# OpenGL Easy camera? (opengl)

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

## Recommended Posts

Whats the best way to make camera, which can be placed/moved almost freely? I used this functions from Lighthouse's tutorial:
void orientMe(float ang)
{
lx = sin(ang);
lz = -cos(ang);
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
}

void moveMeFlat(int direction)
{
x = x + direction*(lx)*0.1;
z = z + direction*(lz)*0.1;
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
}


They do fine, but I don't know how to use them to set an TPP-like camera. I think it has something with 3 last parameters of gluLookAt, the tilt ones, but I don't know how to modify it. Also I would like the cam to focus on one point (the main character). thank you EDIT: Could someone move it to the OpenGL forum? [Edited by - Hand_Of_Destruction on April 1, 2006 10:10:37 AM]

##### Share on other sites
I think the easiet way to make a good simple camera(as long as gimble lock won't get in your way) is to use gluLookAt and in the camera class, have a couple of vectors representing UP, RIGHT, and FORWARD. When you need to rotate, you rotate these vectors upon each other. For example, to rotate pitch, you rotate the UP and FORWARD vectors according to the RIGHT vector. Then use these vectors to create the parameters for the gluLookAt function. The only issue is that the forward vector won't go, rather the position+FORWARD because gluLookAt takes the position you are in, the position you are looking at(not forward vector, rather an acual 3d position) and the UP vector. The only reason to have the RIGHT vector is fro strafing and having the vector to pitch around.

##### Share on other sites
You might also look here:
http://www.codecolony.de/opengl.htm

He has two camera examples. One simple and one advanced. I don't know how they compare to the glLookAt() function stuff, but I just finished my camera class, which follows the first example.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632997
• Total Posts
3009794
• ### Who's Online (See full list)

There are no registered users currently online

×