I'l just briefly introduce myself, My name is Kevin, im from University of Derby, UK and I study Computer Games Programming.
Now for the problem:
I have been assigned to create a cross platform framework for the PSP and Direct3D, this I understand, it is all about abstraction and maximising code sharing, my problem is not here. The demo I am creating with my framework is the issue, I wanted to create a simple Rubik's cube where the user can solve it themselves, have no time to work out the algorithm to solve it automatically, (though I can solve a real one myself). Anywho's I'm rambling, My problem is the rotation...
I have a Cube class which stores verts of <-0.5 -0.5 -0.5 > etc to create a cube of width/height/depth of 1, all with the origin as <0 0 0 > I also store a position vector and a rotation vector.
The position being <-1, 1, -1 > (assuming Z goes into the screen) would position the cube as the top left cube of the front face, if you can picture that...
Next i wanted to store the rotations of each axis so for example, if I wish to rotate the front face 180 degrees, the cube i described above would have a rotation of...
< 0, 0, ToRad(180) >
and would then become the bottom right of the front face.
This works fine, until I start trying to rotate around another axis like so:
[media]
[/media]
As you can see, the way directX or any other API handles the rotation is by XYZ thus if i rotate about X first and then Y, its fine, yet if i rotate around Y and then X, the X rotation is reversed (obviously, this makes sense to me). What my problem is, I dont know how to stop it
Could somebody please explain a better way of doing this? Am I missing something obvious or is this as tricky as it seems?
To calculate my world matrix I do Scale * Translate * Rotate to achieve the offset and then rotate that offset.
Thanks for reading all this, and please help, I would appreciate it SO much!
Kev