I think i undersand glLookAt(...)

Started by
7 comments, last by MrBeaner 19 years, 3 months ago
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?
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
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 );
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 ;)
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!
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
Its gluLookAt. . . .
And don't forget to ensure that your gluLookAt call comes before you draw the scene.
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?

------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
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.
thanks...

opengl rocks. Its like othello...
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.

This topic is closed to new replies.

Advertisement