Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Translation & Rotation of multiple objects

610 views
Skip to first unread message

Mike Willhide

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
Sorry about the newbie nature of this question (gotta learn sometime).

How do you move multiple objects in your view independently of each other?
... And then again as a whole (for viewing changes). I'm sure this is a
simple thing but I've never seen code for it in my examples.

I guess you'd have to use a different matrix for each object. Does
translating and rotating a matrix change the original values in that matrix
or copy them somewhere?

Can (will) anyone walk me through this?

Thanks in advance.

Mike.

T.Brown

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
I believe you are looking for the glPushMatrix and glPopMatrix commands.
To manipulate individual objects and not the rest of the scene push the
model matrix on the stack with glPushMatrix and do your manipulations and
then pop the model matrix off the stack with glPopMatrix.


Mike Willhide wrote in message <78p7tn$13...@r02n01.cac.psu.edu>...

Paul Martz

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to

Mike Willhide wrote in message <78p7tn$13...@r02n01.cac.psu.edu>...
>Sorry about the newbie nature of this question (gotta learn sometime).
>
>How do you move multiple objects in your view independently of each other?

Give eavh object a different modelview matrix.

>... And then again as a whole (for viewing changes).

Give each object the same modelview matrix as all other objects.

>I'm sure this is a
>simple thing but I've never seen code for it in my examples.
>
>I guess you'd have to use a different matrix for each object. Does
>translating and rotating a matrix change the original values in that matrix
>or copy them somewhere?

Calls to glRotate and glTranslate will multiply a rotation or a translation
matrix onto the top of the current matrix stack, so yes, it changes the
matrix. If you don't want the matrix permanently altered, you would use
glPushMatrix and glPopMatrix around your changes; after the pop, the matrix
is restored.

An application will typically do the following to render a dynamic scene:

glMatrixMode (GL_MODELVIEW)
glLoadIdentity ()
// Set camera transform

loop (i) over objects
glPushMatrix
// set transform for object(i)
// render object(i)
glPopMatrix
endloop

I hope that is helpful.

-Paul Martz
Hewlett Packard Workstation Systems Lab
To reply, remove "DONTSPAM" from email address.

0 new messages