Understanding Matrices in a 3d world

Started by
4 comments, last by kburkhart84 18 years, 11 months ago
http://www.devmaster.net/articles/viewing-systems/ I've been reading that and the Cameral Class tutorial on NEHE and I'm just trying to understand the theory here. Basically there is a kind of matrix in opengl that defines what opengl considers up down left right near far etc. The x, y, z. Transformations, rotations and even gluLookAt all modify the world with that original set of axis in mind. What a camera class is trying to do is load a completely new definition of the world, I imagine using glLoadMatrix or glMultMatrix. Is this the proper way of understanding how a camera will work ? Ive been using some clever calculus on gluLookAt, which transforms the world properly but leaves me with something of a "flashlight view" when what I want is a kind of "world lighting" so that I will on some occasions, see the dark side of some objects.
Advertisement
Quote:Original post by harnacks
Ive been using some clever calculus on gluLookAt, which transforms the world properly but leaves me with something of a "flashlight view" when what I want is a kind of "world lighting" so that I will on some occasions, see the dark side of some objects.


WTF? Can you be a little more descriptive? Matrices have little (nothing) to do with lighting in the conceptual sense. Please post some screenshots or some code. Other than that you can "occasionally" see the the darkside if you turn on the lights/disable lighting... "occasionally"....

As your leader, I encourage you from time to time, and always in a respectful manner, to question my logic. If you're unconvinced that a particular plan of action I've decided is the wisest, tell me so, but allow me to convince you and I promise you right here and now, no subject will ever be taboo. Except, of course, the subject that was just under discussion. The price you pay for bringing up either my Chinese or American heritage as a negative is - I collect your f***ing head.
As far as I know, a camera is an object that translates the SCENE so you can see the scene itself from adifferent point of view... said that, I can explain what my camera class does:
every frame, my engine updates modelview matrix, translating and rotating the scene according to camera position/rotation... obviusly, if camera moves left, the scene must be traslated on the right, and the same is for rotations: scene must be translated/rotated on the opposide side of camera position/rotation... I mean, placing the camera in (-1,0,0), moves the scene at (1,0,0)...
So, returning to your question, yes, a camera is an object that manipulates modelview matrix :P

About lights, it seems you are not updating light position after setting your camera... if you don't do that, you should see the scene like a miner with a light on the helmet :P
I don't know of a way to move the light though.

1) I'm not sure how the math works.

2) I dont konw how to actually set a position for the light once its been enabled in the initialization.

Any thoughts ?
1. Really really bad! :P
2. In the same way you initialize it... Oo
Quote:Original post by BladeWise
1. Really really bad! :P
2. In the same way you initialize it... Oo


Quoted for truth.

Matrices aren't all that easy to understand. I know where you are coming from. Basicly though, the light position get moved witht the rest of the world, or should anyway. So you need to set the light to its position after the camera/gluLookAt does its thing so that the light always gets to (x,y,z) in the world. If it is done before(in the init), it will always be there, and even if the camera moves, the light will be where it was. So if the light is at (0,0,1), as in right in front of the monitor shining to the world like your eyes, and you rotate the world, after putting the light, the light still stays where you put it, next to your eyes.


This topic is closed to new replies.

Advertisement