Rotating object in 3D

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Rotating object in 3D

Post by arras »

There is only one way of rotating object in Irrlicht I found out till now: ->setRotation(vect)
but this rotate object always in Z-Y-X order so Xaxis is rotated with both Y and Z rotations, Y is influenced only by Z and Z is newer influeced by any other rotation.
Thats is OK if you want to rotate on plain but once you want to write something where you need to rotate on all three axis at once like space flight sim or car sim you are lost.

Is there way to change order of rotation in setRotation() function? I was looking at Irrlicht documentation and found irr::core::matrix4 class
namely
irr::core::matrix4::setRotationRadians (const vector3df &rotation)
irr::core::matrix4::setRotationDegrees (const vector3df &rotation)
irr::core::matrix4::getRotationDegrees()
irr::core::matrix4::rotateVect (vector3df &vect)

and irr::core::quaternion class
...is there way to use them to rotate object diferent than using Euler angles
without gimbal lock or to rotate around arbitrary axis?

Before I was programing in Dark Basic and there was posibility to change order of rotation from X-Y-Z to Z-Y-X or to use functions like turn, pitch, roll object which aloved rotation around already rotated axis without reseting rotation.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

OK I finaly seems to got it myself. I dont know if its the best way but it seems to function:
http://irrlicht.sourceforge.net/phpBB2/ ... 3481#13481
Post Reply