opengl camera

Started by
1 comment, last by CrazyCdn 16 years, 10 months ago
hi! i have a 3d environment written in opengl and c++. The camera at the moment can only move forwards backwards left right up and down but it cant pivot to the left and go that way etc so its only fixed looking and moving in one direction. I was given the code sqrtf(x * x + y * y + z * z); a while ago to find the length of a vector but im not sure what to do with it and how to apply it to the camera :( any suggestions or pointers in the right direction would be greatly appreciated!
Advertisement
You should use gluLookAt.

gluLookAt(cam.x, cam.y, cam.z, lookat.x, lookat.y, lookat.z, up.x, up.y, up.z);


With some basic math using sine and cosine you'll be able to create a camera that can move and rotate around the Y axis.
while (tired) DrinkCoffee();
Or you could loop on these forums for the dozens or more OpenGL Camera discussions that have taken place and look at their code examples on how to do it properly.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement