transformations. The functions are cleaned up a bit and some bugs are
fixed.
I've directed at least 3-4 people to this code and it was what they needed.
Everybody needs to do local transformations at some point, and it took me
two weeks just to get the buggy version of these functions working.
So for all you n00bs who are having trouble with this, this is your lucky
day!
Enjoy!
Code: Select all
/*
==========
rotateNode -- rotate a scene node locally
==========
*/
void rotateNode(irr::scene::ISceneNode *node, irr::core::vector3df rot)
{
irr::core::matrix4 m;
m = node->getAbsoluteTransformation();
irr::core::matrix4 n;
n.setRotationDegrees(rot);
m *= n;
node->setRotation(m.getRotationDegrees());
node->updateAbsolutePosition();
}
/*
==========
translateNode -- translate a scene node locally
==========
*/
void translateNode(ISceneNode *node, vector3df vel)
{
irr::core::matrix4 m;
vector3df rot = node->getRotation();
m.setRotationDegrees(rot);
m.transformVect(vel);
node->setPosition(node->getPosition() + vel);
node->updateAbsolutePosition();
}