Is it possible to convert the yaw Euler angle got from the Bullet physics engine using
btTransform trans;
trans.getBasis().getEulerYPR(rx, ry, rz);
into the range [0 , 360]. Otherwise for a 360 deg rotation I get the Euler angle varying from 0->90->0-> -90 -> 0
but I want from 0->90->180->270->0
My graphics API only accepts rotation angles in the range of 0 to 360
Well, the 0->90->0-> -90 was the pitch value. Here is the code I use now :
trans.getBasis().getEulerYPR(yaw, pitch, roll);
y1 = (pitch >= 0) ? pitch : (PI2 + pitch);
I was trying to add 180 for negative values of pitch, but that doesnt work. Well it seems I ll need to find another way to rotate meshes smoothly using euler angles.
Update: It seems I should not use the bullet functions directly. A better option is deal with the basis matrix directly :
btMatrix3x3 m_el = trans.getBasis();
ry = btAtan2( m_el[0].z(), m_el[0].x() );
if(ry < 0)
ry += SIMD_PI;
So that gave me the rotation about the y-axis. Now about the other 2 ....phew !