Planeshift
Classes | Public Types | Public Member Functions

psCamera Class Reference

#include <pscamera.h>

List of all members.

Classes

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

Detailed Description

Definition at line 51 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 62 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 492 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 494 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: