How can I clone a IAnimatedMeshX?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Guest

How can I clone a IAnimatedMeshX?

Post by Guest »

Once I loaded two .x file with the same name, the getMesh only returns the same IAnimatedMesh* pointer. I created two difference IAnimatedSceneNode to controll this model, but they has same animation.

I want to have the IAnimatedMeshX cloned. What shall I do?


scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh(filename);

if (!m)
{
// model could not be loaded
return;
}

// set default material properties

Model1 = Device->getSceneManager()->addAnimatedMeshSceneNode(m);

Model2 = Device->getSceneManager()->addAnimatedMeshSceneNode(m);

________________

I want model1 and model2 have them own action but the same mesh file.

((IAnimatedMeshX*)m)->setCurrentAnimation("walk"); can set the x model animation, but this lead model1 and model2 has the same action.

I want to have it cloned.

who knows?
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Hmm, that is very strange. I have a loop that adds the same file ( a map tile ) 40x40 times. I didn't do anything different to what you have done there. Are you sure it returned the same pointer on both instances? Have you tried moving one and it moves the other as well?

Here's the code I used:

Code: Select all

	for (int mapCntX = 0; mapCntX < 40; mapCntX++)
	{
		for (int mapCntY = 0; mapCntY < 40; mapCntY++)
		{
			levels[id]->Map[mapCntX][mapCntY] = new MapTile;

			levels[id]->Map[mapCntX][mapCntY]->Pointer = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../Game Data/meshes/tile.3DS"));
				levels[id]->Map[mapCntX][mapCntY]->Pointer->setPosition(core::vector3df(mapCntX, 0, mapCntY ));
				levels[id]->Map[mapCntX][mapCntY]->passable = true;
				levels[id]->Map[mapCntX][mapCntY]->Pointer->setID(1);

				getSubMaterial(levels[id]->Map[mapCntX][mapCntY]->Pointer, 1, levels[id]);
		}
	}
Guest

Post by Guest »

This problem only occurred at IAnimatedMeshX. Because the rest of Mesh Interface such as MD2 or some other model can use scene node to control their action, but the IAnimatedMeshX can't, it only use
((IAnimatedMeshX*)m)->setCurrentAnimation("walk"); to set its AnimationSet. If you load a .x file(Skeleton animation included) twice, there will be two mesh on your screen, but the same acion. and you setCurrentAnimation("walk"); the two then walk, and you setCurrentAnimation("Run"); the two mesh then run in the same way.
Electron_

Post by Electron_ »

Well, it adds slightly more code and is a nuisance, but simply loading the modal from file into two separate meshes should solve the problem without too much trouble, wouldn't it?
Post Reply