CUGL  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
cugl::Camera Class Reference

#include <cugl.h>

Inheritance diagram for cugl::Camera:
Inheritance graph
[legend]
Collaboration diagram for cugl::Camera:
Collaboration graph
[legend]

Public Member Functions

 Camera ()
 
 Camera (const Point &eye, const Point &model, const Vector &up)
 
 Camera (const Point &eye, const Point &model)
 
 Camera (const Point &eye)
 
void set (const Point &eye, const Point &model, const Vector &up)
 
void set (const Point &eye, const Point &model)
 
void set (const Point &eye)
 
virtual void idle ()
 
void apply () const
 
void moveUp (GLfloat distance)
 
void moveForward (GLfloat distance)
 
void moveLeft (GLfloat distance)
 
void tiltUp (double angle)
 
void panLeft (double angle)
 
void setMode (bool mode)
 
- Public Member Functions inherited from cugl::BaseCamera
 BaseCamera ()
 
void setSteps (int s)
 
virtual void update ()
 

Protected Member Functions

void update (const Point &e, const Point &m)
 

Protected Attributes

Point eye
 
Point eyeOld
 
Point eyeNew
 
Point model
 
Point modelOld
 
Point modelNew
 
Vector up
 
bool smooth
 
- Protected Attributes inherited from cugl::BaseCamera
int steps
 
int maxSteps
 

Friends

std::ostream & operator<< (std::ostream &os, const Camera &c)
 

Detailed Description

An instance represents a camera. An instance of class Camera is used to control the view. The function Camera::apply() calls gluLookAt() with appropriate parameters. The other functions of this class set up these parameters.

Camera movements may be smooth (interlpolated between end points) or abrupt. The function Camera::setMode() determines the kind of movement. Smooth transitions are obtained by calling Camera::idle() in the GLUT idle callback function, together with the various camera movement functions.

Definition at line 1659 of file cugl.h.

Constructor & Destructor Documentation

cugl::Camera::Camera ( )

Construct a default camera. The view is set as follows: Eye = (0,0,1). Model=(0,0,0). Up=(0,1,0).

cugl::Camera::Camera ( const Point eye,
const Point model,
const Vector up 
)

Construct a camera for a particular view.

Parameters
eyesets the eye coordinates for gluLookAt().
modelsets the model coordinates for gluLookAt().
upsets the 'up' vector for gluLookAt().
cugl::Camera::Camera ( const Point eye,
const Point model 
)

Construct a camera for a particular view. The 'up' vector is set to (0,1,0).

Parameters
eyesets the eye coordinates for gluLookAt().
modelsets the model coordinates for gluLookAt().
cugl::Camera::Camera ( const Point eye)
explicit

Construct a camera for a particular view. The 'up' vector is set to (0,1,0). The model point is set to (0,0,0).

Parameters
eyesets the eye coordinates for gluLookAt().

Member Function Documentation

void cugl::Camera::apply ( ) const
virtual

Apply the camera position to the model-view matrix. This function calls gluLookAt() with appropriate parameters. It should be called in the GLUT display function or its equivalent after the model-view matrix has been initialized.

Implements cugl::BaseCamera.

virtual void cugl::Camera::idle ( )
virtual

Update the camera position. This function should be called from the GLUT idle() function or its equivalent. It performs one step of the motion until the motion is complete, after which it has no effect.

Implements cugl::BaseCamera.

void cugl::Camera::moveForward ( GLfloat  distance)

Move the camera forwards. The camera moves towards the model.

Parameters
distancegives the amount of movement. Negative values move the camera away from the model..
void cugl::Camera::moveLeft ( GLfloat  distance)

Move the camera to its left.

Parameters
distancegives the amount of movement. Negative values move the camera to its right.
void cugl::Camera::moveUp ( GLfloat  distance)

Move the camera upwards (+Y direction).

Parameters
distancegives the amount of movement. Negative values move the camera downwards.
void cugl::Camera::panLeft ( double  angle)

Pan the camera to the left.

Parameters
anglegives the angle through which the camera should be panned. Negative values give panning to the right.
void cugl::Camera::set ( const Point eye,
const Point model,
const Vector up 
)

Set the camera for a particular view.

Parameters
eyesets the eye coordinates for gluLookAt().
modelsets the model coordinates for gluLookAt().
upsets the 'up' vector for gluLookAt().
void cugl::Camera::set ( const Point eye,
const Point model 
)

Set the camera for a particular view. The 'up' vector is set to (0,1,0).

Parameters
eyesets the eye coordinates for gluLookAt().
modelsets the model coordinates for gluLookAt().
void cugl::Camera::set ( const Point eye)

Set the camera for a particular view. The model point is set to (0,0,0). The 'up' vector is set to (0,1,0).

Parameters
eyesets the eye coordinates for gluLookAt().
void cugl::Camera::setMode ( bool  mode)
inline

Set the kind of motion required.

Parameters
modeshould be set to true for smooth movements or to false for abrupt movements.

Definition at line 1779 of file cugl.h.

References smooth.

void cugl::Camera::tiltUp ( double  angle)

Tilt the camera upwards.

Parameters
anglegives the angle through which the camera should be moved. Negative values give a downward tilt.
void cugl::Camera::update ( const Point e,
const Point m 
)
protected

Update the camera position.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Camera c 
)
friend

Write a representation of the camera to a stream. This function displays the current settings of the eye point, the model point, and the up vector.

Parameters
osis a reference to an output stream.
cis a reference to a camera.

Member Data Documentation

Point cugl::Camera::eye
protected

Eye coordinates for gluLookAt().

Definition at line 1800 of file cugl.h.

Point cugl::Camera::eyeNew
protected

Updated eye coordinates.

Definition at line 1806 of file cugl.h.

Point cugl::Camera::eyeOld
protected

Previous eye coordinates.

Definition at line 1803 of file cugl.h.

Point cugl::Camera::model
protected

Model coordinates for gluLookAt()

Definition at line 1810 of file cugl.h.

Point cugl::Camera::modelNew
protected

Updated model coordinates

Definition at line 1816 of file cugl.h.

Point cugl::Camera::modelOld
protected

Previous model coordinates

Definition at line 1813 of file cugl.h.

bool cugl::Camera::smooth
protected

Mode for motion

Definition at line 1822 of file cugl.h.

Referenced by setMode().

Vector cugl::Camera::up
protected

Up vector for gluLookAt()

Definition at line 1819 of file cugl.h.


The documentation for this class was generated from the following file: