Hey all!

I have been working on my first 3D game (and entry to the compo!), and I came across something tricky.
I made sure I read all the threads in this forum, so as not to repeat someone else. I saw NecroDome asked something similar a couple of months ago but seems to have given up on the thread.

Here it is:
In your 3D 'World', you have a 'board' (rectangle). The coordinates to the centre of the board are Wx, Wy and Wz; its rotation is RWx, RWy and RWz. Now, with opengl, to draw the board, all i need to do is
translatef(Wx,Wy,Wz); //move to centre of board
rotatef(RWx, 1, 0, 0); // rotate board (= entire world)
rotatef(RWy, 0, 1, 0);
rotatef(RWz, 0, 0, 1);
calllist(board); //draw board

ok, i have had tht working for a while.
Then, I created a tank, which has coordinates Tx, Ty and Tz, from the left-top corner of the board (important!); and rotation RTx, RTy and RTz (where rotation=(0,0,0) means the tank is flat on the board and facing the right).
The tank is therefore 'linked' to the board, since it is defined relative to the board.
Similarly, to draw the board and the tank, i write the same code as above, plus:
translatef(-boardsize.x/2,-boardsize.y/2,-boardsize.z/2); //move to top left corner of the board
translatef(Tx,Ty,Tz); // move to position of tank
rotatef(RTx, 1, 0, 0); // rotate tank
rotatef(RTy, 0, 1, 0);
rotatef(RTz, 0, 0, 1);
calllist(tank); // draw tank

Clear, so far?
Well, now, I decided to 'see' the 'world' from the tank's point of view, when a certain key is pressed.

That's where im having trouble. You see, everything is drawn relative to the centre of the board, so all I need to do is to calculate the World(centre of the board) coordinates from the tank (that took me a few hours to figure out! cos i first thought it was even more complicated!)!

Obviously, if the tank is not rotated, it's very straight forward, just work out (boardsize.x/2-Tx) and (boardsize.y/2-Ty) and (boardsize.z/2-Tz) and place the centre of the board there!

But when I start rotating in all three axis, I cannot work out the position and the rotations of the World so that the 'camera' is positioned at Tx, Ty, Tz, with the correct angle.

In NecroDome's thread previous to this, I saw that the way to do it seems to depend on the order you move, rotate and draw everything. However, in my program, i always translate, THEN rotate along the X, THEN rotate along the Y, THEN rotate along the Z axis, like in the code above.
See?

I have started working out equations with 2 or three variables to place the centre of the board. so I have Wx = f(RTx,RTy) and Wz = f(RTy,RTz), but while I don't get equations for Wy and for RWx, RWy and RWz, I can't test it!

Im asking because Im sure many ppl have come across changing views like this, so maybe you have a made procedure to deal with it, or jst the formulae im needing...

Well, enough said. If there is anything not clear, please let me know.