Jump to content
  • Advertisement
Sign in to follow this  
AMDFX

Correct use of GluLookAt?

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

Hey :)

I have a little (maybe big) problem with the glualookat command. I know the declaration (Camera Pos x, y, z - Targetpoint x,y, z - vector x, y, z)

I try to move the camera with the keyboard and mouse but its not working right. Its easy to move the camera with the keyboard but not so easy to change the looking direction correctlly with the mouse! The next problem is, if I move the mouse a little bit to right (maybe 45°) and now I press arrow key up to walk, the camera ignor the 45°C and still go at the Y right...
(yea I know my english is really bad but I hope to understand the problem)!

Short: How to use the camera right? Keyboard = move camera | Mouse = Move Targetpoint

To get keyboard infos I use: glutSpecialFunc | For mouse: GlutPassivMotionFunc

I hope you can help me...

Share this post


Link to post
Share on other sites
Advertisement

I have a little (maybe big) problem with the glualookat command. I know the declaration (Camera Pos x, y, z - Targetpoint x,y, z - vector x, y, z)


But that is not the declaration for gluLookat. This is the declaration:
http://msdn.microsoft.com/en-us/library/dd368663(v=vs.85).aspx

-Maybe now you can get a better feel of where to put your values.
Good luck, man!

Share this post


Link to post
Share on other sites
If you turn 45°, then you need to update your forward vector.
The forward vector is defined as
forward_vector = normalize(Targetpoint - CameraPos);

so if you want to move forward, you can increase by some UNIT
CameraPos = CameraPos + UNIT * forward_vector;

and you also update the target point
Targetpoint = Targetpoint + UNIT * forward_vector;

SuperVGA, his declaration is fine. For the last parameter, it is called the UpVector.

Share this post


Link to post
Share on other sites
Hm okay but the link says me: Page not found :blink:

And what does in this case normalize and UNIT? Sorry guys for nooby questions but this topic confusing me a little bit...

Share this post


Link to post
Share on other sites
V-Man, those are his arguments, not the function declaration and its parameters.
The usage of the function on the other hand, is alright, obviously. It's just important to tell things apart.

Share this post


Link to post
Share on other sites
I'm trying again, the aspx didn't make it into the hyperlink: "http://msdn.microsoft.com/en-us/library/dd368663(v=vs.85).aspx"
Darn... ok just copy the url and go there.

Normalizing is dividing every component in a vector with the length of the vector. By unit, v-man probably meant step length. The unit would be the arbitary opengl unit.

Share this post


Link to post
Share on other sites
Yes UNIT would be some value of your choice like -0.01 or 0.01 or 1.0. Whatever you find appropriate.
Normalize is explained all over the web. Why not start by doing a search?
It is explained in all Linear Algebra textbooks.
You might want to study about vector and matrices if 3D graphics interest you.
There seems to be too many people who just copy and paste code and don't understand what programming is.

Share this post


Link to post
Share on other sites
Agreed, you should google the terms in question. Even gluLookat is easy to find stuff on, but normal trignometry should be easy for you.

Share this post


Link to post
Share on other sites
"There seems to be too many people who just copy and paste code and don't understand what programming is."

Thats the reason why I ask here to understand it :) Copy / Paste is no solution^^

So i know now what is this normalize and I know something about vector and matrices.. the problem is: My english is not the best! So sorry if I dont understand all at the first time :)


But you help me a lot! So thx I will do my best... maybe I post later if it work ^^

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!