Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Caesar

camera

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

hi, i''m a relatively new to OGL and my problem is Camera... In MSDN, the camre funcs are poorly commented (just descripted), so I''ve read some tuts. But there''s one point I''m still helpless with. when using gluLookAt(eyex,eyey,eyez,centerx,centery,centerz,...) then center... family params mean what? One tutorial (gametutorials.com) noted it as a vector, another (nehe) as the position of the point we look at. What''s the truth? I actually tried to just zoom (move closer and further to the object) and i didn''t work. If it''s a vector, should it be a normalized vector? And then, I have problems moving my camera around (just stays at the center of the scene (0,0,0). Could you help me?

Share this post


Link to post
Share on other sites
Advertisement
the 3rd set of coords in gluLookAt is the point at which you are looking. thus if you have 0,0,0 as the final set of coords, no matter where you move you will always be looking at the origin.

it makes more sense to me to store the view coords as a vector in my objects (makes rotation of view easier) so when i do gluLookAT i always enter the 3rd set of coords as view.x - pos.x, ....

but they are defintiely the COORDS you are looking at, not a vector representing your view direction.

-me

Share this post


Link to post
Share on other sites
Palidine: I think you have your order messed up. The third set of coordinates is the "up" location (normally 0,1,0). The first set is the location, and the second set is what you are looking at.

gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz)

Share this post


Link to post
Share on other sites
Ummm, okay, so i have two points, eyex, eyey, eyez, lookingtox, lookingtoy, lookingtoz. I''ve tried to make a overhead game and wanted to move the camera as the main character moves... I set the camera view like


  
glLookAt(hero_x,hero_y,10, //looking from a distance of 10 units

hero_x,hero_y,0, //looking at the hero (his Z coors always equal to 0, a 2d game

0,1,0); //just the up vector



now I would expect the camera to zoom out if I change the 10 in the first line (eyez) from 10 to ie. 20 and to zoom in when changing it to ie. 5. That doesn''t happen (. Even if I change the hero_x, hero_y coords (having a triangle drawn at 0,0,0 to see the center of my scene), it''s still in the center of the viewport... why? I, again, would expect it to "move" a little bit out of the center... I''ve prolly misunderstood some key thing. What''s that?

Share this post


Link to post
Share on other sites
Are you in ortho mode? (If so, the size of everything would not change no matter how far away it is).

Share this post


Link to post
Share on other sites
yes I''m because I don''t know how to change the viewport width and height (in units) in any other way than glOrtho, i tried some glFrustum, but I wasn''t succesfull.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You must use gluPerspective();

Look for it in MSDN, the params aren''t that hard (at least I dont think so). The first one is the angle of your view (1.0f is a very tiny slit you are looking through, I usually use from 45.0f to 60.0f) Thats the only param that is at all confusing.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!