Hello !
I have a character (ms3d) with the head, the left arm and the right arm attach to a node named "bip01", I can rotate the head separatly. But i have a problem with the rotation of arms : Error of axis of rotation. So I'd like to know how to change the axis of rotation of an node (an ms3d mesh) ?
Thanks in advance.
Axis of rotation
-
- Posts: 360
- Joined: Tue Feb 10, 2004 2:20 am
- Location: Lubbock, TX
-
- Posts: 29
- Joined: Fri Sep 19, 2003 8:36 am
Code to rotate the arms with the keyboard:
Code to display the body (perso = character; corps = body) :
Code to display the body (bras = arm; gauche = left) :
The first picture shows the arm attached to the body :
The second picture shows the arm when I rotate it :
Code: Select all
case KEY_KEY_Y:
{
core::vector3df r = perso2_bras_gauche->getRotation();
if (r.X == 360)
r.X=0.0f;
else
r.X += 1.0f;
perso2_bras_gauche->setRotation(r);
}
return true;
case KEY_KEY_H:
{
core::vector3df r = perso2_bras_gauche->getRotation();
if (r.X == 360)
r.X=0.0f;
else
r.X -= 1.0f;
perso2_bras_gauche->setRotation(r);
}
return true;
Code to display the body (perso = character; corps = body) :
Code: Select all
scene::IAnimatedMesh* mesh = 0;
mesh = smgr->getMesh("./perso2/corps.ms3d");
if (mesh)
{
perso2_corps = smgr->addAnimatedMeshSceneNode(mesh);
scene::ISceneNodeAnimator* perso2_corps_col = smgr->createCollisionResponseAnimator(
selector, perso2_corps, core::vector3df(10,40,10),
core::vector3df(0,-100,0), 100.0f,
core::vector3df(0,-40,0));
perso2_corps->addAnimator(perso2_corps_col);
perso2_corps_col->drop();
if (perso2_corps)
{
perso2_corps->setPosition(core::vector3df(0,0,0));
perso2_corps->setMaterialTexture(0, device->getVideoDriver()->getTexture("./perso2/corps.bmp"));
perso2_corps->setMaterialFlag(video::EMF_LIGHTING, true);
perso2_corps->addShadowVolumeSceneNode();
}
}
Code: Select all
scene::IAnimatedMesh* mesh2 = 0;
mesh2 = smgr->getMesh("./perso2/bras_gauche.ms3d");
if (mesh2)
{
perso2_bras_gauche = smgr->addAnimatedMeshSceneNode(mesh2);
if (perso2_bras_gauche)
{
perso2_bras_gauche->setAnimationSpeed(25);
perso2_bras_gauche->setMaterialTexture(0, device->getVideoDriver()->getTexture("./perso2/corps.bmp"));
perso2_bras_gauche->setMaterialFlag(video::EMF_LIGHTING, true);
perso2_bras_gauche->addShadowVolumeSceneNode();
}
}
scene::ISceneNode *bras_gauche = perso2_corps->getMS3DJointNode("Bip01");
perso2_bras_gauche->setPosition(core::vector3df(0,0,0));
tete->addChild (perso2_bras_gauche);
The second picture shows the arm when I rotate it :
-
- Posts: 28
- Joined: Wed Oct 08, 2003 9:09 am
- Location: Annecy - FRANCE
HS: Private message
I send you a message.