How to get turn pitch roll with Irrlicht
Posted: Wed May 26, 2004 4:04 pm
If you were trying to make flight or car simulator than you probably encoutered problem with setRotation() function. It uses so caled Euler angles. Here is way hove to get rid of it using matrix4 class. When writing this code I was largely inspired by Steve Baker's article at http://sjbaker.org/steve/omniv/eulers_are_evil.html
There is bug in matrix4::getRotationDegrees() function, you have to apply this fix in order to get it right:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2234
Another bug in matrix4 class can be fixed like this:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2458
Code: Select all
vector3df r = node->getRotation(); //get current rotation (euler)
matrix4 m;
m.setRotationDegrees(r); //set firsth matrix to current rotation
//use one you need:
vector3df rp = vector3df(angle,0,0); //pitch
//vector3df rp = vector3df(0,angle,0); //turn
//vector3df rp = vector3df(0,0,angle); //roll
matrix4 mp;
mp.setRotationDegrees(rp); //set second matrix to rotation to add
m *= mp; //multipy them
r = m.getRotationDegrees(); //get rotation vector from matrix (euler)
node->setRotation(r); //rotate node
There is bug in matrix4::getRotationDegrees() function, you have to apply this fix in order to get it right:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2234
Another bug in matrix4 class can be fixed like this:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2458