Colobot
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Gfx::CCamera Class Reference

Camera moving in 3D scene. More...

#include <camera.h>

Public Member Functions

bool EventProcess (const Event &event)
 Management of an event. More...
 
void Init (Math::Vector eye, Math::Vector lookat, float delay)
 Initializes the camera. More...
 
void SetControllingObject (CObject *object)
 Sets the object controlling the camera. More...
 
CObjectGetControllingObject ()
 Gets the object controlling the camera. More...
 
void SetType (CameraType type)
 Change the type of camera. More...
 
CameraType GetType ()
 Get the type of the camera. More...
 
void SetSmooth (CameraSmooth type)
 Set smoothing mode. More...
 
CameraSmooth GetSmooth ()
 Get smoothing mode. More...
 
void GetCamera (Math::Vector &eye, Math::Vector &lookat)
 Returns the current point of view of the camera. More...
 
void SetFreeze (bool freeze)
 Temporarily freeze camera movement. More...
 
void SetCameraSpeed (float speed)
 Set camera speed. More...
 
Visit camera management (CAM_TYPE_VISIT) - camera in this mode shows a position, constantly rotating around it
void StartVisit (Math::Vector goal, float dist)
 Start visit camera. More...
 
void StopVisit ()
 Stop visit camera. More...
 
Camera "centering" - moves the camera to show some happening action (e.g. sniffer sniffing)
bool StartCentering (CObject *object, float angleH, float angleV, float dist, float time)
 Move camera to show happening action. More...
 
bool StopCentering (CObject *object, float time)
 Go back to normal position after showing some happening action. More...
 
void AbortCentering ()
 Abort centering animation in the current position. More...
 
Camera shake effects
void StartEffect (CameraEffect effect, Math::Vector pos, float force)
 Starts a camera shake effect. More...
 
void FlushEffect ()
 Removes the camera shake effect. More...
 
Camera overlay effects
void StartOver (CameraOverEffect effect, Math::Vector pos, float force)
 Starts camera overlay effect. More...
 
void FlushOver ()
 Removes camera overlay effect. More...
 
void SetOverBaseColor (Color color)
 Specifies camera overlay effect base color. More...
 
Script camera - cutscenes controlled by external code
void SetScriptCamera (Math::Vector eye, Math::Vector lookat)
 Script camera: Set camera position. More...
 
void SetScriptCameraAnimate (Math::Vector eye, Math::Vector lookat)
 Script camera: Animate to given camera position. More...
 
void SetScriptCameraAnimateEye (Math::Vector eye)
 Script camera: Animate to given eye position. More...
 
void SetScriptCameraAnimateLookat (Math::Vector lookat)
 Script camera: Animate to given lookat position. More...
 

Protected Member Functions

void EffectFrame (const Event &event)
 Advances the effect of the camera. More...
 
void OverFrame (const Event &event)
 Advanced overlay effect in the foreground. More...
 
bool EventFrameFree (const Event &event, bool keysAllowed)
 
bool EventFrameBack (const Event &event)
 
bool EventFrameFix (const Event &event)
 
bool EventFrameExplo (const Event &event)
 
bool EventFrameOnBoard (const Event &event)
 
bool EventFrameVisit (const Event &event)
 
bool EventFrameScript (const Event &event)
 
void UpdateCameraAnimation (const Math::Vector &eyePt, const Math::Vector &lookatPt, float rTime)
 Calculates camera animation and sends updated camera position to the 3D engine. More...
 
void IsCollision (Math::Vector &eye, Math::Vector lookat)
 Avoid the obstacles. More...
 
void IsCollisionBack ()
 Avoid the obstacles (CAM_TYPE_BACK) More...
 
void IsCollisionFix (Math::Vector &eye, Math::Vector lookat)
 Avoid the obstacles (CAM_TYPE_FIX or CAM_TYPE_PLANE) More...
 
Math::Vector ExcludeTerrain (Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV)
 Adjusts the camera not to enter the ground. More...
 
Math::Vector ExcludeObject (Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV)
 Adjusts the camera not to enter an object. More...
 
void SetViewParams (const Math::Vector &eye, const Math::Vector &lookat, const Math::Vector &up=Math::Vector(0.0f, 1.0f, 0.0f))
 Updates the location and direction of the camera in the 3D engine. More...
 
Math::Vector CalculateCameraMovement (const Event &event, bool keysAllowed=true)
 Calculate camera movement (from user inputs) to apply. More...
 

Protected Attributes

CEnginem_engine
 
CRobotMainm_main
 
CTerrainm_terrain
 
CWaterm_water
 
CInputm_input
 
CameraType m_type
 The type of camera. More...
 
CameraSmooth m_smooth
 Type of smoothing. More...
 
CObjectm_cameraObj
 Object linked to the camera. More...
 
float m_initDelay
 Remaining time of initial camera entry animation. More...
 
Math::Vector m_actualEye
 Current eye. More...
 
Math::Vector m_actualLookat
 Current aim. More...
 
Math::Vector m_finalEye
 Final eye. More...
 
Math::Vector m_finalLookat
 Final lookat. More...
 
Math::Vector m_prevEye
 Eye position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT. More...
 
Math::Vector m_prevLookat
 Lookat position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT. More...
 
float m_focus
 
Math::Vector m_eyePt
 CAM_TYPE_FREE: eye. More...
 
float m_directionH
 CAM_TYPE_FREE: horizontal direction. More...
 
float m_directionV
 CAM_TYPE_FREE: vertical direction. More...
 
float m_heightEye
 CAM_TYPE_FREE: height above the ground. More...
 
float m_heightLookat
 CAM_TYPE_FREE: height above the ground. More...
 
float m_speed
 CAM_TYPE_FREE: speed of movement. More...
 
float m_backDist
 CAM_TYPE_BACK: distance. More...
 
float m_backMin
 CAM_TYPE_BACK: minimal distance. More...
 
float m_addDirectionH
 CAM_TYPE_BACK: additional horizontal direction. More...
 
float m_addDirectionV
 CAM_TYPE_BACK: additional vertical direction. More...
 
float m_fixDist
 CAM_TYPE_FIX: distance. More...
 
float m_fixDirectionH
 CAM_TYPE_FIX: horizontal direction. More...
 
float m_fixDirectionV
 CAM_TYPE_FIX: vertical direction. More...
 
Math::Vector m_visitGoal
 CAM_TYPE_VISIT: target position. More...
 
float m_visitDist
 CAM_TYPE_VISIT: distance. More...
 
float m_visitTime
 CAM_TYPE_VISIT: relative time. More...
 
CameraType m_visitType
 CAM_TYPE_VISIT: initial type. More...
 
float m_visitDirectionV
 CAM_TYPE_VISIT: direction. More...
 
Math::Point m_mousePos = Math::Point(0.5f, 0.5f)
 Last known mouse position, used to calculate change since last frame. More...
 
Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f)
 Change of mouse position since last frame. More...
 
Math::Point m_mouseDeltaEdge = Math::Point(0.0f, 0.0f)
 Change of camera position caused by edge camera. More...
 
float m_mouseWheelDelta = 0.0f
 Change of mouse wheel since last frame. More...
 
CenteringPhase m_centeringPhase
 
float m_centeringAngleH
 
float m_centeringAngleV
 
float m_centeringDist
 
float m_centeringCurrentH
 
float m_centeringCurrentV
 
float m_centeringTime
 
float m_centeringProgress
 
CameraEffect m_effectType
 
Math::Vector m_effectPos
 
float m_effectForce
 
float m_effectProgress
 
Math::Vector m_effectOffset
 
CameraOverEffect m_overType
 
float m_overForce
 
float m_overTime
 
Color m_overColorBase
 
Color m_overColor
 
int m_overMode
 
float m_overFadeIn
 
float m_overFadeOut
 
Math::Vector m_scriptEye
 
Math::Vector m_scriptLookat
 
bool m_freeze = false
 Is camera frozen? More...
 

Configuration settings

bool m_effect
 
bool m_blood
 
bool m_oldCameraScroll
 
bool m_cameraInvertX
 
bool m_cameraInvertY
 
void SetEffect (bool enable)
 
bool GetEffect ()
 
void SetBlood (bool enable)
 
bool GetBlood ()
 
void SetOldCameraScroll (bool scroll)
 
bool GetOldCameraScroll ()
 
void SetCameraInvertX (bool invert)
 
bool GetCameraInvertX ()
 
void SetCameraInvertY (bool invert)
 
bool GetCameraInvertY ()
 

Detailed Description

Camera moving in 3D scene.

This class manages everything related to animating the camera in 3D scene. Calculated values are then passed to Gfx::CEngine.

Member Function Documentation

bool Gfx::CCamera::EventProcess ( const Event event)

Management of an event.

void Gfx::CCamera::Init ( Math::Vector  eye,
Math::Vector  lookat,
float  delay 
)

Initializes the camera.

Parameters
eyeInitial eye position
lookatInitial lookat position
delayTime of the initial entry animation
void Gfx::CCamera::SetControllingObject ( CObject object)

Sets the object controlling the camera.

CObject * Gfx::CCamera::GetControllingObject ( )

Gets the object controlling the camera.

void Gfx::CCamera::SetType ( CameraType  type)

Change the type of camera.

CameraType Gfx::CCamera::GetType ( )

Get the type of the camera.

void Gfx::CCamera::SetSmooth ( CameraSmooth  type)

Set smoothing mode.

CameraSmooth Gfx::CCamera::GetSmooth ( )

Get smoothing mode.

void Gfx::CCamera::GetCamera ( Math::Vector eye,
Math::Vector lookat 
)

Returns the current point of view of the camera.

void Gfx::CCamera::StartVisit ( Math::Vector  goal,
float  dist 
)

Start visit camera.

void Gfx::CCamera::StopVisit ( )

Stop visit camera.

bool Gfx::CCamera::StartCentering ( CObject object,
float  angleH,
float  angleV,
float  dist,
float  time 
)

Move camera to show happening action.

bool Gfx::CCamera::StopCentering ( CObject object,
float  time 
)

Go back to normal position after showing some happening action.

void Gfx::CCamera::AbortCentering ( )

Abort centering animation in the current position.

void Gfx::CCamera::StartEffect ( CameraEffect  effect,
Math::Vector  pos,
float  force 
)

Starts a camera shake effect.

void Gfx::CCamera::FlushEffect ( )

Removes the camera shake effect.

void Gfx::CCamera::StartOver ( CameraOverEffect  effect,
Math::Vector  pos,
float  force 
)

Starts camera overlay effect.

void Gfx::CCamera::FlushOver ( )

Removes camera overlay effect.

void Gfx::CCamera::SetOverBaseColor ( Color  color)

Specifies camera overlay effect base color.

void Gfx::CCamera::SetScriptCamera ( Math::Vector  eye,
Math::Vector  lookat 
)

Script camera: Set camera position.

void Gfx::CCamera::SetScriptCameraAnimate ( Math::Vector  eye,
Math::Vector  lookat 
)

Script camera: Animate to given camera position.

void Gfx::CCamera::SetScriptCameraAnimateEye ( Math::Vector  eye)

Script camera: Animate to given eye position.

void Gfx::CCamera::SetScriptCameraAnimateLookat ( Math::Vector  lookat)

Script camera: Animate to given lookat position.

void Gfx::CCamera::SetFreeze ( bool  freeze)

Temporarily freeze camera movement.

void Gfx::CCamera::SetCameraSpeed ( float  speed)

Set camera speed.

void Gfx::CCamera::EffectFrame ( const Event event)
protected

Advances the effect of the camera.

void Gfx::CCamera::OverFrame ( const Event event)
protected

Advanced overlay effect in the foreground.

void Gfx::CCamera::UpdateCameraAnimation ( const Math::Vector eyePt,
const Math::Vector lookatPt,
float  rTime 
)
protected

Calculates camera animation and sends updated camera position to the 3D engine.

Parameters
eyePtEye point
lookatPtLookat point
rTimeTime since last time this function was called (used to calculate animation)
See also
SetViewParams
void Gfx::CCamera::IsCollision ( Math::Vector eye,
Math::Vector  lookat 
)
protected

Avoid the obstacles.

For CAM_TYPE_BACK: make obstacles transparent For CAM_TYPE_FIX or CAM_TYPE_PLANE: adjust eye not to hit the obstacles

Parameters
eyeEye position, may be adjusted
lookatLookat point
void Gfx::CCamera::IsCollisionBack ( )
protected

Avoid the obstacles (CAM_TYPE_BACK)

void Gfx::CCamera::IsCollisionFix ( Math::Vector eye,
Math::Vector  lookat 
)
protected

Avoid the obstacles (CAM_TYPE_FIX or CAM_TYPE_PLANE)

Math::Vector Gfx::CCamera::ExcludeTerrain ( Math::Vector  eye,
Math::Vector  lookat,
float &  angleH,
float &  angleV 
)
protected

Adjusts the camera not to enter the ground.

Math::Vector Gfx::CCamera::ExcludeObject ( Math::Vector  eye,
Math::Vector  lookat,
float &  angleH,
float &  angleV 
)
protected

Adjusts the camera not to enter an object.

void Gfx::CCamera::SetViewParams ( const Math::Vector eye,
const Math::Vector lookat,
const Math::Vector up = Math::Vector(0.0f, 1.0f, 0.0f) 
)
protected

Updates the location and direction of the camera in the 3D engine.

Parameters
eyeEye point
lookatLookat point
upUp vector
See also
CEngine::SetViewParams
Math::Vector Gfx::CCamera::CalculateCameraMovement ( const Event event,
bool  keysAllowed = true 
)
protected

Calculate camera movement (from user inputs) to apply.

Returns
Math::Vector where x, y represent respectively horizontal and vertical angle change in radians and z represents zoom (distance change)
Remarks
Should not be called more often than once every EVENT_FRAME

Member Data Documentation

CameraType Gfx::CCamera::m_type
protected

The type of camera.

CameraSmooth Gfx::CCamera::m_smooth
protected

Type of smoothing.

CObject* Gfx::CCamera::m_cameraObj
protected

Object linked to the camera.

float Gfx::CCamera::m_initDelay
protected

Remaining time of initial camera entry animation.

Math::Vector Gfx::CCamera::m_actualEye
protected

Current eye.

Math::Vector Gfx::CCamera::m_actualLookat
protected

Current aim.

Math::Vector Gfx::CCamera::m_finalEye
protected

Final eye.

Math::Vector Gfx::CCamera::m_finalLookat
protected

Final lookat.

Math::Vector Gfx::CCamera::m_prevEye
protected

Eye position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT.

Math::Vector Gfx::CCamera::m_prevLookat
protected

Lookat position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT.

Math::Vector Gfx::CCamera::m_eyePt
protected

CAM_TYPE_FREE: eye.

float Gfx::CCamera::m_directionH
protected

CAM_TYPE_FREE: horizontal direction.

float Gfx::CCamera::m_directionV
protected

CAM_TYPE_FREE: vertical direction.

float Gfx::CCamera::m_heightEye
protected

CAM_TYPE_FREE: height above the ground.

float Gfx::CCamera::m_heightLookat
protected

CAM_TYPE_FREE: height above the ground.

float Gfx::CCamera::m_speed
protected

CAM_TYPE_FREE: speed of movement.

float Gfx::CCamera::m_backDist
protected

CAM_TYPE_BACK: distance.

float Gfx::CCamera::m_backMin
protected

CAM_TYPE_BACK: minimal distance.

float Gfx::CCamera::m_addDirectionH
protected

CAM_TYPE_BACK: additional horizontal direction.

float Gfx::CCamera::m_addDirectionV
protected

CAM_TYPE_BACK: additional vertical direction.

float Gfx::CCamera::m_fixDist
protected

CAM_TYPE_FIX: distance.

float Gfx::CCamera::m_fixDirectionH
protected

CAM_TYPE_FIX: horizontal direction.

float Gfx::CCamera::m_fixDirectionV
protected

CAM_TYPE_FIX: vertical direction.

Math::Vector Gfx::CCamera::m_visitGoal
protected

CAM_TYPE_VISIT: target position.

float Gfx::CCamera::m_visitDist
protected

CAM_TYPE_VISIT: distance.

float Gfx::CCamera::m_visitTime
protected

CAM_TYPE_VISIT: relative time.

CameraType Gfx::CCamera::m_visitType
protected

CAM_TYPE_VISIT: initial type.

float Gfx::CCamera::m_visitDirectionV
protected

CAM_TYPE_VISIT: direction.

Math::Point Gfx::CCamera::m_mousePos = Math::Point(0.5f, 0.5f)
protected

Last known mouse position, used to calculate change since last frame.

Math::Point Gfx::CCamera::m_mouseDelta = Math::Point(0.0f, 0.0f)
protected

Change of mouse position since last frame.

Math::Point Gfx::CCamera::m_mouseDeltaEdge = Math::Point(0.0f, 0.0f)
protected

Change of camera position caused by edge camera.

float Gfx::CCamera::m_mouseWheelDelta = 0.0f
protected

Change of mouse wheel since last frame.

bool Gfx::CCamera::m_freeze = false
protected

Is camera frozen?


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