I am using Bullet physic in my simulation.
I have a cylinder at pos(0,0,0) and rotation(0,0,0)
Then i apply an angular velocity to Cylinder to make it rotating over Y axis :
Code: Select all
btScalar AngVelocity = 1;
CylinderRigidBody->setAngularVelocity(btVector3(0,AngVelocity,0));
Problem is this :
I expect to cylender rotation change like this :
(0,1,0) > (0,2,0) > ....... > (0,90,0) > ( 0,91,0 ) > (0,92,0) > (0,93,0) > .....>(0,180,0)....... (0,269,0 ) > (0,270,0)
But, what i get is like this :
(0,0,0) > (0,2,0) > ....... > (0,90,0) > (180,89,180) > (180,88,180 ) >(180,87,180)>.... (180,0,180)>.....(180,-89,180)->(0,-90,0)->(0,-89,0)....
For example instead of (0,91,0) , node rotation is (180,89,180) which make no difference in rendering time, but it cause some Irrlitch functions not to work correctly. (for example RotationToDirection())
This difference happens when i update nodes rotation on scene according to Bullet rigidbodu transformation
I tried these two methods :
Code: Select all
1-
vector3df Euler;
const btQuaternion& TQuat = TObject->getOrientation();
quaternion q(TQuat.getX(), TQuat.getY(), TQuat.getZ(), TQuat.getW());
q.toEuler(Euler);
Euler *= RADTODEG;
Node->setRotation(Euler);
2-
irr::core::matrix4 mat;
irr::f32 * ptr;
ptr = mat.pointer();
tr.getOpenGLMatrix(ptr);
Node->setRotation(mat.getRotationDegrees());Both of them are working good and i get correct physic simulation in my scene, but Rotation vector is not as simple as i expected.
For example instead of (0,269,0 ) it returns (180,-89,180)
So, is there any solution to update node rotation in a better manner? or simplify Bullet rotation values?