Im currently making a program that can make simple 3d scene, made of simple objects like cubes, spheres, cylinders and such....
however I need some sort of orentation.
I want the data in 1 vertexlist, so glRotate and such wont work...The data in the vertexlist has to be prerotated
I have considered using 2 angles....however I''m not quite sure how to implement it though.
it would be really neat if anyone have got a easy and space efficent solution.......

# Rotation of simple objects

Started by ManDark, Jul 24 2001 09:50 PM

2 replies to this topic

###
#2
Members - Reputation: **351**

Posted 24 July 2001 - 11:19 PM

> however I need some sort of orentation.

> I want the data in 1 vertexlist, so glRotate and such wont

> work...The data in the vertexlist has to be prerotated

I''m sure you could rotate it by incorporating the object rotate matrix into the matrix used to render the object. E.g. you should have a view matrix that transforms the vertices to the screen. To rotate an object in the world just combine (multiply) it''s rotation matrix with the view matrix before rendering, then restore the view matrix afterwards if there are other objects in the scene which have not been rotated. I think GL has funcitons for this.

Alternately you can pre-multiply the object vertices by an appropriate matrix. The matrix is the same and you should get the same result each way.

You can use angles. One way is to use the input angles to generate two or three rotation matrices about two perpendicular axes and multiply them to produce the object rotation matrix. This is OK for just rotating an object interactively but it does not produce very realistic behaviour, for which you''ll want to use object dyamics appropriate to your game type.

> I want the data in 1 vertexlist, so glRotate and such wont

> work...The data in the vertexlist has to be prerotated

I''m sure you could rotate it by incorporating the object rotate matrix into the matrix used to render the object. E.g. you should have a view matrix that transforms the vertices to the screen. To rotate an object in the world just combine (multiply) it''s rotation matrix with the view matrix before rendering, then restore the view matrix afterwards if there are other objects in the scene which have not been rotated. I think GL has funcitons for this.

Alternately you can pre-multiply the object vertices by an appropriate matrix. The matrix is the same and you should get the same result each way.

You can use angles. One way is to use the input angles to generate two or three rotation matrices about two perpendicular axes and multiply them to produce the object rotation matrix. This is OK for just rotating an object interactively but it does not produce very realistic behaviour, for which you''ll want to use object dyamics appropriate to your game type.

###
#3
Members - Reputation: **1373**

Posted 25 July 2001 - 04:05 AM

I suggest you look in the OpenGL red book, Appendix F, to see how to compute the rotation matrix given an axis and angle such as you send to glRotate(). You can easily add translation and uniform scaling on top of the rotation matrix that you compute.

I wonder why you want to send all your vertices at once? Why not send them for each object separately, with different glBegin()...glEnd() blocks? If you have objects with only a very few triangles then I can see sending them at once, but if you have T&L hardware the pretransformation of the vertices may be more costly than splitting the objects up....

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.

I wonder why you want to send all your vertices at once? Why not send them for each object separately, with different glBegin()...glEnd() blocks? If you have objects with only a very few triangles then I can see sending them at once, but if you have T&L hardware the pretransformation of the vertices may be more costly than splitting the objects up....

Graham Rhodes

Senior Scientist

Applied Research Associates, Inc.