PDA

View Full Version : To define the gluSphere() position.



Suvcon
01-25-2001, 10:49 AM
Ok,i can use gluSphere() draw a ball at (0.0f,0.0f,0.0f),and then translatef(.....),yes ,that work well.
but i turn on a light....if i still do in above way, i will get a wrong lighting.

I want a function to define the position to draw a gluQuadric object.

========
any idea?

Deiussum
01-26-2001, 05:12 AM
Lighting is affected by transformations, so where you put the lighting code will make a difference. Let's see if I remember this correctly. (It's been a rough week and my brain is fried.)

If you do things in this order...

set lighting
do transformations
draw object

It is as if the light is in a set position and you are moving the object around.

If you do it in this order...

do transformations
set lighting
draw object

It's more like you are moving a camera because the lighting will follow the movements of the object.

coco
01-26-2001, 05:34 AM
More detailed, the most common way to do it will be:
-setup the projection matrix
-setup de modelview matrix (with gluLookAt for example)
-setup lights
-for each object:
--push modelview matrix
--setup object matrix in the modelview matrix
--draw object
--pop modelview matrix
-endfor