- Change their materials for each model used
- Use the command "useAnimationFrom" for each model used
Here is the code I'm using right now.
Code: Select all
IMesh* mesh = smgr->getMesh(meshFile);
nodeAnim = smgr->addAnimatedMeshSceneNode((IAnimatedMesh*)mesh,0,0x0010);
My question is: Is there a way to duplicate the "mesh" pointer content so when each node will not use the same meshbuffers? If possible, how can it be done?
If this is possible, then it will fix all my problems. As of now, I have to put all the animations required inside the same object. And I would really much like to load separate files with their animations and apply them on the character when needed. This will also allow me to create variation by code by changing the textures only.
Edit: Seen something with google but not sure. Could it be something like this?:
Code: Select all
IMesh* mesh = smgr->getMesh(meshFile);
IMesh* duplicate = new IMesh*(mesh);
nodeAnim = smgr->addAnimatedMeshSceneNode((IAnimatedMesh*)duplicate,0,0x0010);
Another important note I almost forgot, I need to duplicate (clone) a animated mesh. I seen that this is possible with static meshes (IMeshManipulator), but not seen anything with animated meshes.
EDIT2: I think I have found a "dirty trick" to make a duplicate of the IAnimatedMesh. I am manipulating the meshcache and renaming all files that are matching the one that I want to load. Not 100% sure it will use different meshbuffers but seem to be working. I will have to check by changing the animation from an instance of a model to see if the others will be affected to be totally sure. Here is my current code to check and rename the mesh filename in the mesh cache:
Code: Select all
//Attempt to create different meshbuffer when getting instances from the meshbuffer. "realfile" is the filename name.
bool result=smgr->getMeshCache()->isMeshLoaded(realFile);
if (result)
{
IAnimatedMesh* oldmesh = smgr->getMeshCache()->getMeshByName(realFile);
smgr->getMeshCache()->renameMesh(oldmesh,realFile+"1"); //Only extend the filename with a "1" at the end.
printf("This mesh %s is already loaded and in the mesh cache\n",realFile.c_str());
}
Code: Select all
IAnimatedMesh* mesh->clone()