#include <GLCamera.h>
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) |
| Vector & | getOffSet () |
| 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) |
| Vector & | getCurrentPos () |
| Vector & | getLookAt () |
| Vector & | getVelocity () |
| 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 GLCamera * | getCurrentCamera () |
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 GLCamera * | currentCamera_ = 0 |
Definition at line 32 of file GLCamera.h.
| 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.
| enum GLCamera::ScrollDir |
Scrolls the camera along the ground, in the direction given.
Definition at line 164 of file GLCamera.h.
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.
| 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] |
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().
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().
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().
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().
GLCamera * GLCamera::currentCamera_ = 0 [static, protected] |
Definition at line 179 of file GLCamera.h.
Referenced by draw(), getCurrentCamera(), and GLCamera().
GLsizei GLCamera::windowW_ [protected] |
GLsizei GLCamera::windowH_ [protected] |
GLsizei GLCamera::windowL_ [protected] |
GLsizei GLCamera::windowT_ [protected] |
GLfloat GLCamera::windowAspect_ [protected] |
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] |
float GLCamera::totalTime_ [protected] |
Vector GLCamera::shakeV_ [protected] |
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] |
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] |
MinHeightFunc GLCamera::minHeightFunc_ [protected] |
MaxHeightFunc GLCamera::maxHeightFunc_ [protected] |
void* GLCamera::minHeightData_ [protected] |
void* GLCamera::maxHeightData_ [protected] |
1.5.3