Public Group

# birds eye view in OPENGL

This topic is 3795 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

how can i look at a 3D object from exactly the top of its center?? (with angle of 90) i think i should use gluLookAt() function to do this,but i don't know which values to use :( thx

:(

##### Share on other sites
I'm not real familiar with OpenGL but I might be able to help you with the general idea of how to do it. Are you talking about an overheard camera above the player? (similar to the old GTA's)

##### Share on other sites
yes,

for example there is a car which is in motion.After its journey,i will show this motion graphically by using its x,y,z coordinates.

and after this,i should show this motion in birds eye view.(that's the part that i couldn't do) -> to do this,i think i should use only the x,y coordinates and change position of the camera

--> and i think i should use gluLookAt. but i don't understand this function.To put the camera above the car(perpendicular to the car), which values i should use?

can you write the function with values?

i hope my English is good enough for you to understand :D

##### Share on other sites
Yes, you'll need to change the position of the camera using the X and Y values to place the camera above the vehicle. Then you'll aim the camera to look straight down. Doing a quick Google search I think the code might be similar to:

gluLookAt(vehicleX, vehicleY + 20, vehicleZ, vehicleX, vehicleY, vehicleZ, 0.0, 1.0, 0.0);

I think that would put the camera at the vehicle's position and above it 20. Then, it would be looking at the position of the vehicle (althought vehicleZ might be 0). Finally, the last 3 are the up vector which is typically always (0, 1, 0).

Again, I've never really used OpenGL and the way the next sounds, GL doesn't really have a 'camera' since the scene is moved relative to a static position for viewing.

##### Share on other sites
Quote:
 Original post by programmermattcgluLookAt(vehicleX, vehicleY + 20, vehicleZ, vehicleX, vehicleY, vehicleZ, 0.0, 1.0, 0.0);

Almost, but not entirely right. The only restriction on the up vector is that it cannot be parallel to the viewing direction, since it cannot specify an up direction that way. If you are viewing the scene top-down, the up vector is pointing forward (in world space). So correctly the gluLookAt call would look like this:
gluLookAt(vehicleX, vehicleY + 20, vehicleZ, vehicleX, vehicleY, vehicleZ, 0.0, 0.0, -1.0);

Last parameter could be +1.0, don't remember exactly if positive or negative z is into the scene in OpenGL.

##### Share on other sites

gluLookAt(vehicleX, vehicleY + 20, vehicleZ, vehicleX, vehicleY, vehicleZ, 0.0, 0.0, 1.0); ---> this is what i need :)

thank you very much :):)

##### Share on other sites
how can i zoom to this view?? vertexes look very small

##### Share on other sites
You can zoom in by putting your camera closer to the object you're viewing. The distance right now is 20 units: vehicle is at vehicle.x, vehicle.y, vehicle.z; camera is at vehicle.x, vehicle.y + 20, vehicle.z. You can probably see that the constant you add to the y coordinate is the camera distance in this case. Try changing it to a lower value. Later you should probably make it a variable so you can experiment with it more easily and perhaps change it in runtime.

##### Share on other sites
Another thing you can do to zoom in is to change the field of view by calling

gluPerspective(field of view, aspect ratio, near plane distance, far plane distance) ;

The larger the field of view, the more zoomed it will appear (I use 20 for non-zoom and 50 for zoom in my game). The nice part about this method is that you don't need to reposition the camera (i.e. its position can remain constant relative to the car). It is akin to a real cameraman zooming in on something. They don't usually run up to the object, they just zoom in.

1. 1
Rutin
69
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011828
• ### Who's Online (See full list)

There are no registered users currently online

×