conormcc

05-11-2009, 03:33 AM

Hi all,

I am trying to simulate a cube rotating around a bounded box. As the cube rolls it is rotating in a given direction (r1). When the cube rebounds off the box, it's direction and rotation axis changes (r2), relative to its previous rotation and so on until the cube stops (rn). The question I have on this is, for any given keyframe, do I need to apply all n previous rotations in order to get the correct orientation of the cube? Obviously, this can become a lot of work when there are multiple cubes rotation in any direction.

I think a nicer solution is to have a single transformation matrix for the cube that holds the result of all previous rotations, a rotation angle and rotation vertex. Then at each keyframe, I calculate a rotation matrix and apply it to the transformation matrix to get the new orientation. I am not sure how to do this though.

I want to be able to add some physics into the mix as well to simulate bouncing, collisions, etc but for now i just want to learn how to rotate the cube around the screen.

I imagine this is a regular problem for noobs like myself. By the way I am using opengl es 1.1.

I'd be grateful for any help on how to approach this problem.

Cheers,

I am trying to simulate a cube rotating around a bounded box. As the cube rolls it is rotating in a given direction (r1). When the cube rebounds off the box, it's direction and rotation axis changes (r2), relative to its previous rotation and so on until the cube stops (rn). The question I have on this is, for any given keyframe, do I need to apply all n previous rotations in order to get the correct orientation of the cube? Obviously, this can become a lot of work when there are multiple cubes rotation in any direction.

I think a nicer solution is to have a single transformation matrix for the cube that holds the result of all previous rotations, a rotation angle and rotation vertex. Then at each keyframe, I calculate a rotation matrix and apply it to the transformation matrix to get the new orientation. I am not sure how to do this though.

I want to be able to add some physics into the mix as well to simulate bouncing, collisions, etc but for now i just want to learn how to rotate the cube around the screen.

I imagine this is a regular problem for noobs like myself. By the way I am using opengl es 1.1.

I'd be grateful for any help on how to approach this problem.

Cheers,