moving a object


I think my last topic was a little bit misunderstood. I’m explaining my problem with more details …

I have designed a cube. with some keys i can move, rotate, … the cube. This works everything, no problem. After every keystroke my object is new computed and shown (mostly correct ). Only in one situation there is a mistake:
I can move my cube along the axis correctly,
but after a rotation of my cube (for example 45 degrees in direction of the negative z-axis) the translation isn’t anymore in the direction of the coordinate axis. When i want to move my object in the positive x-axis (right), the cube moves in two directions: right and down

here are the matrices, where i store my moves:

after the first translation (one step left):

matrix on the stack

1 0 0 -1
0 1 0 0
0 0 1 0
0 0 0 1

after the rotation (-45 degrees, z-axis)

(The figures are not the real, i have only taken some)
matrix on the stack

0.707 0.707 0 -0,1111
-0.707 0.707 0 -0,2222
0 1 1 0
0 0 0 1

now i want to move the spinned cube one step in the positive x-direction.

matrix on the stack

0.707 0.707 0 0,777
-0.707 0.707 0 -0,888 ***
0 1 1 0
0 0 0 1

Why do my value ***, which is responsible for the y-direction, change ?? Because of this change my object moves downwards too, but i only want to move the spinned cube in the x-direction.

my translation-matrix for x-direction +1 is

1 0 0 1
0 1 0 0
0 0 1 0
0 0 0 1

Sorry for posting this again, but it is very impotant. I hope somebody can answer my question, thx a lot …

When you rotate the cube, you need to first translate the cube so that its center is at the origin. Then you may rotate the cube. After rotating, move the cube back to where it was. And finally translate the cube to the position it should be at in the world. You can remove those initial translations if you design your cube so that its center coincides with the origin in object space.

I know, that i have to move my cube with its center in the origin.
This is not the mistake.

If you are certain the order of operations is correct, then you must have a bug somewhere else. But the way you describe the problem, it sounds to me, like you are simply doing the operations out of order.

what i don’t understand is, that a multiplication by

matrix A:


do change the values x,y


this is impossible, only the x value should be changed not the y.

I multiplicate (glMultMatrix) the matrix on the Stack with the matrix A and this thing happens…
Could you explain me that ???