how to apply ISkinnedMesh to several nodes?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

how to apply ISkinnedMesh to several nodes?

Post by comicsteam »

I made two .x files:
"mesh.X" contains the mesh and bones
"anim.X" contains the bone animation

I tried to add 3 nodes with different animation speed.
here's my code:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("mesh.X");
((scene::ISkinnedMesh*)mesh)->useAnimationFrom((scene::ISkinnedMesh*)smgr->getMesh("anim.X"));

IAnimatedMeshSceneNode* node;

//---- node 1
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(4800.0);

//---- node 2
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(1300.0);
node->setPosition(core::vector3df(1.0,0.0,0.0));

//---- node 3
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(2200.0);
node->setPosition(core::vector3df(2.0,0.0,0.0));
however, the result seems strange.....
all the bounding box are incorrect. :(
Image

Then, I tried to add 3 nodes with same animation speed, but different current frame.
here's my code:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("mesh.X");
((scene::ISkinnedMesh*)mesh)->useAnimationFrom((scene::ISkinnedMesh*)smgr->getMesh("anim.X"));

IAnimatedMeshSceneNode* node;

//---- node 1
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(4800.0);

//---- node 2
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(4800.0);
node->setCurrentFrame(30.0);
node->setPosition(core::vector3df(1.0,0.0,0.0));

//---- node 3
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setDebugDataVisible( scene::EDS_BBOX |
			scene::EDS_BBOX_BUFFERS |
			scene::EDS_SKELETON);
node->setAnimationSpeed(4800.0);
node->setCurrentFrame(30.0*4800.0);
node->setPosition(core::vector3df(2.0,0.0,0.0));
all the nodes have the same animation :shock:
Image

how can i fix this problem?
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

check this out
Image
Image
Post Reply