Im trying to do a simple rotation of a cube about the x and y axis:
I want to always rotate the cube over the x axis by an amount x and rotate the cube over the yaxis by an amount y independent of the x axis rotation
first i naively did :
glRotatef(x,1,0,0); glRotatef(y,0,1,0);
then
but that first rotates over x then rotates over y i want to rotate over the y independently of the x access.
I started looking into quaternions, so i tried :
` Quaternion Rotation1; Rotation1.createFromAxisAngle(0,1, 0, globalRotateY); Rotation1.normalize();
Quaternion Rotation2;
Rotation2.createFromAxisAngle(1,0, 0, globalRotateX);
Rotation2.normalize();
GLfloat Matrix[16];
Quaternion q=Rotation2 * Rotation1;
q.createMatrix(Matrix);
glMultMatrixf(Matrix);
` that just does almost exactly what was accomplished doing 2 consecutive glRotates ...so i think im missing a step or 2.
is quaternions the way to go or should i be using something different? AND if quaternions are the way to go what steps can i add to make the cube rotate independently of each axis. i think someone else has the same issue: http://stackoverflow.com/questions/1278395/rotating-opengl-scene-in-2-axes