PDA

View Full Version : Lighting rotating with object? Eh?



03-25-2006, 07:56 PM
Hi,

I'm writing a 3D Asteroids sort of game, and wouldn't it be cool if my asteroid models were shaded? Unfortunately, whenever I try this, the lighting and shading for the object seems to rotate along with it(as if the lighting was some sort of texture). I've downloaded a tutorial from NeHe, and THAT program had the same problem. Can anyone give me a few pointers? Thanks.

-Aramil

RigidBody
03-26-2006, 02:52 AM
use glLightPos before you rotate the model.

Tin Whisker
03-26-2006, 03:00 AM
I'm writing a 3D Asteroids sort of game, and wouldn't it be cool if my asteroid models were shaded?It most certainly would. And I love a good game of asteroids.

Perhaps your problem has to do with your light being in the wrong coordinate space? As I recal, OpenGL transforms the supplied light position with the current model-view matrix.

There's a chapter on lighting in the on-line programming guide that describes this in good detail:
http://www.rush3d.com/reference/opengl-redbook-1.1/chapter06.html

03-26-2006, 10:19 AM
Thanks a lot for the help, I appreciate it.

PS.(It's working now, lol)