i've got a problems which i've been trying to solve for a day now
I'm rotating an object by and arcball based controller, it's been working
great, except all rotations that are clamped in a [0..360] range( after normalizing ). Now i don't want this, because i want to key frame animations, where a range greater than the[0...360] is needed.
But i can't quite figure it out, this is some code i had
//determine amount of full revolutions
//do this only once
//onMouseDown()
m_revX = ((int)m_newRotation.getPitch())/360;
m_revY = ((int)m_newRotation.getRoll())/360;
m_revZ = ((int)m_newRotation.getYaw())/360;
if(m_revX<0)
m_revX--;
if(m_revY<0)
m_revY--;
if(m_revZ<0)
m_revZ--;
//onMouseDrag()
EulerAngle oldRot = m_newRotation;
oldRot.correctRotation(); //clamp in [0...360] range
m_newRotation = dMat.toEulerAngle(); //matrix to eulers
m_newRotation.correctRotation(); //clamp in [0...360] range
int oldPitch = ((int)oldRot.getPitch())%360;
int oldRoll = ((int)oldRot.getRoll())%360;
int oldYaw = ((int)oldRot.getYaw())%360;
float newPitch = m_newRotation.getPitch();
float newRoll = m_newRotation.getRoll();
float newYaw = m_newRotation.getYaw();
//determine new revolution
if(oldPitch > 315 && newPitch < 45 )
{
m_revX++;
}
else if ( oldPitch < 45 && newPitch> 315)
{
m_revX--;
}
if(oldRoll>315 && newRoll<45)
{
m_revY++;
}
else if ( oldRoll < 45 && newRoll> 315)
{
m_revY--;
}
if(oldYaw>315 && newYaw <45)
{
m_revZ++;
}
else if ( oldYaw < 45 && newYaw > 315)
{
m_revZ--;
}
m_newRotation.setPitch(m_revX * 360 + m_newRotation.getPitch());
m_newRotation.setRoll(m_revY * 360 + m_newRotation.getRoll());
m_newRotation.setYaw(m_revZ * 360 + m_newRotation.getYaw());
Regards,
Marks












