Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

Camera Class Reference

#include <camera.h>

Inheritance diagram for Camera:

Inheritance graph
[legend]
Collaboration diagram for Camera:

Collaboration graph
[legend]
List of all members.

Detailed Description

Main camera abstraction class. Use for rendering.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types


Public Member Functions

 Camera (const std::string &rstrName, SceneNode *pkParent=0)
bool Render (Frustum *pkFrustum=0, bool bForce=false)
void LookAt (const Vector3d &rkAt, const Vector3d &rkUp)
const MatrixGetViewMatrix ()
const MatrixGetInverseViewMatrix ()
void SetRoom (Room *pkRoom)
RoomGetRoom ()
void SetActive ()
virtual void NotifyUpdate (bool bRecurse=true)
virtual void NotifyVolumeUpdate (bool bRecurse=true)
virtual void Update (float fDeltaTime)
BoundingVolumeGetBoundingVolume ()
void SetBoundingVolume (BoundingVolume *pkVolume)
SceneEntityGetEntity ()
void SetEntity (SceneEntity *pkEntity, bool bDeleteOld=true)
void PrintHierarchy (unsigned int uiLevel=0)
virtual SceneNodeDuplicate ()
virtual void TraverseNode (BaseVisitor &rkVisitor)
virtual bool Intersection (BoundingVolume *pkObj, ContactSet *pkContactSet=0)
virtual bool Intersection (const Ray &rkRay, ContactSet *pkContactSet=0)
bool IsActive () const
virtual void Activate ()
virtual void Deactivate ()
bool Toggle ()
virtual void SetTranslation (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
virtual void SetRotation (const Quaternion &rkRotation, bool bNotifyUpdate=true)
virtual void SetScaling (float fScaling, bool bNotifyUpdate=true)
void SetName (const HashString &rstrName)
const HashStringGetName () const
SceneNodeGetParent ()
virtual int AttachNode (SceneNode *pkNode, bool bKeepWorldSRT=false)
virtual int DetachNode (SceneNode *pkNode)
void DetachFromParent ()
const Vector3dGetWorldTranslation ()
const QuaternionGetWorldRotation ()
float GetWorldScaling ()
const MatrixGetWorldTransform ()
const MatrixGetInverseWorldTransform ()
const std::vector< SceneNode * > & GetChildren ()
SceneNodeGetByName (const HashString &rstrName, NODESEARCHMODE eMode=BREADTH_FIRST, bool bInitSearch=true)
virtual void Traverse (BaseVisitor &rkVisitor, NODESEARCHMODE eMode=DEPTH_FIRST, int iDirection=1, bool bInitSearch=true)
virtual void Accept (BaseVisitor &rkVisitor)=0
const Vector3dGetTranslation () const
const QuaternionGetRotation () const
float GetScaling () const
void Translate (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
void TranslateWorld (const Vector3d &rkTranslation, bool bNotifyUpdate=true)
void Rotate (const Quaternion &rkRotation, bool bNotifyUpdate=true)
void RotateWorld (const Quaternion &rkRotation, bool bNotifyUpdate=true)
void Scale (float fScaling, bool bNotifyUpdate=true)

Static Public Member Functions

CameraGetActive ()

Public Attributes

bool m_bIgnoreVolume
unsigned int m_uiLastFrame

Static Public Attributes

unsigned int s_uiFrameCount

Protected Member Functions

virtual bool UpdateWorld ()
virtual bool UpdateVolume ()
virtual SceneNodeGet ()

Static Protected Member Functions

template<class NodeType> void AcceptImpl (NodeType &rkVisited, BaseVisitor &rkVisitor)

Protected Attributes

Roomm_pkRoom
SceneEntitym_pkEntity
BoundingVolumem_pkBoundingVolume
bool m_bNeedVolumeUpdate
bool m_bIgnoreVolumeUpdate
bool m_bActive
bool m_bWorldUpdate
float m_fWorldScaling
Quaternion m_kWorldRotation
Vector3d m_kWorldTranslation
std::vector< SceneNode * > m_vpkChildren
SceneNodem_pkParent
HashString m_strName
Matrix m_kWorldTransform
Matrix m_kInverseWorldTransform
float m_fScaling
Quaternion m_kRotation
Vector3d m_kTranslation

Static Protected Attributes

Cameras_pkActiveCamera


Constructor & Destructor Documentation

Camera const std::string &  rstrName,
SceneNode pkParent = 0
 

Create camera

Parameters:
rstrName Name
pkParent Parent node


Member Function Documentation

bool Render Frustum pkFrustum = 0,
bool  bForce = false
[virtual]
 

Render camera

Parameters:
pkFrustum Ignored, will continue rendering with own frustum
bForce Force rendering of nodes even if already rendered
Returns:
true if successful, false if error

Reimplemented from SceneNode.

void LookAt const Vector3d rkAt,
const Vector3d rkUp
 

Sets current orientation derived from at and up vector

Parameters:
rkAt Vector indicating viewing direction
rkUp Vector indicating up direction

const Matrix& GetViewMatrix  )  [inline]
 

Returns:
View matrix

const Matrix& GetInverseViewMatrix  )  [inline]
 

Returns:
Inverse view matrix

void SetRoom Room pkRoom  ) 
 

Set room

Parameters:
pkRoom New room

Room* GetRoom  )  [inline]
 

Returns:
Current room

void SetActive  )  [inline]
 

Set as active camera

Camera* GetActive  )  [inline, static]
 

Returns:
Active camera

virtual bool UpdateWorld  )  [protected, virtual, inherited]
 

Updates world SRT data cache

Returns:
true if world cache data was updated, false if not

Reimplemented from HierarchyNode< SceneNode >.

virtual bool UpdateVolume  )  [protected, virtual, inherited]
 

Updates bounding volume for subtree rooted at this node

Returns:
true if any bounding volume was updated, false if not

virtual SceneNode* Get  )  [inline, protected, virtual, inherited]
 

Used to get this as correct type

Returns:
This node

Reimplemented from HierarchyNode< SceneNode >.

virtual void NotifyUpdate bool  bRecurse = true  )  [inline, virtual, inherited]
 

Set world udpate flag. If flag is set, a call to any of the GetWorldScaling, GetWorldRotation, GetWorldTranslation will cause world cache data to be updated. Optionally recurses on all child nodes (default).

Parameters:
bRecurse Recurse on children

Reimplemented from HierarchyNode< SceneNode >.

virtual void NotifyVolumeUpdate bool  bRecurse = true  )  [inline, virtual, inherited]
 

Set bounding volume udpate flag. If flag is set, a call to any of the GetBoundingVolume will cause volume to be remerged from child nodes and entity. Optionally recurses on parent (default).

Parameters:
bRecurse Recurse on parent

virtual void Update float  fDeltaTime  )  [virtual, inherited]
 

If node is active, update node and any child nodes. Also calls Update on the entity object, if any.

Parameters:
fDeltaTime Delta time passed

Reimplemented from UpdateEntity.

Reimplemented in AnimatedNode, MassParticle, ParticleSystem, PhysicsNode, RigidBody, and Skeleton.

BoundingVolume* GetBoundingVolume  )  [inline, inherited]
 

Get bounding volume

Returns:
Bounding volume for entire subtree rooted at this node

void SetBoundingVolume BoundingVolume pkVolume  )  [inherited]
 

Set bounding volume object. Bounding volume transformation should be in world coordinate system

Parameters:
pkVolume Bounding volume

SceneEntity* GetEntity  )  [inline, inherited]
 

Get scene entity attached to this node

Returns:
Scene entity object pointer

void SetEntity SceneEntity pkEntity,
bool  bDeleteOld = true
[inherited]
 

Attach new scene entity to this node. If flag set, Will delete previous entity (if any)

Parameters:
pkEntity New scene entity object
bDeleteOld if true, delete old entity object

void PrintHierarchy unsigned int  uiLevel = 0  )  [inherited]
 

Debug output. Print hierarchy of nodes

Parameters:
uiLevel Current recursion level

virtual SceneNode* Duplicate  )  [virtual, inherited]
 

Duplicate node, child nodes and optionally entities

Returns:
New node that is exact duplicate of this node

Reimplemented in AnimatedNode, MassParticle, ParticleSystem, PhysicsNode, RigidBody, and Skeleton.

virtual void TraverseNode BaseVisitor rkVisitor  )  [virtual, inherited]
 

Also traverse the entitiy

Parameters:
rkVisitor Visitor to apply to each node

Reimplemented from HierarchyNode< SceneNode >.

virtual bool Intersection BoundingVolume pkObj,
ContactSet pkContactSet = 0
[virtual, inherited]
 

Intersection test with unknown object type

Parameters:
pkObj Bounding volume object to test for intersection with
pkContactSet Contact set object receiving collision contact data, 0 if not needed
Returns:
true if volumes intersect, false if not

virtual bool Intersection const Ray rkRay,
ContactSet pkContactSet = 0
[virtual, inherited]
 

Intersection test with ray

Parameters:
rkRay Ray
pkContactSet Contact set object receiving collision contact data, 0 if not needed
Returns:
true if volumes intersect, false if not

bool IsActive  )  const [inline, inherited]
 

Query state of object

Returns:
true if active, false if not

void Activate  )  [inline, virtual, inherited]
 

Activate object

void Deactivate  )  [inline, virtual, inherited]
 

Deactivate object

bool Toggle  )  [inline, inherited]
 

Toggle active state. This method does not need to be overloaded, it is only a wrapper to Activate and Deactivate

Returns:
true if activated, false if deactivated

virtual void SetTranslation const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, virtual, inherited]
 

Set position relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
rkTranslation New translation relative parent node
bNotifyUpdate Set update flag to child tree for world SRT data and parent tree for bounding volume (true default, use false with caution)

Reimplemented from SRTNode.

virtual void SetRotation const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, virtual, inherited]
 

Set rotation relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
rkRotation New rotation relative parent node
bNotifyUpdate Set update flag to child tree for world SRT data (true default, use false with caution)

Reimplemented from SRTNode.

virtual void SetScaling float  fScaling,
bool  bNotifyUpdate = true
[inline, virtual, inherited]
 

Set uniform scaling relative parent node. Will set flag to update world cache data, and optionally recurse and flag child nodes to update data

Parameters:
fScaling Uniform scaling factor
bNotifyUpdate Set update flag to child tree for world SRT data (true default, use false with caution)

Reimplemented from SRTNode.

void SetName const HashString rstrName  )  [inline, inherited]
 

Set name

Parameters:
rstrName New node name

const HashString& GetName  )  const [inline, inherited]
 

Returns:
Node name

SceneNode * GetParent  )  [inline, inherited]
 

Returns:
Parent node

virtual int AttachNode SceneNode pkNode,
bool  bKeepWorldSRT = false
[virtual, inherited]
 

Attach node. If the node is attached to a parent, detach it first. This will cause the node to get it's world SRT data as local SRT data. If bKeepWorldSRT is set, node will be updated with inverse of this (new parent) node's SRT data, effectively keeping it intact in world space. If flag not set, node will effectivaly get new parent world SRT data added to own (used in initialization phase, for example).

Parameters:
pkNode Node to attach
bKeepWorldSRT If true, recalculate node relative position to maintain world SRT
Returns:
undefined (reserved for future use or derived classes)

Reimplemented in Room.

virtual int DetachNode SceneNode pkNode  )  [virtual, inherited]
 

Detach node. The node will store world SRT data in local SRT data.

Parameters:
pkNode Node to detach
Returns:
undefined (reserved for future use or derived classes)

Reimplemented in Room.

void DetachFromParent  )  [inherited]
 

Detach this node from parent, if any. Will store world SRT data (and update first if needed) in local SRT data to remain in same world position and orientation.

const Vector3d& GetWorldTranslation  )  [inline, inherited]
 

Get position relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World position

const Quaternion& GetWorldRotation  )  [inline, inherited]
 

Get rotation relative world unrotated coordinate system. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World-relative quaternion

float GetWorldScaling  )  [inline, inherited]
 

Get total unform scaling factor relative world scale. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World scaling factor

const Matrix& GetWorldTransform  )  [inline, inherited]
 

Get total transform matrix relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
World transform matrix

const Matrix& GetInverseWorldTransform  )  [inline, inherited]
 

Get inverse total transform matrix relative world coordinate system origo. The world SRT data is the combined hierarchial data of any parent nodes and this node.

Returns:
Inverse world transform matrix

const std::vector< SceneNode * >& GetChildren  )  [inline, inherited]
 

Get all child nodes

Returns:
Children node vector

SceneNode * GetByName const HashString rstrName,
NODESEARCHMODE  eMode = BREADTH_FIRST,
bool  bInitSearch = true
[inherited]
 

Search hierarchy for named node, including this node. Will return first node found along selected search mode.

Parameters:
rstrName Node name to search for
eMode Search mode (see enum descriptions for details)
bInitSearch Internal flag
Returns:
Ptr to node or null if not found

virtual void Traverse BaseVisitor rkVisitor,
NODESEARCHMODE  eMode = DEPTH_FIRST,
int  iDirection = 1,
bool  bInitSearch = true
[virtual, inherited]
 

Traverse the hierarchy applying the visitor to the nodes.

Parameters:
rkVisitor Visitor to apply to each node.
eMode Search mode (see enum descriptions for details)
iDirection Direction of traversal (for DEPTH_FIRST, > 0 means top-down, < 0 means bottom up)
bInitSearch Internal flag

void AcceptImpl NodeType &  rkVisited,
BaseVisitor rkVisitor
[inline, static, protected, inherited]
 

Accept visitors if implementation available

Parameters:
rkVisited Node being visited
rkVisitor Visitor

virtual void Accept BaseVisitor rkVisitor  )  [pure virtual, inherited]
 

Accept a visitor

Parameters:
rkVisitor Visitor

const Vector3d& GetTranslation  )  const [inline, inherited]
 

Returns:
Translation of this node

const Quaternion& GetRotation  )  const [inline, inherited]
 

Returns:
Rotation of this node

float GetScaling  )  const [inline, inherited]
 

Returns:
Uniform scaling factor

void Translate const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Translate node from current position, in local (along current rotated axes) coordinate system. Will call SetTranslation() for setting new translation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkTranslation Translation offset vector
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void TranslateWorld const Vector3d rkTranslation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Translate node from current position, in world (along unrotated axes) coordinate system. Will call SetTranslation() for setting new translation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkTranslation Translation offset vector
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void Rotate const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Rotate node in local (current rotation) coordinate system. Will call SetRotation() for setting new rotation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkRotation Rotation quaternion
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void RotateWorld const Quaternion rkRotation,
bool  bNotifyUpdate = true
[inline, inherited]
 

Rotate node in world (unrotated) coordinate system. Will call SetRotation() for setting new rotation of node, derived classes do not need to overload this method directly. Not affected by current scaling.

Parameters:
rkRotation Rotation quaternion
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)

void Scale float  fScaling,
bool  bNotifyUpdate = true
[inline, inherited]
 

Scale node by uniform factor. Will use SetScaling for setting new scaling of node, derived classes do not need to overload this method directly. Must be >0, where a value of 1.0f indicates no scaling

Parameters:
fScaling Uniform scaling factor
bNotifyUpdate Used by derived classes to indicate if to set update flag to child tree (true default, use false with caution)


Member Data Documentation

Room* m_pkRoom [protected]
 

Room we are in

Reimplemented from SceneNode.

Camera* s_pkActiveCamera [static, protected]
 

Current active camera

SceneEntity* m_pkEntity [protected, inherited]
 

Scene entity contained in this node

BoundingVolume* m_pkBoundingVolume [protected, inherited]
 

Bounding volume for subtree rooted at this node

bool m_bNeedVolumeUpdate [protected, inherited]
 

Flag indicating bounding volume needs remerging

bool m_bIgnoreVolumeUpdate [protected, inherited]
 

Internal flag for indicating we should ignore requests for volume update

bool m_bIgnoreVolume [inherited]
 

Flag indicating parent node should ignore this node when calculating bounding volume

bool m_bActive [protected, inherited]
 

Active flag

unsigned int s_uiFrameCount [static, inherited]
 

Frame counter (at 500 frames per second, can be active ~100 days continously before loop, and then it will just skip one frame -> safe enough)

unsigned int m_uiLastFrame [inherited]
 

Last frame count we were rendered

bool m_bWorldUpdate [protected, inherited]
 

Flag indicating we need to update world relative SRT information

float m_fWorldScaling [protected, inherited]
 

Total scaling relative world (cached)

Quaternion m_kWorldRotation [protected, inherited]
 

Total rotation relative world (cached)

Vector3d m_kWorldTranslation [protected, inherited]
 

Total translation relative world (cached)

std::vector< SceneNode * > m_vpkChildren [protected, inherited]
 

Child nodes

SceneNode * m_pkParent [protected, inherited]
 

Parent node

HashString m_strName [protected, inherited]
 

Name

Matrix m_kWorldTransform [protected, inherited]
 

Total transformation matrix relative world (cached)

Matrix m_kInverseWorldTransform [protected, inherited]
 

Total inverse transformation matrix relative world (cached)

float m_fScaling [protected, inherited]
 

Uniform scaling factor (must be >0, default 1)

Quaternion m_kRotation [protected, inherited]
 

Rotation

Vector3d m_kTranslation [protected, inherited]
 

Translation


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:10 2004 for NeoEngine by doxygen 1.3.5