Planeshift
psCamera Class Reference

Handles camera modes like first person, thrid person, speak to npc manages collision of camera with meshes, moving, turning, ... More...

#include <pscamera.h>

Classes

struct  DistanceCfg
 

Public Types

enum  CAMERA_MODES {
  CAMERA_FIRST_PERSON = 0, CAMERA_THIRD_PERSON, CAMERA_M64_THIRD_PERSON, CAMERA_LARA_THIRD_PERSON,
  CAMERA_FREE, CAMERA_ACTUAL_DATA, CAMERA_LAST_ACTUAL, CAMERA_TRANSITION,
  CAMERA_NPCTALK, CAMERA_COLLISION, CAMERA_ERR, CAMERA_MODES_COUNT
}
 

Public Member Functions

bool CheckCameraCD () const
 returns whether the camera is performing CD or not More...
 
bool Draw ()
 applies the camera data to the viewport and renders the 3D scene More...
 
iMeshWrapper * FindMeshUnder2D (int x, int y, csVector3 *pos=NULL, int *poly=NULL)
 Returns the mesh under the 2D point. More...
 
iMeshWrapper * Get3DPointFrom2D (int x, int y, csVector3 *worldCoord=0, csVector3 *untransfCoord=0)
 returns the 3D point where the line under the given point intersects with the world More...
 
int GetCameraMode () const
 returns the current camera mode (as integer) More...
 
csString GetCameraModeVerbose () const
 returns the current camera mode (text description) More...
 
float GetDampeningCoef (int mode=-1) const
 returns the dampening coefficient of the camera More...
 
float GetDefaultPitch (int mode=-1) const
 returns the default (starting) pitch of the specific camera mode More...
 
float GetDefaultYaw (int mode=-1) const
 returns the default (starting) yaw of the specific camera mode More...
 
float GetDistance (int mode=-1) const
 returns the distance from the camera position to its target More...
 
DistanceCfg GetDistanceCfg ()
 
int GetFixedDistClip ()
 
csVector3 GetForwardVector (int mode=-1) const
 returns the forward vector of the camera More...
 
iPerspectiveCamera * GetICamera ()
 returns the camera that CS use More...
 
int GetLastCameraMode ()
 gets the last used camera mode More...
 
float GetMaxDistance (int mode=-1) const
 returns the max distance from the camera position to the target More...
 
float GetMinDistance (int mode=-1) const
 returns the min distance from the camera position to the target More...
 
float GetPitch (int mode=-1) const
 returns the pitch (up/down) of the camera More...
 
float GetPitchVelocity () const
 gets the pitch (up/down) velocity of the camera More...
 
csVector3 GetPosition (int mode=-1) const
 returns the current position of the camera (different for each mode) More...
 
csVector3 GetRightVector (int mode=-1) const
 returns the forward vector of the camera More...
 
float GetSpringCoef (int mode=-1) const
 returns the spring coefficient of the camera More...
 
float GetSpringLength (int mode=-1) const
 returns the spring length of the camera More...
 
float GetSwingCoef (int mode=-1) const
 returns the swing coefficient of the specific camera mode More...
 
csVector3 GetTarget (int mode=-1) const
 returns the current position of the camera (different for each mode) More...
 
float GetTransitionThreshold () const
 gets the camera transition threshold (the distance between camera position and ideal where the camera ceases to be in transition) More...
 
float GetTurnSpeed (int mode=-1) const
 returns the turning speed of the camera (ignored for most camera modes) More...
 
csVector3 GetUp (int mode=-1) const
 Returns the current up vector of the camera (different for each mode). More...
 
bool GetUseNPCCam ()
 returns whether the npc chat camera is used or not More...
 
iView * GetView ()
 returns the CS viewport More...
 
float GetYaw (int mode=-1) const
 returns the yaw (left/right) of the camera More...
 
float GetYawVelocity () const
 gets the yaw (up/down) velocity of the camera More...
 
const char * HandleCommand (const char *cmd)
 Interprets a received message and executes the command. More...
 
void HandleMessage (MsgEntry *msg)
 
bool InitializeView (GEMClientActor *entity)
 creates the viewport More...
 
bool IsInitialized ()
 
bool LoadFromFile (bool useDefault=false, bool overrideCurrent=true)
 loads the camera settings from a file More...
 
void LoadOptions ()
 This function is called when the options system has been issued a Save() call. More...
 
void LockCameraMode (bool state)
 locks the current camera mode so it cannot be changed More...
 
void MoveDistance (float deltaDistance, int mode=-1)
 moves the distance from the camera position to its target More...
 
void MovePitch (float deltaPitch, int mode=-1)
 moves the pitch (up/down) of the camera More...
 
void MoveYaw (float deltaYaw, int mode=-1)
 moves the yaw (left/right) of the camera More...
 
void NextCameraMode ()
 changes the current camera mode to the next available camera mode More...
 
void npcTargetReplaceIfEqual (GEMClientObject *currentEntity, GEMClientObject *replacementEntity)
 Replace the actor the camera is targeting when in npc camera mode. More...
 
 psCamera ()
 
void ResetActualCameraData ()
 resets the actual camera data to the player position and stuff More...
 
void ResetCameraPositioning ()
 flags the camera positioning as bad so that it will reset it next update loop More...
 
bool RotateCameraWithPlayer () const
 moves decides, based on the camera mode, whether the camera should be rotated along-side the player More...
 
void SaveOptions ()
 This function is called whenever the options system needs the options class to give it its options values. More...
 
bool SaveToFile ()
 saves the camera settings to a file More...
 
void SetActor (GEMClientActor *entity)
 Set the actor the camera is following. More...
 
void SetCameraCD (bool useCD)
 sets whether the camera is performing CD or not More...
 
void SetCameraMode (int mode)
 sets the current camera mode More...
 
void SetDampeningCoef (float coef, int mode=-1)
 sets the dampening coefficient of the camera More...
 
void SetDefaultPitch (float pitch, int mode=-1)
 sets the default (starting) pitch for the specific camera mode More...
 
void SetDefaultYaw (float yaw, int mode=-1)
 sets the default (starting) yaw for the specific camera mode More...
 
void SetDistance (float distance, int mode=-1)
 sets the distance from the camera position to its target More...
 
void SetDistanceCfg (DistanceCfg newcfg)
 
void SetMaxDistance (float dist, int mode=-1)
 sets the max distance from the camera position to the target More...
 
void SetMinDistance (float dist, int mode=-1)
 sets the min distance from the camera position to the target More...
 
void SetPitch (float pitch, int mode=-1)
 sets the pitch (up/down) of the camera More...
 
void SetPitchVelocity (float pitchVel)
 sets the pitch (up/down) velocity of the camera More...
 
void SetPosition (const csVector3 &pos, int mode=-1)
 sets the current position of the camera (different for each mode) More...
 
void SetSpringCoef (float coef, int mode=-1)
 sets the spring coefficient of the camera More...
 
void SetSpringLength (float length, int mode=-1)
 sets the spring length of the camera More...
 
void SetSwingCoef (float swingCoef, int mode=-1)
 sets the swing coefficient of the specific camera mode More...
 
void SetTarget (const csVector3 &tar, int mode=-1)
 Sets the current target of the camera (different for each mode). More...
 
void SetTransitionThreshold (float threshold)
 sets the camera transition threshold (the distance between camera position and ideal where the camera ceases to be in transition) More...
 
void SetTurnSpeed (float speed, int mode=-1)
 sets the turning speed of the camera (ignored for most camera modes) More...
 
void SetUp (const csVector3 &up, int mode=-1)
 Sets the current up vector of the camera (different for each mode). More...
 
void SetUseNPCCam (bool useNPCCam)
 sets whether the npc chat camera is used or not More...
 
void SetYaw (float yaw, int mode=-1)
 sets the yaw (left/right) of the camera More...
 
void SetYawVelocity (float yawVel)
 sets the yaw (up/down) velocity of the camera More...
 
void UseAdaptiveDistanceClipping (int minFPS, int maxFPS, int minDist)
 puts camera to adaptive distance clipping mode - camera will automatically adjust the distance to stay in given fps interval More...
 
void UseFixedDistanceClipping (float dist)
 puts camera to fixed distance clipping mode - distance clipping will be set to constant value More...
 
virtual ~psCamera ()
 
- Public Member Functions inherited from iOptionsClass
virtual ~iOptionsClass ()
 
- Public Member Functions inherited from psCmdBase
virtual void HandleMessage (MsgEntry *msg, Client *)
 Interprets a received message and executes the command. More...
 
 psCmdBase (ClientMsgHandler *mh, CmdHandler *ch, iObjectRegistry *obj)
 
void Report (int severity, const char *msgtype, const char *description,...)
 
virtual bool Setup (ClientMsgHandler *mh, CmdHandler *ch)
 
virtual bool Verify (MsgEntry *, unsigned int, Client *&)
 
virtual ~psCmdBase ()
 

Additional Inherited Members

- Protected Attributes inherited from psCmdBase
CmdHandlercmdsource
 
ClientMsgHandlermsgqueue
 
iObjectRegistry * objreg
 

Detailed Description

Handles camera modes like first person, thrid person, speak to npc manages collision of camera with meshes, moving, turning, ...

Definition at line 55 of file pscamera.h.

Member Enumeration Documentation

Enumerator
CAMERA_FIRST_PERSON 
CAMERA_THIRD_PERSON 
CAMERA_M64_THIRD_PERSON 
CAMERA_LARA_THIRD_PERSON 
CAMERA_FREE 
CAMERA_ACTUAL_DATA 
CAMERA_LAST_ACTUAL 
CAMERA_TRANSITION 
CAMERA_NPCTALK 
CAMERA_COLLISION 
CAMERA_ERR 
CAMERA_MODES_COUNT 

Definition at line 66 of file pscamera.h.

Constructor & Destructor Documentation

psCamera::psCamera ( )
virtual psCamera::~psCamera ( )
virtual

Member Function Documentation

bool psCamera::CheckCameraCD ( ) const

returns whether the camera is performing CD or not

Returns
true if using CD, false otherwise
bool psCamera::Draw ( )

applies the camera data to the viewport and renders the 3D scene

Returns
true on success, false on error
iMeshWrapper* psCamera::FindMeshUnder2D ( int  x,
int  y,
csVector3 *  pos = NULL,
int poly = NULL 
)

Returns the mesh under the 2D point.

Parameters
xthe x part of the 2D point
ythe y part of the 2D point
[out]posThe best found position.
polyNot used
Returns
the mesh under the 2D point
iMeshWrapper* psCamera::Get3DPointFrom2D ( int  x,
int  y,
csVector3 *  worldCoord = 0,
csVector3 *  untransfCoord = 0 
)

returns the 3D point where the line under the given point intersects with the world

Parameters
xthe x part of the 2D point
ythe y part of the 2D point
worldCoordcontainer to hold the calculated 3D world vector under the 2D point
untransfCoordcontainer to hold the untransformed 3D world vector (untouched by warp portals)
Returns
the mesh it intersects with
int psCamera::GetCameraMode ( ) const

returns the current camera mode (as integer)

Returns
The current camera mode
csString psCamera::GetCameraModeVerbose ( ) const

returns the current camera mode (text description)

Returns
A csString describing the current camera mode
float psCamera::GetDampeningCoef ( int  mode = -1) const

returns the dampening coefficient of the camera

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the dampening coefficient
float psCamera::GetDefaultPitch ( int  mode = -1) const

returns the default (starting) pitch of the specific camera mode

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the default (starting) pitch
float psCamera::GetDefaultYaw ( int  mode = -1) const

returns the default (starting) yaw of the specific camera mode

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the default (starting) yaw
float psCamera::GetDistance ( int  mode = -1) const

returns the distance from the camera position to its target

Parameters
modeOptional - the camera mode to get it from (leave blank for current)
Returns
the distance from the camera position to its target
DistanceCfg psCamera::GetDistanceCfg ( )
int psCamera::GetFixedDistClip ( )
inline

Definition at line 496 of file pscamera.h.

csVector3 psCamera::GetForwardVector ( int  mode = -1) const

returns the forward vector of the camera

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the forward vector
iPerspectiveCamera* psCamera::GetICamera ( )

returns the camera that CS use

Returns
An iCamera that CS uses
int psCamera::GetLastCameraMode ( )

gets the last used camera mode

Returns
the last camera mode
float psCamera::GetMaxDistance ( int  mode = -1) const

returns the max distance from the camera position to the target

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the max distance
float psCamera::GetMinDistance ( int  mode = -1) const

returns the min distance from the camera position to the target

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the min distance
float psCamera::GetPitch ( int  mode = -1) const

returns the pitch (up/down) of the camera

Parameters
modeOptional - the camera mode to get it from (leave blank for current)
Returns
the pitch (up/down) of the camera
float psCamera::GetPitchVelocity ( ) const

gets the pitch (up/down) velocity of the camera

Returns
the pitch (up/down) of the camera
csVector3 psCamera::GetPosition ( int  mode = -1) const

returns the current position of the camera (different for each mode)

Parameters
modethe camera mode
Returns
The current camera position for the current mode
csVector3 psCamera::GetRightVector ( int  mode = -1) const

returns the forward vector of the camera

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the forward vector
float psCamera::GetSpringCoef ( int  mode = -1) const

returns the spring coefficient of the camera

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the spring coefficient
float psCamera::GetSpringLength ( int  mode = -1) const

returns the spring length of the camera

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the spring length
float psCamera::GetSwingCoef ( int  mode = -1) const

returns the swing coefficient of the specific camera mode

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the swing coefficient
csVector3 psCamera::GetTarget ( int  mode = -1) const

returns the current position of the camera (different for each mode)

Parameters
modethe camera mode
Returns
The current camera target for the current mode
float psCamera::GetTransitionThreshold ( ) const

gets the camera transition threshold (the distance between camera position and ideal where the camera ceases to be in transition)

Returns
the camera transition threshold
float psCamera::GetTurnSpeed ( int  mode = -1) const

returns the turning speed of the camera (ignored for most camera modes)

Parameters
modeOptional - the camera mode to get the data from (leave blank for current)
Returns
the turning speed
csVector3 psCamera::GetUp ( int  mode = -1) const

Returns the current up vector of the camera (different for each mode).

Parameters
modethe camera mode
Returns
The current camera up vector for the current mode
bool psCamera::GetUseNPCCam ( )

returns whether the npc chat camera is used or not

Returns
true if using npc chat camera, false otherwise
iView* psCamera::GetView ( )

returns the CS viewport

Returns
an iView of this camera's CS viewport
float psCamera::GetYaw ( int  mode = -1) const

returns the yaw (left/right) of the camera

Parameters
modeOptional - the camera mode to get it from (leave blank for current)
Returns
the yaw (left/right) of the camera
float psCamera::GetYawVelocity ( ) const

gets the yaw (up/down) velocity of the camera

Returns
the yaw (up/down) of the camera
const char* psCamera::HandleCommand ( const char *  cmd)
virtual

Interprets a received message and executes the command.

char * returned can be an error message to display.

Implements psCmdBase.

void psCamera::HandleMessage ( MsgEntry msg)
virtual

Implements psCmdBase.

bool psCamera::InitializeView ( GEMClientActor entity)

creates the viewport

Parameters
entitythe actor for the view
Returns
true on success, false on error
bool psCamera::IsInitialized ( )
inline

Definition at line 498 of file pscamera.h.

bool psCamera::LoadFromFile ( bool  useDefault = false,
bool  overrideCurrent = true 
)

loads the camera settings from a file

Parameters
useDefaultif true, use the default config file even if the normal exists
overrideCurrentif true, change current camera settings with loaded data
Returns
true on success, false otherwise
void psCamera::LoadOptions ( )
virtual

This function is called when the options system has been issued a Save() call.

Options classes will be expected to load all associated options and apply them as appropriate.

Implements iOptionsClass.

void psCamera::LockCameraMode ( bool  state)

locks the current camera mode so it cannot be changed

Parameters
statethe desired state
void psCamera::MoveDistance ( float  deltaDistance,
int  mode = -1 
)

moves the distance from the camera position to its target

Parameters
deltaDistancethe amount to displace the current distance
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::MovePitch ( float  deltaPitch,
int  mode = -1 
)

moves the pitch (up/down) of the camera

Parameters
deltaPitchthe amount to move from the current pitch
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::MoveYaw ( float  deltaYaw,
int  mode = -1 
)

moves the yaw (left/right) of the camera

Parameters
deltaYawthe amount to move from the current yaw
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::NextCameraMode ( )

changes the current camera mode to the next available camera mode

void psCamera::npcTargetReplaceIfEqual ( GEMClientObject currentEntity,
GEMClientObject replacementEntity 
)

Replace the actor the camera is targeting when in npc camera mode.

It's replaced only if the actor is equal. This is to be used when deleting actor objects or replacing them, in order to avoid a pending invalid pointer in pscamera.

Parameters
currentEntityThe actor which is being replaced/deleted.
replacementEntityThe actor instance which is being created. Pass NULL if it's only being destroyed.
void psCamera::ResetActualCameraData ( )

resets the actual camera data to the player position and stuff

void psCamera::ResetCameraPositioning ( )

flags the camera positioning as bad so that it will reset it next update loop

bool psCamera::RotateCameraWithPlayer ( ) const

moves decides, based on the camera mode, whether the camera should be rotated along-side the player

Returns
true if the camera should be rotated, false otherwise
void psCamera::SaveOptions ( )
virtual

This function is called whenever the options system needs the options class to give it its options values.

The options class is expected to call SetOption for every option it uses.

Implements iOptionsClass.

bool psCamera::SaveToFile ( )

saves the camera settings to a file

Returns
true on success, false otherwise
void psCamera::SetActor ( GEMClientActor entity)

Set the actor the camera is following.

Parameters
entitythe actor for the view
void psCamera::SetCameraCD ( bool  useCD)

sets whether the camera is performing CD or not

Parameters
useCDtrue if the camera should perform CD, false otherwise
void psCamera::SetCameraMode ( int  mode)

sets the current camera mode

Parameters
modethe desired camera mode
void psCamera::SetDampeningCoef ( float  coef,
int  mode = -1 
)

sets the dampening coefficient of the camera

Parameters
coefthe dampening coefficient
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetDefaultPitch ( float  pitch,
int  mode = -1 
)

sets the default (starting) pitch for the specific camera mode

Parameters
pitchthe new default (starting) pitch
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetDefaultYaw ( float  yaw,
int  mode = -1 
)

sets the default (starting) yaw for the specific camera mode

Parameters
yawthe new default (starting) yaw
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetDistance ( float  distance,
int  mode = -1 
)

sets the distance from the camera position to its target

Parameters
distancethe new distance
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::SetDistanceCfg ( DistanceCfg  newcfg)
void psCamera::SetMaxDistance ( float  dist,
int  mode = -1 
)

sets the max distance from the camera position to the target

Parameters
distthe max distance
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetMinDistance ( float  dist,
int  mode = -1 
)

sets the min distance from the camera position to the target

Parameters
distthe min distance
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetPitch ( float  pitch,
int  mode = -1 
)

sets the pitch (up/down) of the camera

Parameters
pitchthe new pitch of the camera
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::SetPitchVelocity ( float  pitchVel)

sets the pitch (up/down) velocity of the camera

Parameters
pitchVelthe velocity of the pitch
void psCamera::SetPosition ( const csVector3 &  pos,
int  mode = -1 
)

sets the current position of the camera (different for each mode)

Parameters
posThe new camera position for the current mode
modethe camera mode
void psCamera::SetSpringCoef ( float  coef,
int  mode = -1 
)

sets the spring coefficient of the camera

Parameters
coefthe spring coefficient
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetSpringLength ( float  length,
int  mode = -1 
)

sets the spring length of the camera

Parameters
lengththe spring length
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetSwingCoef ( float  swingCoef,
int  mode = -1 
)

sets the swing coefficient of the specific camera mode

Parameters
swingCoefthe new swing coefficient
modeOptional - the camera mode to get the data from (leave blank for current)
void psCamera::SetTarget ( const csVector3 &  tar,
int  mode = -1 
)

Sets the current target of the camera (different for each mode).

Parameters
tarThe new camera target for the current mode
modethe camera mode
void psCamera::SetTransitionThreshold ( float  threshold)

sets the camera transition threshold (the distance between camera position and ideal where the camera ceases to be in transition)

Parameters
thresholdthe camera transition threshold
void psCamera::SetTurnSpeed ( float  speed,
int  mode = -1 
)

sets the turning speed of the camera (ignored for most camera modes)

Parameters
speedthe turning speed
modeOptional - the camera mode to set the data (leave blank for current)
void psCamera::SetUp ( const csVector3 &  up,
int  mode = -1 
)

Sets the current up vector of the camera (different for each mode).

Parameters
upThe new camera up vector for the current mode
modethe camera mode
void psCamera::SetUseNPCCam ( bool  useNPCCam)

sets whether the npc chat camera is used or not

Parameters
useNPCCamtrue if the npc chat camera should be used, false otherwise
void psCamera::SetYaw ( float  yaw,
int  mode = -1 
)

sets the yaw (left/right) of the camera

Parameters
yawthe new yaw of the camera
modeOptional - the camera mode to apply it to (leave blank for current)
void psCamera::SetYawVelocity ( float  yawVel)

sets the yaw (up/down) velocity of the camera

Parameters
yawVelthe velocity of the yaw
void psCamera::UseAdaptiveDistanceClipping ( int  minFPS,
int  maxFPS,
int  minDist 
)

puts camera to adaptive distance clipping mode - camera will automatically adjust the distance to stay in given fps interval

Parameters
minFPSminimum fps (viewing distance will shrink when fps is lower)
maxFPSmaximum fps (viewing distance will rise when fps is higher)
minDistlower bound on distance that will be never crossed
void psCamera::UseFixedDistanceClipping ( float  dist)

puts camera to fixed distance clipping mode - distance clipping will be set to constant value

Parameters
distthe maximum visible distance

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