Jump to content
  • Advertisement
Sign in to follow this  
Hand_Of_Destruction

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.

If you intended to correct an error in the post then please contact us.

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);
    glLoadIdentity();
    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;
    glLoadIdentity();
    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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!