Robin Forster

02-06-2003, 09:56 AM

My OpenGL graphics engine allows a user to load an object that is specified relative to its own internal origin. The object may also be rotated about any of the three major axis. The object can then be painted (with texturing) at any model view location.

My problem is that the new origin say (vx,vy,vz) must also be rotated. I have done this by using the modelview matrix and multiplying it against the aforementioned vector (new origin). However this does not seem to rotate it properly. The following is the algorithm used:

1. rotate to the worlds rotation (rx, ry, rz)

2. translate to (0.0, 0.0, 0.0)

3. get the modelview matrix

4. multiply the matrix against the position

vector (vx,vy,vz) (Mv = p)

5. reset the modelview matrix to identity

6. rotate the object by its internal rotation

and the worlds rotation (three axis)

7. translate to the new previously

calculated position vector p.

8. If the object is inside the frustum then

paint it.

This does not seem to plave the object correctly with respect to the floor of my test world.

Any ideas?

Robin

My problem is that the new origin say (vx,vy,vz) must also be rotated. I have done this by using the modelview matrix and multiplying it against the aforementioned vector (new origin). However this does not seem to rotate it properly. The following is the algorithm used:

1. rotate to the worlds rotation (rx, ry, rz)

2. translate to (0.0, 0.0, 0.0)

3. get the modelview matrix

4. multiply the matrix against the position

vector (vx,vy,vz) (Mv = p)

5. reset the modelview matrix to identity

6. rotate the object by its internal rotation

and the worlds rotation (three axis)

7. translate to the new previously

calculated position vector p.

8. If the object is inside the frustum then

paint it.

This does not seem to plave the object correctly with respect to the floor of my test world.

Any ideas?

Robin