Jump to content
  • Advertisement

Archived

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

Cibressus

Can some one post a example of GluLookAt

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

Advertisement
Bob is hanging upside down from a branch, looking at Alice, lying on the grass with a book.

gluLookAt( Bob_x, Bob_y, Bob_z,
Alice_x, Alice_y, Alice_z,
UpsideDown_x, UpsideDown_y, UpsideDown_z );


Bob''s branch is at 20,80,15 (it''s a tall tree)
Alice is at 15,0,12 (near the foot of the tree)
Upside-down mean your ''up'' vector is 0,-1,0


gluLookAt( 20, 80, 15,
15, 0, 12,
0, -1, 0 );




“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites
[quote name='Kamal Reddy' timestamp='1300974440' post='4789937']
but what if alice is not a point but an object like finite size(not a zero size point)
[/quote]

Are you saying Alice needs to lose weight? Alice may be of 'finite size' (she says it's glandular), but gluLookAt still needs a precise direction in which to look. OpenGL doesn't support [i]sorta that way[/i] vectors.

If her position (ie: the translation part of her transform matrix) isn't reliable because she's deforming (that's glandular too), you can calculate an appropriate target vector by taking the centre of her bounding box, or the average of all her vertices, her centre of mass, centre of volume and so on.

That wouldn't have to be done precisely on every frame, though. You can get some nice camera movement with gluLookAt by treating the eye position, centre and up-vector as heavily damped particles (with position and velocity), [i]attracting[/i] the centre to target locations with damped springs, and repelling the camera itself from walls with a soft collision sphere or capsule. That way you don't have to be too fussy about calculating appropriate eye/centre/up-vectors all the time - the camera will still move smoothly on every frame even if you only [i]occasionally[/i] make careful decisions about where it's going.

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.

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!