Main Page   Namespace List   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ViewModel Class Reference

The ViewModel class implements a camera model, minus the perspective transformation. More...


Public Methods

void set_distance (float new_distance)
void set_up (vec3 new_up)
void set_up (float x, float y, float z)
void set_eye (vec3 new_eye)
void set_eye (float x, float y, float z)
void set_lookat (vec3 new_lookat)
void set_lookat (float x, float y, float z)
void roll (float angle)
void eye_yaw (float angle)
void eye_yaw_abs (float angle, vec3 axis)
void eye_pitch (float angle)
void lookat_yaw (float angle)
void lookat_pitch (float angle)
void reset_up (int axis_num)
void reset_up (void)
void move (float side_move, float up_move, float forw_move)
void move (vec3 v)
void move_by_eye (vec3 new_eye)
void move_by_lookat (vec3 new_lookat)
void move_abs (vec3 v)
void rot_about_eye (mat4 rot)
void rot_about_lookat (mat4 rot)
void make_mtx (void)
void load_to_openGL (void)
void load_to_openGL_noident (void)
void reset (void)
 ViewModel (void)
void update (void)
void dump (FILE *output)

Data Fields

vec3 eye
 eye point

vec3 lookat
 lookat point

vec3 up
 up vector

vec3 side
 side vector

vec3 forward
 forward vector

mat4 mtx
 modelview matrix

float distance
 distance between eye and lookat points


Detailed Description

The ViewModel class implements a camera model, minus the perspective transformation.

It maintains the coordinate system of the camera as three vectors (forward, up, and side), which are themselves derived from two points (eye and lookat).

Apart from simplifying camera translation, this class provides three rotation methods: yaw (rotation about the up axis), roll (about the forward axis), and pitch (about the side axis). Also, these rotations can take place about the eye (in which case the eye location is fixed but the lookat point changes - like rotating your head), or about the lookat point (in which case your eye rotates around the point of interest).

There is also a routine for rotating the eye about an arbitrary axis, which is quite useful in conjuction with the world up axis.

This class is heavily-dependent on the vec3 class in the file algebra3.h.

The function update() sets the side and forward vectors based on the lookat, eye, and up vectors. Remember to call this function if you change the side or forward directly.

Sample use: ViewModel vm; vm.eye.set( 0.0, 0.0, 20.0 ); vm.lookat.set( 0.0, 0.0, 0.0 ); vm.update(); // updates the three vectors

vm.move( 0.0, 2.0, 0.0 ); // Moves the eye and lookat by 2 units in the world Y direction vm.roll( 5.0 ); // rolls 5 degrees about the forward axis vm.lookat_yaw( -25.0 ); // Yaws about the eye (lookat is fixed) by -25 degrees vm.load_to_openGL(); // Sets OpenGL modelview matrix

.. render ...


Constructor & Destructor Documentation

ViewModel::ViewModel (  void    ) 
 

Constructor


Member Function Documentation

void ViewModel::dump (  FILE *    output ) 
 

Prints the contents of this class to a file, typically stdin or stderr

void ViewModel::eye_pitch (  float    angle ) 
 

Rotates the eye about the side vector Lookat is unaffected

void ViewModel::eye_yaw (  float    angle ) 
 

Rotates the eye about the lookat point, using the up vector Lookat is unaffected

void ViewModel::eye_yaw_abs (  float    angle,
vec3    axis
) 
 

Rotates the eye about the lookat point, with a specific axis Lookat is unaffected

void ViewModel::load_to_openGL (  void    ) 
 

Sets the OpenGL modelview matrix based on the current camera coordinates

void ViewModel::load_to_openGL_noident (  void    ) 
 

Multiplies the current camera matrix by the existing openGL modelview matrix. This is same as above function, but does not set the OpenGL matrix to identity first

void ViewModel::lookat_pitch (  float    angle ) 
 

Rotates the lookat point about the side vector This assumes the side vector is correct. Eye point is unaffected

void ViewModel::lookat_yaw (  float    angle ) 
 

This assumes the up vector is correct. Rotates the lookat about the side vector Eye point is unaffected

void ViewModel::make_mtx (  void    ) 
 

Constructs a 4x4 matrix - used by load_to_openGL()

void ViewModel::move (  vec3    v ) 
 

Moves a specified distance in the forward, side, and up directions.

void ViewModel::move (  float    side_move,
float    up_move,
float    forw_move
) 
 

Moves a specified distance in the forward, side, and up directions. This function does NOT move by world coordinates. To move by world coords, use the move_abs function.

void ViewModel::move_abs (  vec3    v ) 
 

Move the eye and lookat in world coordinates

void ViewModel::move_by_eye (  vec3    new_eye ) 
 

Sets the eye point, AND moves the lookat point by the same amount as the eye is moved.

void ViewModel::move_by_lookat (  vec3    new_lookat ) 
 

Sets the lookat point, AND moves the eye point by the same amount as the lookat is moved.

void ViewModel::reset (  void    ) 
 

Resets the parameters of this class

void ViewModel::reset_up (  void    ) 
 

Resets up vector to the Y axis

void ViewModel::reset_up (  int    axis_num ) 
 

Resets the up vector to a specified axis (0=X, 1=Y, 2=Z) Also sets the eye point level with the lookat point, along the specified axis

void ViewModel::roll (  float    angle ) 
 

Rotates about the forward vector eye and lookat remain unchanged

void ViewModel::rot_about_eye (  mat4    rot ) 
 

Rotates the lookat point about the eye, based on a 4x4 (pure) rotation matrix

void ViewModel::rot_about_lookat (  mat4    rot ) 
 

Rotates the lookat point about the lookat, based on a 4x4 (pure) rotation matrix

void ViewModel::set_distance (  float    new_distance ) 
 

This readjusts the distance from the eye to the lookat (changing the eye point in the process). The lookat point is unaffected.

void ViewModel::set_eye (  float    x,
float    y,
float    z
) 
 

Sets the current eye point

void ViewModel::set_eye (  vec3    new_eye ) 
 

Sets the current eye point

void ViewModel::set_lookat (  float    x,
float    y,
float    z
) 
 

Sets the current lookat point

void ViewModel::set_lookat (  vec3    new_lookat ) 
 

Sets the current lookat point

void ViewModel::set_up (  float    x,
float    y,
float    z
) 
 

Sets the current up vector

void ViewModel::set_up (  vec3    new_up ) 
 

Sets the current up vector

void ViewModel::update (  void    ) 
 

updates the view params. Call this after making direct changes to the vectors or points of this class


Field Documentation

float ViewModel::distance
 

distance between eye and lookat points

vec3 ViewModel::eye
 

eye point

vec3 ViewModel::forward
 

forward vector

vec3 ViewModel::lookat
 

lookat point

mat4 ViewModel::mtx
 

modelview matrix

vec3 ViewModel::side
 

side vector

vec3 ViewModel::up
 

up vector


The documentation for this class was generated from the following file:
Generated on Wed Feb 18 16:32:56 2004 for POVAMA by doxygen1.2.18