GLCamera Class Reference

#include <GLCamera.h>

List of all members.

Public Types

enum  ScrollDir {
  eScrollLeft, eScrollRight, eScrollUp,
  eScrollDown
}
typedef float(* MinHeightFunc )(int, int, void *)
typedef float(* MaxHeightFunc )(int, int, void *)

Public Member Functions

 GLCamera (GLsizei windowWidth, GLsizei windowHeight)
virtual ~GLCamera ()
void setMinHeightFunc (MinHeightFunc func, void *heightData=0)
void setMaxHeightFunc (MaxHeightFunc func, void *heightData=0)
void setUseHeightFunc (bool toggle)
void setLookAt (Vector &lookAt, bool instant=false)
void setCurrentPos (Vector &pos)
void setOffSet (Vector &offSet, bool instant=false)
VectorgetOffSet ()
void setWindowSize (GLsizei windowWidth, GLsizei windowHeight)
void setWindowOffset (GLsizei windowLeft, GLsizei windowTop)
void draw ()
void simulate (float frameTime=0.02f)
void addShake (float shake)
void movePosition (float XY, float YZ, float Z)
void movePositionDelta (float XY, float YZ, float Z)
bool getDirectionFromPt (GLfloat ptX, GLfloat ptY, Line &direction)
VectorgetCurrentPos ()
VectorgetLookAt ()
VectorgetVelocity ()
float getRotationXY ()
float getRotationYZ ()
float getZoom ()
void scroll (ScrollDir direction, float minWidth, float minHeight, float maxWidth, float maxHeight, float amount)
void scroll (float x, float y, float minWidth, float minHeight, float maxWidth, float maxHeight)

Static Public Member Functions

static GLCameragetCurrentCamera ()

Protected Member Functions

virtual void calculateWantedOffset ()
virtual void moveViewport (Vector &lookFrom, Vector &lookAt)

Protected Attributes

GLsizei windowW_
GLsizei windowH_
GLsizei windowL_
GLsizei windowT_
GLfloat windowAspect_
GLfloat rotationXY_
GLfloat rotationYZ_
GLfloat zoom_
float shake_
float totalTime_
Vector shakeV_
bool useHeightFunc_
Vector lookAt_
Vector wantedLookAt_
Vector wantedOffset_
Vector currentPosition_
Vector velocity_
MinHeightFunc minHeightFunc_
MaxHeightFunc maxHeightFunc_
void * minHeightData_
void * maxHeightData_

Static Protected Attributes

static GLCameracurrentCamera_ = 0


Detailed Description

A class that wraps setting and moving the current viewport. It sets the projection matrix and the modelview matrix such that any OpenGL calls will be "looking" at the given position.

Definition at line 32 of file GLCamera.h.


Member Typedef Documentation

typedef float(* GLCamera::MinHeightFunc)(int, int, void *)

Definition at line 35 of file GLCamera.h.

typedef float(* GLCamera::MaxHeightFunc)(int, int, void *)

Definition at line 36 of file GLCamera.h.


Member Enumeration Documentation

enum GLCamera::ScrollDir

Scrolls the camera along the ground, in the direction given.

Enumerator:
eScrollLeft 
eScrollRight 
eScrollUp 
eScrollDown 

Definition at line 164 of file GLCamera.h.


Constructor & Destructor Documentation

GLCamera::GLCamera ( GLsizei  windowWidth,
GLsizei  windowHeight 
)

Create the camera. The camera has a width and height that it will use for its viewport.

Definition at line 30 of file GLCamera.cpp.

References calculateWantedOffset(), currentCamera_, currentPosition_, lookAt_, setWindowOffset(), setWindowSize(), and wantedOffset_.

GLCamera::~GLCamera (  )  [virtual]

Definition at line 43 of file GLCamera.cpp.


Member Function Documentation

void GLCamera::setMinHeightFunc ( MinHeightFunc  func,
void *  heightData = 0 
)

Sets a function that can be used to limit the cameras minimum height at a specified position. This can be used for example to prevent the camera from entering the landscape.

Definition at line 53 of file GLCamera.cpp.

References minHeightData_, minHeightFunc_, and useHeightFunc_.

Referenced by TargetCamera::TargetCamera().

void GLCamera::setMaxHeightFunc ( MaxHeightFunc  func,
void *  heightData = 0 
)

Definition at line 63 of file GLCamera.cpp.

References maxHeightData_, maxHeightFunc_, and useHeightFunc_.

Referenced by TargetCamera::TargetCamera().

void GLCamera::setUseHeightFunc ( bool  toggle  ) 

Turns the user of the height function on or off. See setHeightFunc.

Definition at line 48 of file GLCamera.cpp.

References useHeightFunc_.

Referenced by TargetCamera::keyboardCheck().

void GLCamera::setLookAt ( Vector lookAt,
bool  instant = false 
)

Sets the position that the camera will point at. The camera will gradualy move to look at this position unless the instant flag is given in which case the camera will move instantly.

Definition at line 73 of file GLCamera.cpp.

References lookAt_, and wantedLookAt_.

Referenced by GLWPlanView::mouseDown(), TargetCamera::mouseUp(), TargetCamera::moveCamera(), ClientStartGameHandler::processMessage(), TargetCamera::resetCam(), and MainCamera::useQuick().

void GLCamera::setCurrentPos ( Vector pos  ) 

Sets the position that the camera will look from.

Definition at line 82 of file GLCamera.cpp.

References currentPosition_.

void GLCamera::setOffSet ( Vector offSet,
bool  instant = false 
)

Sets the position that the camera will look from. This position is relative to the current look at position. The camera will gradualy move to look from this position unless the instant flag is given in which case the camera will move instantly.

Definition at line 87 of file GLCamera.cpp.

References currentPosition_, lookAt_, and wantedOffset_.

Referenced by TargetCamera::moveCamera().

Vector& GLCamera::getOffSet (  )  [inline]

Definition at line 78 of file GLCamera.h.

References wantedOffset_.

void GLCamera::setWindowSize ( GLsizei  windowWidth,
GLsizei  windowHeight 
)

Changes the current viewport size (w, h dimension) of the viewport. The viewport is the area of the window that is drawn to.

Definition at line 96 of file GLCamera.cpp.

References windowAspect_, windowH_, and windowW_.

Referenced by ClientMain::clientEventLoop(), createScorchedWindow(), CameraDialog::draw(), and GLCamera().

void GLCamera::setWindowOffset ( GLsizei  windowLeft,
GLsizei  windowTop 
)

Sets the current viewport location (x, y position) of the viewport. The viewport is the area of the window that is drawn to.

Definition at line 103 of file GLCamera.cpp.

References windowL_, and windowT_.

Referenced by CameraDialog::draw(), and GLCamera().

void GLCamera::draw (  ) 

Causes the current model and projection matrixs to be replaced so they are "looking" from the from position to the to position.

Definition at line 187 of file GLCamera.cpp.

References currentCamera_, currentPosition_, lookAt_, moveViewport(), and shakeV_.

Referenced by TankKeyboardControlUtil::autoAim(), TargetCamera::draw(), Landscape::drawShadows(), and TargetCamera::getLandIntersect().

void GLCamera::simulate ( float  frameTime = 0.02f  ) 

Causes the camera to move if gradual movements are being made.

Definition at line 148 of file GLCamera.cpp.

References currentPosition_, lookAt_, RAND, shake_, shakeV_, totalTime_, velocity_, wantedLookAt_, wantedOffset_, and Vector::zero().

Referenced by TargetCamera::simulate().

void GLCamera::addShake ( float  shake  ) 

Causes the camera to shake the viewport randomly. This can be used to simulate ground shake. e.g. during large explosions. The larger the shake the longer the camera will shake.

Definition at line 196 of file GLCamera.cpp.

References shake_.

Referenced by Explosion::init().

void GLCamera::movePosition ( float  XY,
float  YZ,
float  Z 
)

Moves the current look from position to a new location. The current look from position in overwritten. The look from position is relative to the look at position. XY = horizontal rotation for the new point from the old YZ = vertical rotation for the new point from the old Z = Zoom closeness

Definition at line 202 of file GLCamera.cpp.

References calculateWantedOffset(), rotationXY_, rotationYZ_, and zoom_.

Referenced by TargetCamera::moveCamera(), movePositionDelta(), ClientStartGameHandler::processMessage(), AnimatedBackdropDialog::simulate(), and MainCamera::useQuick().

void GLCamera::movePositionDelta ( float  XY,
float  YZ,
float  Z 
)

Moves the current look from position to a new location. This position is relative to the current look from position. The look from position is relative to the look at position. XY = horizontal rotation for the new point from the old YZ = vertical rotation for the new point from the old Z = Zoom closeness

Definition at line 211 of file GLCamera.cpp.

References movePosition(), rotationXY_, rotationYZ_, and zoom_.

Referenced by TargetCamera::keyboardCheck(), TargetCamera::mouseDrag(), TargetCamera::mouseWheel(), and MainCamera::simulate().

bool GLCamera::getDirectionFromPt ( GLfloat  ptX,
GLfloat  ptY,
Line direction 
)

Uses the current matrixs to turn a two 2D points into a 3D line.

Definition at line 225 of file GLCamera.cpp.

References GLViewPort::getActualHeight(), GLViewPort::getHeight(), GLViewPort::getHeightMult(), GLViewPort::getWidthMult(), GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX, GL_VIEWPORT, glGetDoublev(), glGetIntegerv(), Line::setEnd(), and Line::setStart().

Referenced by TargetCamera::getLandIntersect().

Vector& GLCamera::getCurrentPos (  )  [inline]

Get the point the camera is currently looking from

Definition at line 135 of file GLCamera.h.

References currentPosition_.

Referenced by VisibilityPatchGrid::calculateVisibility(), Lightning::draw(), GLWTankModel::draw(), GLLenseFlare::draw(), SkyDome::drawBackdrop(), GLWPlanView::drawCameraPointer(), GLWWindView::drawDisplay(), SkyDome::drawLayers(), Water2Renderer::drawWater(), Water2Renderer::drawWaterShaders(), TargetCamera::minHeightFunc(), ParticleEngine::normalizedSimulate(), Sun::setLightPosition(), LandscapeSoundPositionWater::setPosition(), LandscapeSoundPositionGroup::setPosition(), TargetCamera::simulate(), MainCamera::simulate(), ParticleRendererRain::simulateParticle(), and TargetRendererImpl::storeTarget2DPos().

Vector& GLCamera::getLookAt (  )  [inline]

Get the point the camera is currently looking at (observing)

Definition at line 139 of file GLCamera.h.

References lookAt_.

Referenced by GLWTankModel::draw(), GLLenseFlare::draw(), GLWPlanView::drawCameraPointer(), GLWWindView::drawDisplay(), TargetCamera::minHeightFunc(), MainCamera::setQuick(), MainCamera::simulate(), ParticleRendererRain::simulateParticle(), and TargetRendererImpl::storeTarget2DPos().

Vector& GLCamera::getVelocity (  )  [inline]

Get the speed of movement of the camera looking from position

Definition at line 143 of file GLCamera.h.

References velocity_.

Referenced by MainCamera::simulate().

float GLCamera::getRotationXY (  )  [inline]

Returns the current camera horizontal rotation. As set by the move position methods.

Definition at line 149 of file GLCamera.h.

References rotationXY_.

Referenced by MainCamera::setQuick(), and MainCamera::simulate().

float GLCamera::getRotationYZ (  )  [inline]

Returns the current camera vertical rotation. As set by the move position methods.

Definition at line 154 of file GLCamera.h.

References rotationYZ_.

Referenced by MainCamera::setQuick(), and MainCamera::simulate().

float GLCamera::getZoom (  )  [inline]

Returns the current camera zoom. As set by the move position methods.

Definition at line 159 of file GLCamera.h.

References zoom_.

Referenced by MainCamera::setQuick(), and MainCamera::simulate().

void GLCamera::scroll ( ScrollDir  direction,
float  minWidth,
float  minHeight,
float  maxWidth,
float  maxHeight,
float  amount 
)

Definition at line 281 of file GLCamera.cpp.

References eScrollDown, eScrollLeft, eScrollRight, and eScrollUp.

Referenced by MainCamera::keyboardCheck(), TargetCamera::mouseDrag(), and MainCamera::simulate().

void GLCamera::scroll ( float  x,
float  y,
float  minWidth,
float  minHeight,
float  maxWidth,
float  maxHeight 
)

Definition at line 305 of file GLCamera.cpp.

References currentPosition_, left, lookAt_, Vector::StoreNormalize(), wantedLookAt_, and zoom_.

static GLCamera* GLCamera::getCurrentCamera (  )  [inline, static]

Definition at line 176 of file GLCamera.h.

References currentCamera_.

Referenced by VisibilityPatchGrid::calculateVisibility(), Lightning::draw(), GLLenseFlare::draw(), SkyDome::drawBackdrop(), SkyDome::drawLayers(), Water2Renderer::drawWater(), Water2Renderer::drawWaterShaders(), Landscape::getShadowMap(), and TargetRendererImpl::storeTarget2DPos().

void GLCamera::calculateWantedOffset (  )  [protected, virtual]

Definition at line 109 of file GLCamera.cpp.

References rotationXY_, rotationYZ_, wantedOffset_, and zoom_.

Referenced by GLCamera(), and movePosition().

void GLCamera::moveViewport ( Vector lookFrom,
Vector lookAt 
) [protected, virtual]

Definition at line 116 of file GLCamera.cpp.

References GL_MODELVIEW, GL_PROJECTION, glLoadIdentity(), glMatrixMode(), glViewport(), MAX, maxHeightData_, maxHeightFunc_, MIN, minHeightData_, minHeightFunc_, Vector::StoreNormalize(), useHeightFunc_, windowAspect_, windowH_, windowL_, windowT_, and windowW_.

Referenced by draw().


Member Data Documentation

GLCamera * GLCamera::currentCamera_ = 0 [static, protected]

Definition at line 179 of file GLCamera.h.

Referenced by draw(), getCurrentCamera(), and GLCamera().

GLsizei GLCamera::windowW_ [protected]

Definition at line 180 of file GLCamera.h.

Referenced by moveViewport(), and setWindowSize().

GLsizei GLCamera::windowH_ [protected]

Definition at line 180 of file GLCamera.h.

Referenced by moveViewport(), and setWindowSize().

GLsizei GLCamera::windowL_ [protected]

Definition at line 181 of file GLCamera.h.

Referenced by moveViewport(), and setWindowOffset().

GLsizei GLCamera::windowT_ [protected]

Definition at line 181 of file GLCamera.h.

Referenced by moveViewport(), and setWindowOffset().

GLfloat GLCamera::windowAspect_ [protected]

Definition at line 182 of file GLCamera.h.

Referenced by moveViewport(), and setWindowSize().

GLfloat GLCamera::rotationXY_ [protected]

Definition at line 183 of file GLCamera.h.

Referenced by calculateWantedOffset(), getRotationXY(), movePosition(), and movePositionDelta().

GLfloat GLCamera::rotationYZ_ [protected]

Definition at line 183 of file GLCamera.h.

Referenced by calculateWantedOffset(), getRotationYZ(), movePosition(), and movePositionDelta().

GLfloat GLCamera::zoom_ [protected]

Definition at line 183 of file GLCamera.h.

Referenced by calculateWantedOffset(), getZoom(), movePosition(), movePositionDelta(), and scroll().

float GLCamera::shake_ [protected]

Definition at line 184 of file GLCamera.h.

Referenced by addShake(), and simulate().

float GLCamera::totalTime_ [protected]

Definition at line 185 of file GLCamera.h.

Referenced by simulate().

Vector GLCamera::shakeV_ [protected]

Definition at line 186 of file GLCamera.h.

Referenced by draw(), and simulate().

bool GLCamera::useHeightFunc_ [protected]

Definition at line 187 of file GLCamera.h.

Referenced by moveViewport(), setMaxHeightFunc(), setMinHeightFunc(), and setUseHeightFunc().

Vector GLCamera::lookAt_ [protected]

Definition at line 188 of file GLCamera.h.

Referenced by draw(), getLookAt(), GLCamera(), scroll(), setLookAt(), setOffSet(), and simulate().

Vector GLCamera::wantedLookAt_ [protected]

Definition at line 189 of file GLCamera.h.

Referenced by scroll(), setLookAt(), and simulate().

Vector GLCamera::wantedOffset_ [protected]

Definition at line 190 of file GLCamera.h.

Referenced by calculateWantedOffset(), getOffSet(), GLCamera(), setOffSet(), and simulate().

Vector GLCamera::currentPosition_ [protected]

Definition at line 191 of file GLCamera.h.

Referenced by draw(), getCurrentPos(), GLCamera(), scroll(), setCurrentPos(), setOffSet(), and simulate().

Vector GLCamera::velocity_ [protected]

Definition at line 192 of file GLCamera.h.

Referenced by getVelocity(), and simulate().

MinHeightFunc GLCamera::minHeightFunc_ [protected]

Definition at line 193 of file GLCamera.h.

Referenced by moveViewport(), and setMinHeightFunc().

MaxHeightFunc GLCamera::maxHeightFunc_ [protected]

Definition at line 194 of file GLCamera.h.

Referenced by moveViewport(), and setMaxHeightFunc().

void* GLCamera::minHeightData_ [protected]

Definition at line 195 of file GLCamera.h.

Referenced by moveViewport(), and setMinHeightFunc().

void* GLCamera::maxHeightData_ [protected]

Definition at line 196 of file GLCamera.h.

Referenced by moveViewport(), and setMaxHeightFunc().


The documentation for this class was generated from the following files:
Generated on Mon Feb 16 15:15:01 2009 for Scorched3D by  doxygen 1.5.3