Jump to content
  • Advertisement
Sign in to follow this  
MrBeaner

OpenGL I think i undersand glLookAt(...)

This topic is 5025 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

OK... i've just started learning OpenGL, and i am kicking myself for not learning it sooner, because it is fairly easy to understand and simple to implement. What i have got going is a car class that updates its position, and a map that gets drawn before everything. My question is this: using glLookAt(...), if i change the position of the "camera" so it is locked on the car (or player) do i need to translate the map so it is centered on the screen, or does glLookAt(...) do this for me? In otherwords, is it neccessary to translate the map at all? do i need to move the map into world space, or can i start with it in world space to begin with? i think just moving the camera around would suffice for determining what to draw (besides culling and clipping). am i thinking correctly?

Share this post


Link to post
Share on other sites
Advertisement
just keep your map static, + use something like
gluLookAt( car_pos.x +10, car_pos.y+10, car_pos.z+10, car_pos.x,car_pos.y,car_pos.z, 0,1,0 );

Share this post


Link to post
Share on other sites
I was having a rough time with my camera system until I found glLookAt, too ;)

Think of it as a set of parameters telling your game where the camera is, physically, in your 3D world, and where it's looking at. Just picture a physical camera floating around your map and filming stuff, that's roughly how it goes.

It's marvelously easy to use ;)

Share this post


Link to post
Share on other sites
so it seems like i have then the basic understanding down.

the map has world coords, and only the car translates.

good stuff!

i'll tell you al something... if you are thinking about using a decent API and you are new to 3d API's, try OpenGL. its easier to understand and use (i think) then DirectX. Not to say that DX is useless, (quite the opposite i think), but that OpenGL can have you drawing things in no time.

Thanks to all who responded!

Share this post


Link to post
Share on other sites
shouldn't the gluLookAt() call come before anything else gets drawn? Doesn't it set some sort of matrix that OGL uses then to calculate everything else?

Share this post


Link to post
Share on other sites
Quote:
Original post by MrBeaner
shouldn't the gluLookAt() call come before anything else gets drawn? Doesn't it set some sort of matrix that OGL uses then to calculate everything else?


Yep you'll want to set up your camera transform before you apply your object transforms.

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!