It’s impossible for people to move around physically in a "virtual 3D world", we therefore use a "camera" to get
orientated. When setting up a basic camera in OpenGL there are two main subjects to be taken into consideration,
the camera handling and the perspective.
To handle the camera in OpenGL we use the gluLookAt function:
gluLookAt ( pos.x, pos.y, pos.z, view.x, view.y, view.z, up.x, up.y, up.z );
An OpenGL camera consists of three vectors: position, view and up. The "position", is the actual point
where the camera is located, while the "view" is the target point that the camera is looking at.
If you're standing in a room looking at a picture on the wall, then your eyes are the position
and the picture is the view.
You can say that the position point and the target point form a view-vector.
The "up" or "tilt" decides if the camera is tilting (used in flight simulators).
The "target camera" in 3D Studio Max is a good visualization of an OpenGL Camera.
To handle the perspective in OpenGL we use the gluPerspective function:
gluPerspective ( fovy, aspect, zNear, zFar );
You can set up your "camera lens" in OpenGL by altering the perspective values.
The perspective of an OpenGL camera consists of four elements: fovy, aspect, near
and far. "Fovy" specifies the field of view angle, in degrees, in the y-direction.
"Aspect" specifies the aspect ratio that determines the field of view in the x-direction.
The aspect ratio is the ratio of x (width) to y (height).
"Near" specifies the distance from the viewer to the nearest clipping plane (always positive).
"Far" specifies the disistance from the viewer to the far clipping plane (always positive).
Since there are many uses for 3D cameras, it’s necessary for you to decide which type is best
suited for your purpose. First you must set up the kind of perspective you want, and then you must
decide if the camera is going to stand still or be moved around.
Camera code and articles can be found all over the Internet, try to put together a camera that suites
your need, you can also download some from Apron Tutorials to get some ideas.
Ronny André Reierstad