本文整理汇总了C++中MeshPtr::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::clone方法的具体用法?C++ MeshPtr::clone怎么用?C++ MeshPtr::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCloneMesh
void MeshWithoutIndexDataTests::testCloneMesh()
{
String originalName = "toClone.mesh";
createMeshWithMaterial(originalName);
MeshPtr mesh = mMeshMgr->getByName(originalName);
String fileName = "clone.mesh";
MeshPtr clone = mesh->clone(fileName);
CPPUNIT_ASSERT(mesh->getNumSubMeshes() == 4);
MeshSerializer meshWriter;
meshWriter.exportMesh(mesh.get(), fileName);
mMeshMgr->remove( fileName );
ResourceGroupManager::getSingleton().addResourceLocation(".", "FileSystem");
MeshPtr loadedMesh = mMeshMgr->load(fileName, "General");
remove(fileName.c_str());
CPPUNIT_ASSERT(loadedMesh->getNumSubMeshes() == 4);
mMeshMgr->remove( fileName );
}
示例2: setupContent
//---------------------------------------------------------------------
void PlayPen_testPoseAnimationWithoutNormals::setupContent()
{
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
Vector3 dir(-1, -1, 0.5);
dir.normalise();
Light* l = mSceneMgr->createLight("light1");
l->setType(Light::LT_DIRECTIONAL);
l->setDirection(dir);
MeshPtr mesh = MeshManager::getSingleton().load("cube.mesh",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
String newName = "testposenonormals.mesh";
mesh = mesh->clone(newName);
SubMesh* sm = mesh->getSubMesh(0);
// Re-organise geometry since this mesh has no animation and all
// vertex elements are packed into one buffer
VertexDeclaration* newDecl =
sm->vertexData->vertexDeclaration->getAutoOrganisedDeclaration(false, true, false);
sm->vertexData->reorganiseBuffers(newDecl);
// create 2 poses
Pose* pose = mesh->createPose(1, "pose1");
// Pose1 moves vertices 0, 1, 2 and 3 upward
Vector3 offset1(0, 50, 0);
pose->addVertex(0, offset1);
pose->addVertex(1, offset1);
pose->addVertex(2, offset1);
pose->addVertex(3, offset1);
pose = mesh->createPose(1, "pose2");
// Pose2 moves vertices 3, 4, and 5 to the right
// Note 3 gets affected by both
Vector3 offset2(100, 0, 0);
pose->addVertex(3, offset2);
pose->addVertex(4, offset2);
pose->addVertex(5, offset2);
Animation* anim = mesh->createAnimation("poseanim", 20.0f);
VertexAnimationTrack* vt = anim->createVertexTrack(1, sm->vertexData, VAT_POSE);
// Frame 0 - no effect
VertexPoseKeyFrame* kf = vt->createVertexPoseKeyFrame(0);
// Frame 1 - bring in pose 1 (index 0)
kf = vt->createVertexPoseKeyFrame(3);
kf->addPoseReference(0, 1.0f);
// Frame 2 - remove all
kf = vt->createVertexPoseKeyFrame(6);
// Frame 3 - bring in pose 2 (index 1)
kf = vt->createVertexPoseKeyFrame(9);
kf->addPoseReference(1, 1.0f);
// Frame 4 - remove all
kf = vt->createVertexPoseKeyFrame(12);
// Frame 5 - bring in pose 1 at 50%, pose 2 at 100%
kf = vt->createVertexPoseKeyFrame(15);
kf->addPoseReference(0, 0.5f);
kf->addPoseReference(1, 1.0f);
// Frame 6 - bring in pose 1 at 100%, pose 2 at 50%
kf = vt->createVertexPoseKeyFrame(18);
kf->addPoseReference(0, 1.0f);
kf->addPoseReference(1, 0.5f);
// Frame 7 - reset
kf = vt->createVertexPoseKeyFrame(20);
// Export the mesh
DataStreamPtr stream = Root::getSingleton().createFileStream(newName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
MeshSerializer ser;
ser.exportMesh(mesh.get(), stream);
stream->close();
// Unload old mesh to force reload
MeshManager::getSingleton().remove(mesh->getHandle());
mesh->unload();
mesh.setNull();
Entity* e;
AnimationState* animState;
// software pose
e = mSceneMgr->createEntity("test2", newName);
mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(150,0,0))->attachObject(e);
animState = e->getAnimationState("poseanim");
animState->setEnabled(true);
animState->setWeight(1.0f);
mAnimStateList.push_back(animState);
// test hardware pose
e = mSceneMgr->createEntity("test", newName);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(e);
//.........这里部分代码省略.........
示例3: addinterval
FlexBody::FlexBody(SceneManager *manager, node_t *nds, int numnds, char* meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot, char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin, bool enableShadows, MaterialReplacer *mr) : snode(0), faulty(false), mr(mr)
{
nodes=nds;
numnodes=numnds;
cref=ref; nodes[cref].iIsSkin=true;
cx=nx; nodes[cx].iIsSkin=true;
cy=ny; nodes[cy].iIsSkin=true;
coffset=offset;
cameramode=-2; // all cameras
enabled=true;
haveshadows=(manager->getShadowTechnique()==SHADOWTYPE_STENCIL_MODULATIVE || manager->getShadowTechnique()==SHADOWTYPE_STENCIL_ADDITIVE);
havetangents=false;
haveblend=true;
freenodeset=0;
//parsing set definition
char* pos=setdef;
char* end=pos;
char endwas='G';
while (endwas!=0)
{
unsigned int val1, val2;
end=pos;
while (*end!='-' && *end!=',' && *end!=0) end++;
endwas=*end;
*end=0;
val1=strtoul(pos, 0, 10);
if (endwas=='-')
{
pos=end+1;
end=pos;
while (*end!=',' && *end!=0) end++;
endwas=*end;
*end=0;
val2=strtoul(pos, 0, 10);
addinterval(val1, val2);
}
else addinterval(val1, val1);
pos=end+1;
}
/*
// too verbose, removed
for (int i=0; i<freenodeset; i++)
LOG("FLEXBODY node interval "+TOSTRING(i)+": "+TOSTRING(nodeset[i].from)+"-"+TOSTRING(nodeset[i].to));
*/
Vector3 normal = Vector3::UNIT_Y;
Vector3 position = Vector3::ZERO;
Quaternion orientation = Quaternion::ZERO;
if(ref >= 0)
{
normal=(nodes[ny].smoothpos-nodes[ref].smoothpos).crossProduct(nodes[nx].smoothpos-nodes[ref].smoothpos);
normal.normalise();
//position
position=nodes[ref].smoothpos+offset.x*(nodes[nx].smoothpos-nodes[ref].smoothpos)+offset.y*(nodes[ny].smoothpos-nodes[ref].smoothpos);
position=(position+normal*offset.z);
//orientation
Vector3 refx=nodes[nx].smoothpos-nodes[ref].smoothpos;
refx.normalise();
Vector3 refy=refx.crossProduct(normal);
orientation=Quaternion(refx, normal, refy)*rot;
} else
{
// special case!
normal = Vector3::UNIT_Y;
position=nodes[0].smoothpos+offset;
orientation = rot;
}
// load unique mesh (load original mesh and clone it with unique name)
// find group that contains the mesh
String groupname="";
try
{
groupname = ResourceGroupManager::getSingleton().findGroupContainingResource(meshname);
}catch(...)
{
}
if(groupname == "")
{
LOG("FLEXBODY mesh not found: "+String(meshname));
faulty=true;
return;
}
// build new unique mesh name
char uname_mesh[256];
memset(uname_mesh, 0, 254);
strcpy(uname_mesh, uname);
strcat(uname_mesh, "_mesh");
MeshPtr mesh = Ogre::MeshManager::getSingleton().load(meshname, groupname);
MeshPtr newmesh = mesh->clone(uname_mesh);
// now find possible LODs
String basename, ext;
StringUtil::splitBaseFilename(String(meshname), basename, ext);
for(int i=0; i<4;i++)
{
//.........这里部分代码省略.........