🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Opengl accumulte delta eulers >180 from result quaternion

Started by
0 comments, last by DAddill 5 years, 4 months ago

I'm trying to understand how maya, blender, unity etc get new eulers in widget while user rotate model in local coordinate system by gizmo in viewport.
This applications somehow save rotate in eulers but perform operation in quaternions. I can't understand how they save/convert quaternion to eulers and get eulers more than 180 degree
If i simplest convert result quaternion to eulers i can't get result like in applications above. I can't get angle more 180

Unity for example

https://monosnap.com/file/oHigb8FSwopYTZCBjOQLqvh58vbQ8Z

This is my code explain my attemps to do that.
 


Quaternion rotation; //relative (local rotation)
Vector3 eulersRotation;
Quaternion parentRotation;
//it is psevdo code where we calculate delta angle that user generate on current frame by mouse
void SetDeltaWorldRotationFromUserInput(Quaternion value)
{
    SetWorldRotation(value);
}

void SetWorldRotation(Quaternion value)
{
    SetLocalRotation(parentQuaternion.inverted() * value); //set local rotation
}

void SetLocalRotation(Quaternion value)
{
    rotation = value; // we save new local rotation but i want to save somehow more then 180 degree
    auto eulersForGui = value.toEulers(); //it is current eulers but i want to accumulate and show in gui accumulate rotation. like currentRotation + delta or somehow

auto deltaEulers = (value * rotation.inverted()).toEulers(); //i can get delta eulers but i can't add it to       euelers and don't know what i need to do with this value
eulersRotation += deltaEulers; //it is similar wrong. I don't know how to do it correctly
}

 

This topic is closed to new replies.

Advertisement