Jump to content
  • Advertisement
Sign in to follow this  
harnacks

OpenGL Understanding Matrices in a 3d world

This topic is 4852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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"....

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!