opengl matrix rotation quaternions -


I am trying to do simple rotation of a cube about X and Y axis:

I want to always rotate the cube on the x axis and rotate the amount of x, and the X axis rotates independently from the y amount of quadrilateral

ago I had disappointed:

  glRotatef (x, 1,0,0); GlRotatef (y, 0,1,0);  

then

but it rotates on the first x, then moves on y, to rotate the x access independently on y.

I started looking for a quadrilateral, so I tried:

  Quarteran rotation 1; Rotation1.createFromAxisAngle (0,1, 0, globalratitude); Rotation1.normalize (); Quaternion rotation 2; Rotation2.createFromAxisAngle (1,0, 0, global rotor x); Rotation2.normalize (); GL Float Matrix [16]; Quaternion Q = Rotation 2 * Rotation 1; Q.createMatrix (matrix); GlMultMatrixf (matrix);  

It's almost perfectly ok to do 2 consecutive glRotates what was accomplished ... so I guess I'm not missing a stage or 2.

Is there a way to go quatnions or should I use something different? And if there is a way to go quadrilateral, then I can take steps to rotate the cube independently of each axis. I think someone else has the same problem:

< P>

I have found that working Quattroniens properly: I believe there are other ways, but some reseach afeter, it Worked perfectly for me I have a similar version post on another forum The T.

Before making the quaternier presentation of the angles of the change of X / Y, each frame has multiplied the quadrilateral by changing the quadrilateral, then ultimately to convert that quaternion to the matrix form, the current matrix Have to multiply. Here is the main code of the loop:

  Quaternion3D Rotation1 = Quaternion3DMakeWithAxisAndAngle (Vector 3D Mackay (-1.0F, 0,0), DGEERRODRIIIIS (GlobalRotetax)); Quaternion3DNormalize (& Rotation1); Quaternion3D Rotation2 = Quaternion3DMakeWithAxisAndAngle (Vector 3D Mac (0.0F, -1.0F, 0), DGEEROHOIRDISS (GlobalRotetry)); Quaternion3DNormalize (& Rotation2); Matrix 3D mat; Matrix3DSetIdentity (mat); Quaternion3DMultiply (& QAccum, and Rotation 1); Quaternion3DMultiply (& QAccum, and Rotation 2); Matrix 3DSetUsingQuaternion3D (mat, QAccum); GlobalRotateX = 0; GlobalRotateY = 0; GlMultMatrixf (mat);  

then drag the cube


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -