Page 1 of 1
Axis of rotation
Posted: Thu Feb 19, 2004 11:02 am
by Soldier of infortune
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.
Posted: Thu Feb 19, 2004 2:27 pm
by thesmileman
How are your rotating it currently show us some code?
Posted: Thu Feb 19, 2004 3:29 pm
by Soldier of infortune
Code to rotate the arms with the keyboard:
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 to display the body (bras = arm; gauche = left) :
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 first picture shows the arm attached to the body :
The second picture shows the arm when I rotate it :

HS: Private message
Posted: Mon Feb 23, 2004 9:21 am
by LEFRANCAIS
I send you a message.