omegalib  13.1
omega::Camera Class Reference

The Camera class handles information about a view transformation, head tracking and optional target buffers for off screen rendering A camera can have a controller that is used to implement a navigation technique. More...

#include <Camera.h>

Public Types

enum  CameraFlags { DrawScene = 1 << 1, DrawOverlay = 1 << 2, CullingEnabled = 1 << 3, DefaultFlags = DrawScene | DrawOverlay }
 
enum  RenderPassMasks { DefaultRenderPassMask = 0x00000000, AllRenderPassMask = 0xffffffff }
 
- Public Types inherited from omega::SceneNode
enum  HitType { HitBoundingSphere, HitBest }
 
- Public Types inherited from omega::Node
enum  TransformSpace { TransformLocal, TransformParent, TransformWorld }
 Enumeration denoting the spaces which a transform can be relative to. More...
 
typedef Dictionary< String, Ref< Node > > ChildNodeMap
 

Public Member Functions

 Camera (Engine *engine, uint flags=DefaultFlags)
 
CameraOutputgetOutput (uint contextId)
 
DisplayTileConfiggetCustomTileConfig ()
 Returns a custom tile configuration for secondary cameras that do no use default display tiles during rendering. More...
 
virtual void setup (Setting &s)
 
virtual void handleEvent (const Event &evt)
 
void setPitchYawRoll (const Vector3f &yawPitchRoll)
 
const AffineTransform3getViewTransform ()
 
void setNearFarZ (float near, float far)
 
float getNearZ ()
 
float getFarZ ()
 
void focusOn (SceneNode *node)
 
virtual void lookAt (const Vector3f &position, const Vector3f &upVector)
 Rotate the node to make its positive Z axis point toward the specified position. More...
 
virtual bool isEnabledInContext (const DrawContext &context)
 Returns true if this camera is enabled in the specified draw context. More...
 
virtual bool isEnabledInContext (DrawContext::Task task, const DisplayTileConfig *tile)
 
bool overlapsTile (const DisplayTileConfig *tile)
 Returns true if this camera view area overlaps the specified tile. More...
 
void setEnabled (bool value)
 Set the camera enabled flag. More...
 
bool isEnabled ()
 Returns true if the frame is enabled, false otherwise. More...
 
virtual void clear (DrawContext &context)
 
virtual void endDraw (DrawContext &context)
 
virtual void beginDraw (DrawContext &context)
 
virtual void startFrame (const FrameInfo &frame)
 
virtual void finishFrame (const FrameInfo &frame)
 
int getCameraId ()
 
void setMask (uint mask)
 
uint getMask ()
 
void addListener (ICameraListener *listener)
 Gets or sets the camera listener. More...
 
void removeListener (ICameraListener *listener)
 
ICameraListenergetListener ()
 
void setCanvasTransform (const Vector3f &position, const Quaternion &orientation, const Vector3f scale)
 Update the canvas transform. Used to support dynamic immersive canvases. More...
 
const Vector3fgetCanvasPosition () const
 
const QuaterniongetCanvasOrientation () const
 
const Vector3fgetCanvasScale () const
 
void setSceneEnabled (bool value)
 Returns a view ray given an origin point in normalized coordinates. More...
 
bool isSceneEnabled ()
 
void setOverlayEnabled (bool value)
 When set to true, will draw all 2D overlay render passes for this camera. More...
 
bool isOverlayEnabled ()
 
void setCullingEnabled (bool value)
 When set to false, disables all culling for this camera. More...
 
bool isCullingEnabled ()
 
void setController (CameraController *value)
 Navigation management. More...
 
CameraControllergetController ()
 
bool isControllerEnabled ()
 
void setControllerEnabled (bool value)
 
void setHeadOffset (const Vector3f &value)
 Observer control. More...
 
void setHeadOrientation (const Quaternion &value)
 
const Vector3fgetHeadOffset ()
 
const QuaterniongetHeadOrientation ()
 
const AffineTransform3getHeadTransform ()
 
bool isTrackingEnabled ()
 
void setTrackingEnabled (bool value)
 
int getTrackerSourceId ()
 
void setTrackerSourceId (int value)
 
int getTrackerUserId ()
 Sets the tracker user id. More...
 
void setTrackerUserId (int value)
 
void setEyeSeparation (float value)
 
float getEyeSeparation ()
 
const Vector2fgetViewPosition ()
 View management. More...
 
void setViewPosition (float x, float y)
 
const Vector2fgetViewSize ()
 Gets the size of the view generated by this camera on the global canvas, in normalized coordinates. More...
 
void setViewSize (float width, float height)
 
const ColorgetBackgroundColor ()
 Frame buffer clear. More...
 
void setBackgroundColor (const Color &value)
 
void clearColor (bool enabled)
 
bool isClearColorEnabled ()
 
void clearDepth (bool enabled)
 
bool isClearDepthEnabled ()
 
void queueFrameDraw ()
 On-demand drawing. More...
 
void setMaxFps (float fps)
 Set the maximum fps that this camera will render at. More...
 
float getMaxFps ()
 
Vector3f localToWorldPosition (const Vector3f &position)
 DEPRECATED. More...
 
Quaternion localToWorldOrientation (const Quaternion &orientation)
 
Vector3f worldToLocalPosition (const Vector3f &position)
 
- Public Member Functions inherited from omega::SceneNode
 SceneNode (Engine *server)
 
 SceneNode (Engine *server, const String &name)
 
EnginegetEngine ()
 
bool hit (const Ray &ray, Vector3f *hitPoint, HitType type)
 Hit test. More...
 
void update (const UpdateContext &context)
 Invoked the update function for all node components on this node and down in the hierarchy. More...
 
virtual void update (bool updateChildren, bool parentHasChanged)
 
virtual void needUpdate (bool forceParentUpdate=true)
 To be called in the event of transform changes to this node that require it's recalculation. More...
 
void setTag (const String &value)
 
const StringgetTag ()
 
void addComponent (NodeComponent *o)
 
int getNumComponents ()
 
void removeComponent (NodeComponent *o)
 
bool isSelectable ()
 
void setSelectable (bool value)
 
void setVisible (bool value)
 Sets this node visibility. More...
 
bool isVisible ()
 
void setChildrenVisible (bool value)
 
void setSelected (bool value)
 
bool isSelected ()
 
bool isAttachedToScene ()
 
const AlignedBox3getBoundingBox ()
 
const SpheregetBoundingSphere ()
 
const Vector3fgetBoundMinimum ()
 
const Vector3fgetBoundMaximum ()
 
const Vector3fgetBoundCenter ()
 
float getBoundRadius ()
 
void requestBoundingBoxUpdate ()
 Force an update of the bounding box for this node. More...
 
void addListener (SceneNodeListener *listener)
 
void removeListener (SceneNodeListener *listener)
 
void setFacingCamera (Camera *cam)
 Billboard mode. More...
 
CameragetFacingCamera ()
 
void setFacingCameraFixedY (bool value)
 When set to true, Y axis for nodes facing camera will be fixed to the world Y axis. More...
 
bool isFacingCameraFixedY ()
 
void followTrackable (int trackableId)
 Trackable object. More...
 
void setFollowOffset (const Vector3f &offset, const Quaternion &ooffset)
 
TrackedObjectgetTracker ()
 
void unfollow ()
 
void setFlag (uint bit)
 Node flags. More...
 
void unsetFlag (uint bit)
 
bool isFlagSet (uint bit)
 
- Public Member Functions inherited from omega::Node
 Node ()
 Constructor, should only be called by parent, not directly. More...
 
 Node (const String &name)
 Constructor, should only be called by parent, not directly. More...
 
virtual ~Node ()
 
const StringgetName (void) const
 Returns the name of the node. More...
 
virtual NodegetParent (void) const
 Gets this node's parent (NULL if this is the root). More...
 
virtual const QuaterniongetOrientation () const
 Returns a quaternion representing the nodes orientation. More...
 
virtual void setOrientation (const Quaternion &q)
 Sets the orientation of this node via a quaternion. More...
 
virtual void setOrientation (float w, float x, float y, float z)
 Sets the orientation of this node via quaternion parameters. More...
 
virtual void resetOrientation (void)
 Resets the nodes orientation (local axes as world axes, no rotation). More...
 
virtual void setPosition (const Vector3f &pos)
 Sets the position of the node relative to it's parent. More...
 
virtual void setPosition (float x, float y, float z)
 Sets the position of the node relative to it's parent. More...
 
virtual const Vector3fgetPosition (void) const
 Gets the position of the node relative to it's parent. More...
 
virtual void setScale (const Vector3f &scale)
 Sets the scaling factor applied to this node. More...
 
virtual void setScale (float x, float y, float z)
 Sets the scaling factor applied to this node. More...
 
virtual const Vector3fgetScale (void) const
 Gets the scaling factor of this node. More...
 
virtual void setInheritOrientation (bool inherit)
 Tells the node whether it should inherit orientation from it's parent node. More...
 
virtual bool getInheritOrientation (void) const
 Returns true if this node is affected by orientation applied to the parent node. More...
 
virtual void setInheritScale (bool inherit)
 Tells the node whether it should inherit scaling factors from it's parent node. More...
 
virtual bool getInheritScale (void) const
 Returns true if this node is affected by scaling factors applied to the parent node. More...
 
virtual void scale (const Vector3f &scale)
 Scales the node, combining it's current scale with the passed in scaling factor. More...
 
virtual void scale (float x, float y, float z)
 Scales the node, combining it's current scale with the passed in scaling factor. More...
 
virtual void translate (const Vector3f &d, TransformSpace relativeTo=TransformParent)
 Moves the node along the Cartesian axes. More...
 
virtual void translate (float x, float y, float z, TransformSpace relativeTo=TransformParent)
 Moves the node along the Cartesian axes. More...
 
virtual void translate (const Matrix3f &axes, const Vector3f &move, TransformSpace relativeTo=TransformParent)
 Moves the node along arbitrary axes. More...
 
virtual void translate (const Matrix3f &axes, float x, float y, float z, TransformSpace relativeTo=TransformParent)
 Moves the node along arbitrary axes. More...
 
virtual void roll (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Z-axis. More...
 
void rollDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Z-axis, The angle is specified in degrees. More...
 
virtual void pitch (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the X-axis. More...
 
virtual void pitchDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the X-axis, The angle is specified in degrees. More...
 
virtual void yaw (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Y-axis. More...
 
virtual void yawDeg (const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around the Y-axis, The angle is specified in degrees. More...
 
virtual void rotate (const Vector3f &axis, const float &angle, TransformSpace relativeTo=TransformLocal)
 Rotate the node around an arbitrary axis. More...
 
virtual void rotate (const Quaternion &q, TransformSpace relativeTo=TransformLocal)
 Rotate the node around an aritrary axis using a Quarternion. More...
 
virtual Matrix3f getLocalAxes (void) const
 Gets a matrix whose columns are the local axes based on the nodes orientation relative to it's parent. More...
 
virtual void addChild (Node *child)
 Adds a (precreated) child scene node to this node. More...
 
virtual unsigned short numChildren (void) const
 Reports the number of child nodes under this one. More...
 
virtual NodegetChild (unsigned short index) const
 Gets a pointer to a child node. More...
 
virtual NodegetChild (const String &name) const
 Gets a pointer to a named child node. More...
 
virtual void removeChild (unsigned short index)
 Drops the specified child from this node. More...
 
virtual void removeChild (Node *child)
 Drops the specified child from this node. More...
 
virtual void removeChild (const String &name)
 Drops the named child from this node. More...
 
virtual void removeAllChildren (void)
 Removes all child Nodes attached to this node. More...
 
const List< Node * > & getChildren () const
 #PYPI Returns the list of children of this node More...
 
virtual void _setDerivedPosition (const Vector3f &pos)
 Sets the final world position of the node directly. More...
 
virtual void _setDerivedOrientation (const Quaternion &q)
 Sets the final world orientation of the node directly. More...
 
virtual const QuaterniongetDerivedOrientation (void) const
 Gets the orientation of the node as derived from all parents. More...
 
virtual const Vector3fgetDerivedPosition (void) const
 Gets the position of the node as derived from all parents. More...
 
virtual const Vector3fgetDerivedScale (void) const
 Gets the scaling factor of the node as derived from all parents. More...
 
virtual const AffineTransform3getFullTransform (void) const
 Gets the full transformation matrix for this node. More...
 
virtual Vector3f convertWorldToLocalPosition (const Vector3f &worldPos)
 Gets the local position, relative to this node, of the given world-space position. More...
 
virtual Vector3f convertLocalToWorldPosition (const Vector3f &localPos)
 Gets the world position of a point in the node local space useful for simple transforms that don't require a child node. More...
 
virtual Quaternion convertWorldToLocalOrientation (const Quaternion &worldOrientation)
 Gets the local orientation, relative to this node, of the given world-space orientation. More...
 
virtual Quaternion convertLocalToWorldOrientation (const Quaternion &localOrientation)
 Gets the world orientation of an orientation in the node local space useful for simple transforms that don't require a child node. More...
 
virtual void requestUpdate (Node *child, bool forceParentUpdate=false)
 Called by children to notify their parent that they need an update. More...
 
virtual void cancelUpdate (Node *child)
 Called by children to notify their parent that they no longer need an update. More...
 
void * getUserData ()
 
void setUserData (void *data)
 
void setName (const String &name)
 
bool isUpdateNeeded ()
 
- Public Member Functions inherited from omicron::ReferenceType
 ReferenceType ()
 
virtual ~ReferenceType ()
 
void ref ()
 
void unref ()
 
long refCount ()
 

Protected Member Functions

void updateTraversal (const UpdateContext &context)
 
void updateTransforms (DrawContext &ctx)
 Updates the specified draw context, computing an off-axis projection based on the tile and active eye in the draw context. More...
 
virtual void updateFromParent (void) const
 Class-specific implementation of updateFromParent. More...
 
- Protected Member Functions inherited from omega::SceneNode
virtual void setParent (Node *parent)
 Only available internally - notification of parent. More...
 
void onAttachedToScene ()
 
void onDetachedFromScene ()
 

Additional Inherited Members

- Static Public Member Functions inherited from omega::SceneNode
static SceneNodecreate (const String &name)
 
- Static Public Member Functions inherited from omicron::ReferenceType
static void printObjCounts ()
 
- Protected Types inherited from omega::Node
typedef std::set< Node * > ChildUpdateSet
 
- Protected Attributes inherited from omega::Node
NodemParent
 Pointer to parent node. More...
 
ChildNodeMap mChildren
 Collection of pointers to direct children; hashmap for efficiency. More...
 
List< Node * > mChildrenList
 
ChildUpdateSet mChildrenToUpdate
 List of children which need updating, used if self is not out of date but children are. More...
 
bool mNeedParentUpdate
 Flag to indicate own transform from parent is out of date. More...
 
bool mNeedChildUpdate
 Flag indicating that all children need to be updated. More...
 
bool mParentNotified
 Flag indicating that parent has been notified about update request. More...
 
bool mQueuedForUpdate
 Flag indicating that the node has been queued for update. More...
 
String mName
 Friendly name of this node, can be automatically generated if you don't care. More...
 
Quaternion mOrientation
 Stores the orientation of the node relative to it's parent. More...
 
Vector3f mPosition
 Stores the position/translation of the node relative to its parent. More...
 
Vector3f mScale
 Stores the scaling factor applied to this node. More...
 
bool mInheritOrientation
 Stores whether this node inherits orientation from it's parent. More...
 
bool mInheritScale
 Stores whether this node inherits scale from it's parent. More...
 
void * myUserData
 
Quaternion mDerivedOrientation
 Cached combined orientation. More...
 
Vector3f mDerivedPosition
 Cached combined position. More...
 
Vector3f mDerivedScale
 Cached combined scale. More...
 
AffineTransform3 mCachedTransform
 Cached derived transform as a 4x4 matrix. More...
 
bool mCachedTransformOutOfDate
 
- Static Protected Attributes inherited from omega::Node
static NameGenerator msNameGenerator
 Incremented count for next name extension. More...
 
- Static Protected Attributes inherited from omicron::ReferenceType
static List< ReferenceType * > mysObjList
 

Detailed Description

The Camera class handles information about a view transformation, head tracking and optional target buffers for off screen rendering A camera can have a controller that is used to implement a navigation technique.

+ Inheritance diagram for omega::Camera:

Member Enumeration Documentation

Enumerator
DrawScene 
DrawOverlay 
CullingEnabled 
DefaultFlags 
Enumerator
DefaultRenderPassMask 
AllRenderPassMask 

Constructor & Destructor Documentation

omega::Camera::Camera ( Engine engine,
uint  flags = DefaultFlags 
)

Member Function Documentation

void omega::Camera::addListener ( ICameraListener listener)
inline

Gets or sets the camera listener.

Currently, only one listener is supported. Setting an additional listener will replace the current one.

virtual void omega::Camera::beginDraw ( DrawContext context)
virtual
virtual void omega::Camera::clear ( DrawContext context)
virtual
void omega::Camera::clearColor ( bool  enabled)
inline
void omega::Camera::clearDepth ( bool  enabled)
inline
virtual void omega::Camera::endDraw ( DrawContext context)
virtual
virtual void omega::Camera::finishFrame ( const FrameInfo frame)
virtual
void omega::Camera::focusOn ( SceneNode node)
const Color& omega::Camera::getBackgroundColor ( )
inline

Frame buffer clear.

int omega::Camera::getCameraId ( )
inline
const Quaternion & omega::Camera::getCanvasOrientation ( ) const
inline
const Vector3f & omega::Camera::getCanvasPosition ( ) const
inline
const Vector3f & omega::Camera::getCanvasScale ( ) const
inline
CameraController* omega::Camera::getController ( )
inline
DisplayTileConfig * omega::Camera::getCustomTileConfig ( )
inline

Returns a custom tile configuration for secondary cameras that do no use default display tiles during rendering.

float omega::Camera::getEyeSeparation ( )
inline
float omega::Camera::getFarZ ( )
inline
const Vector3f& omega::Camera::getHeadOffset ( )
inline
const Quaternion& omega::Camera::getHeadOrientation ( )
inline
const AffineTransform3 & omega::Camera::getHeadTransform ( )
inline
ICameraListener * omega::Camera::getListener ( )
inline
uint omega::Camera::getMask ( )
inline
float omega::Camera::getMaxFps ( )
inline
float omega::Camera::getNearZ ( )
inline
CameraOutput* omega::Camera::getOutput ( uint  contextId)
int omega::Camera::getTrackerSourceId ( )
inline
int omega::Camera::getTrackerUserId ( )
inline

Sets the tracker user id.

Remarks
If a tracker user ID is set (!= -1) and tracking is enabled this camera will ignore the tracker source id, and use any tracker source with the right user id. The camera controller may also process imput based on user id instead of source id. This is useful in supporting dynamic User-application control.
const Vector2f& omega::Camera::getViewPosition ( )
inline

View management.

Gets the position of the view generated by this camera on the global canvas, in normalized coordinates. Default is (0,0)

const Vector2f& omega::Camera::getViewSize ( )
inline

Gets the size of the view generated by this camera on the global canvas, in normalized coordinates.

Default is (1,1)

const AffineTransform3 & omega::Camera::getViewTransform ( )
inline
virtual void omega::Camera::handleEvent ( const Event evt)
virtual
bool omega::Camera::isClearColorEnabled ( )
inline
bool omega::Camera::isClearDepthEnabled ( )
inline
bool omega::Camera::isControllerEnabled ( )
inline
bool omega::Camera::isCullingEnabled ( )
inline
bool omega::Camera::isEnabled ( )
inline

Returns true if the frame is enabled, false otherwise.

Remarks
even if the camera is enabled, this method can return false if on-demand frame drawing is on and the camera is not currently scheduled to draw a frame
virtual bool omega::Camera::isEnabledInContext ( const DrawContext context)
virtual

Returns true if this camera is enabled in the specified draw context.

virtual bool omega::Camera::isEnabledInContext ( DrawContext::Task  task,
const DisplayTileConfig tile 
)
virtual
bool omega::Camera::isOverlayEnabled ( )
inline
bool omega::Camera::isSceneEnabled ( )
inline
bool omega::Camera::isTrackingEnabled ( )
inline
Quaternion omega::Camera::localToWorldOrientation ( const Quaternion orientation)
Vector3f omega::Camera::localToWorldPosition ( const Vector3f position)

DEPRECATED.

virtual void omega::Camera::lookAt ( const Vector3f position,
const Vector3f upVector 
)
virtual

Rotate the node to make its positive Z axis point toward the specified position.

Reimplemented from omega::Node.

bool omega::Camera::overlapsTile ( const DisplayTileConfig tile)

Returns true if this camera view area overlaps the specified tile.

void omega::Camera::queueFrameDraw ( )
inline

On-demand drawing.

Queues one frame for drawing. Use this to force a frame draw when MaxFps is set to 0.

void omega::Camera::removeListener ( ICameraListener listener)
inline
void omega::Camera::setBackgroundColor ( const Color value)
inline
void omega::Camera::setCanvasTransform ( const Vector3f position,
const Quaternion orientation,
const Vector3f  scale 
)

Update the canvas transform. Used to support dynamic immersive canvases.

void omega::Camera::setController ( CameraController value)

Navigation management.

void omega::Camera::setControllerEnabled ( bool  value)
inline
void omega::Camera::setCullingEnabled ( bool  value)
inline

When set to false, disables all culling for this camera.

All drawables will attempt drawing, even the ones that are outside of this camera frustum. This is useful to force drawing of all objects when we want to use vertex shaders with custom projections. By default, culling is enabled.

void omega::Camera::setEnabled ( bool  value)
inline

Set the camera enabled flag.

If a camera is disabled it will never render. If it's enabled it will still be checked agains the active draw context.

void omega::Camera::setEyeSeparation ( float  value)
inline
void omega::Camera::setHeadOffset ( const Vector3f value)
inline

Observer control.

void omega::Camera::setHeadOrientation ( const Quaternion value)
inline
void omega::Camera::setMask ( uint  mask)
inline
void omega::Camera::setMaxFps ( float  fps)
inline

Set the maximum fps that this camera will render at.

Use 0 to stop camera drawing and use queueFrameDraw to draw frames on-demand. Use -1 to disable the fps cap and let this camera draw at the maximum renderer speed (typically 60fps)

void omega::Camera::setNearFarZ ( float  near,
float  far 
)
inline
void omega::Camera::setOverlayEnabled ( bool  value)
inline

When set to true, will draw all 2D overlay render passes for this camera.

Set to true by default.

void omega::Camera::setPitchYawRoll ( const Vector3f yawPitchRoll)
inline
void omega::Camera::setSceneEnabled ( bool  value)
inline

Returns a view ray given an origin point in normalized coordinates.

Parameters
normalizedPoint- the origin point for the ray in normalized ([0, 1]) coordinates Camera flags When set to true, will draw all 3D scene render passes for this camera. Set to true by default.
void omega::Camera::setTrackerSourceId ( int  value)
inline
void omega::Camera::setTrackerUserId ( int  value)
inline
void omega::Camera::setTrackingEnabled ( bool  value)
inline
virtual void omega::Camera::setup ( Setting s)
virtual
void omega::Camera::setViewPosition ( float  x,
float  y 
)
inline
void omega::Camera::setViewSize ( float  width,
float  height 
)
inline
virtual void omega::Camera::startFrame ( const FrameInfo frame)
virtual
virtual void omega::Camera::updateFromParent ( void  ) const
protectedvirtual

Class-specific implementation of updateFromParent.

Remarks
Splitting the implementation of the update away from the update call itself allows the detail to be overridden without disrupting the general sequence of updateFromParent (e.g. raising events)

Reimplemented from omega::Node.

void omega::Camera::updateTransforms ( DrawContext ctx)
protected

Updates the specified draw context, computing an off-axis projection based on the tile and active eye in the draw context.

Used by beginDraw.

void omega::Camera::updateTraversal ( const UpdateContext context)
protectedvirtual

Reimplemented from omega::SceneNode.

Vector3f omega::Camera::worldToLocalPosition ( const Vector3f position)

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