OpenGL 4.3 setting camera LookAt

bboo used Ask the Experts™
I have a scene with a camera that I want to look down on a floor that has objects on it. I'm having trouble setting the position of the camera so that I can see the floor from above.

I have:

camera->setPosition(vec3(20.0f, 1.5f, 0.0f));

I would like to be able to zoom out more.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
In most graphics systems Y is up. I assume that your objects are at, or near the origin. So to move your camera further above the object you would do something like this:
camera->setPosition(vec3(0.0f, 10.f, 0.0f));

Open in new window

That places it 10 units above the origin. To see more of the floor you would move it further up (always assuming its a perspective camera). The other aspect is that it has to be looking downwards. An OpenGL camera looks down its z-axis, so you have to rotate it to point its z-axis down.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial