🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3D Game Engine Camera Movement

Started by
0 comments, last by Slayer-X 24 years, 7 months ago
I have no idea how to do this. I just need to know how to move the viewport around the 3D world. I have 2 different ideas of what this is by reading what some people have posted. It is either keeping all of the 3D world's objects' coordinates the same and moving the coordinates of the player's view around, or it is translating every single object in the viewable world. I think it's the first because the second would seem to take up a lot of processing time.
Advertisement
I think you meant the 3D world, and not the viewport. Viewport is a two dimensional rectangle of your 3 dimensional world. Everything not in your viewport gets clipped. Basically, you have 3 matrices to work with in Opengl or DirectX. You have the world, view, and projection matrices. You start up by drawing your objects in model space which is x=y=z=0, and you make a world matrix with rotation, translation, and scale that tell you how far your object moves from the world coordinates that are x=y=z=0. For example if you want to move your model along the positive x-axis, use a translation function and put some value for the x coordinate, this will multiply your vertices by the translation matrix and move your model from the world's coords x=y=z=0 to y=z=0 and x=some value. So in DirectX you first build the world matrix, then the view, and you normally don't manipulate the projection matrix once it's set up. Your vertices will be multiplied by world, view, and projection matrices. Do as I do and use gluLookAt() or D3DXMatrixLookAtLH(), matrices, they'll take care of your view matrix. Then only manipulate world matrix to place your objects and if you want to move around your world use the LookAt functions to manipulate your camera or view matrix. You don't move around in your world, but your objects do. You manipulate the view matrix to move your objects further out or in from the current world position and this gives the illusion that you are moving around in your world. By the way, in DirectX once you build your world, view, and projection matrices don't forget to set them since the api is a state machine. In opengl you have model and view matrix in one, and projection separate, in DirectX all 3 are separate. Hope this helps and good luck!

[This message has been edited by JD (edited November 16, 1999).]

This topic is closed to new replies.

Advertisement