I am making a basic model viewer that loads in a mesh from a file and renders it on the screen. I have the camera set down the negative Y axis looking towards the origin. I did this because I wanted my model (which I didn't make, I just downloaded one and this is how it was set up) to be "facing away" from me without any rotation applied to it. You can then use the arrow buttons to rotate the mesh, pitch it up and down and roll it.
I have some code that uses vector3df data passed into the scene node's setRotation function. This works well until I try to roll it over, and I start getting weird results. No problem, this was anticipated since it was a known limitation of working with these parameters.
All over the place people say to use quaternions. This is where I need my first brain check. I'm trying to get the model to point in a direction, say up and to the rightat a 45 degree angle. I would think that I could do the following...
Code: Select all
quaternion q1(-45*DEGTORAD,0,35*DEGTORAD,20*DEGTORAD);
q1.normalize();
q1.toEuler(rot);
node->setRotation(rot);
I don't see any rotation at all.
What am I doing wrong? I'm guessing that this is a common operation, so there should be plenty of code out there, but I cannot seem to find anything that works. I would like to boil this down to the simplest example, if possible.