   permanent rotation
  Hi,I'd like to know if it is possible to change the rotation of an object permanently I mean everytime when it is going to be drawn it will be rotated like I set. And this is the reason why I need it: I'm simulating a ball rolling on a table, I have the rotation speed and also the rotation axis, the rotation is simply done by glRotatef(x,y,w,z) function. But every time the ball collides with something and the rotation axis changes, the next rotation of the ball has to continue from the rotation-state at the time of the collision.I hope it is understandable.I tried to fix it with remembering all the rotation-angles and rotation axes and getting through all these rotations before the actual rotation (actual step of the simulation) but I don't think this is the best way how this can be done, so can anybody help me?Thanks   
Quote:Original post by Zviri...I tried to fix it with remembering all the rotation-angles and rotation axes and getting through all these rotations before the actual rotation (actual step of the simulation) but I don't think this is the best way how this can be done, ...It is indeed the way to go ... but probably not as you mean it: You have to accumulate all rotations (i.e. the delta rotation done from one rendered frame to the next). At any time you're interested in the current orientation, and that is given by the accumulated rotations occured in the history of rolling the ball.Accumulation cannot be done with axis/angle pairs very well. You should use a rotation matrix or a quaternion instead. In the case of matrices you have to orthonormalize frequently, and in the case of quaternions you have to convert it to a matrix just before rendering. However, ultimately use the matrix with glMultMatrix to perform the rotation when rendering.Notice please that "accumulation" for rotations, regardless whether stored in a matrix or in a quaternion, actually means to multiply the rotation so far by the new delta rotation. Notice further that it plays a role whether you multiply likecurrentRot := currentRot * deltaRotor elsecurrentRot := deltaRot * currentRotBecause you want to apply the deltaRot onto the currentRot as remembered so far, you have to use the former formula when using row vectors, and the latter formula when using column vectors.   ;  You can't really create a permanent rotation of your ball in opengl, but there are many ways to achieve the effect that you want.There's a couple different options here depending on how much work you're willing to do:1) You can store the final rotation of the ball in the ball class, and then perform that rotation before applying any new rotations (this sounds like what you are trying now)2) You can download the current modelview matrix from opengl after a frame and store it in the ball. Then when you're ready to move that ball in the next frame, you send the modelview matrix back to opengl, and apply your subsequent rotations on that. Using this method however you cannot move your camera, because the camera position is baked into the modelview matrix. 3) Implement your own matrix class (or use a math library) which is contained in the ball, and perform rotations on this. Then instead of calling glTranslate, glRotate, you use your own matrix: matrix.Translate(), matrix.Rotate(). Then once the ball is in position you call glMultMatrixf(matrix) to apply your model matrix to the view matrix. This one is the most work, but also the best approach in terms of future opengl compatibility (you are supposed to handle your own matrices in the new opengl standard, and all of the glTranslate,glRotate commands are depreciated now).   ;  Ok thank you both, I think I know the way to go now.   