Rajveer

03-27-2002, 07:30 AM

If I have a whole set of objects in a scene, how can I make it so that only specified objects rotate as opposed to the whole scene?

View Full Version : Rotating some objects only

Rajveer

03-27-2002, 07:30 AM

If I have a whole set of objects in a scene, how can I make it so that only specified objects rotate as opposed to the whole scene?

rIO

03-27-2002, 08:22 AM

You just need to read some more about matrices stack in OpenGL.

Let's try to explain shorty (ollowing OGL Matrice for Dummies) :D

First of all, you must know when I'm talking about matrices I mean rotations,translations and scales mainly.

A matrix can be seen as "a situation".

Keep in mind that you never modify objects in OGL, but you modify coordinate systems, you can draw a complete solar system drawing your objects always centered in 0,0,0.

OGL let you push, pop and "reset" matrices, what this means ?

Let say you and your friend are two objects and the room in wich you will be rendered is the identity matrix (rot,pos,scale).

So the routine to render YOU the right way will be :

LoadIdentity. (start from the entrance door)

Walk to the center. (translate)

Look at the left wall. (rotate)

Render yourself.

now the actual matrices has it's center 0,0,0 in you chest and it is rotated with a Z facing the left wall, so if you render your freind in 0,0,0, with a rotation of 0,0,0 it will be "rendered" exactly where you are.

the solution could be :

LoadIdentity. (start from the entrance door)

Walk to the center. (translate)

Look at the left wall. (rotate)

Render yourself (glBegin(GL_PEOPLE))

//finished rendering you

LoadIdentity. (restore the matrix to the entrance door)

Look at the right wall (rotation)

Walk. (translation)

Render friend (glBegin(GL_PEOPLE))

now we rendered you in the center looking at the left wall, and your freind near the right wall.

this could also be done saving the matrices at the beginning, rendering you, and then restoring it before rendering your freind, this way.

LoadIdentity (matrix is the entrance door)

PushMatrix (save this situation)

Translate (walk to the center of room)

Rotate (look at the left wall)

Render

PopMatrix (restore the original matrix)

//here we start again from the door

Rotate (your friend)

Translate (walk to the wall)

Render

hope this helps...

It's quite messy I know, but I had some spare time to write a mini weird tutorial on matrices stack :P

sorry to whom already known how matrices works...

rIO.sK http://www.spinningkids.org/rio

Let's try to explain shorty (ollowing OGL Matrice for Dummies) :D

First of all, you must know when I'm talking about matrices I mean rotations,translations and scales mainly.

A matrix can be seen as "a situation".

Keep in mind that you never modify objects in OGL, but you modify coordinate systems, you can draw a complete solar system drawing your objects always centered in 0,0,0.

OGL let you push, pop and "reset" matrices, what this means ?

Let say you and your friend are two objects and the room in wich you will be rendered is the identity matrix (rot,pos,scale).

So the routine to render YOU the right way will be :

LoadIdentity. (start from the entrance door)

Walk to the center. (translate)

Look at the left wall. (rotate)

Render yourself.

now the actual matrices has it's center 0,0,0 in you chest and it is rotated with a Z facing the left wall, so if you render your freind in 0,0,0, with a rotation of 0,0,0 it will be "rendered" exactly where you are.

the solution could be :

LoadIdentity. (start from the entrance door)

Walk to the center. (translate)

Look at the left wall. (rotate)

Render yourself (glBegin(GL_PEOPLE))

//finished rendering you

LoadIdentity. (restore the matrix to the entrance door)

Look at the right wall (rotation)

Walk. (translation)

Render friend (glBegin(GL_PEOPLE))

now we rendered you in the center looking at the left wall, and your freind near the right wall.

this could also be done saving the matrices at the beginning, rendering you, and then restoring it before rendering your freind, this way.

LoadIdentity (matrix is the entrance door)

PushMatrix (save this situation)

Translate (walk to the center of room)

Rotate (look at the left wall)

Render

PopMatrix (restore the original matrix)

//here we start again from the door

Rotate (your friend)

Translate (walk to the wall)

Render

hope this helps...

It's quite messy I know, but I had some spare time to write a mini weird tutorial on matrices stack :P

sorry to whom already known how matrices works...

rIO.sK http://www.spinningkids.org/rio

Furrage

03-27-2002, 10:16 AM

Not bad Rio. Maybe more people will understand transforms now.

Then again, birds fly, worms crawl and ghosts float, so walking might be a totally foreign concept to them http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Furrage (edited 03-27-2002).]

Then again, birds fly, worms crawl and ghosts float, so walking might be a totally foreign concept to them http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Furrage (edited 03-27-2002).]

nexusone

03-27-2002, 11:21 AM

He saved me a lot of typing....

http://www.opengl.org/discussion_boards/ubb/smile.gif

Originally posted by Furrage:

Not bad Rio. Maybe more people will understand transforms now.

Then again, birds fly, worms crawl and ghosts float, so walking might be a totally foreign concept to them http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Furrage (edited 03-27-2002).]

http://www.opengl.org/discussion_boards/ubb/smile.gif

Originally posted by Furrage:

Not bad Rio. Maybe more people will understand transforms now.

Then again, birds fly, worms crawl and ghosts float, so walking might be a totally foreign concept to them http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by Furrage (edited 03-27-2002).]

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.