Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglViewPlatform Class Reference

#include <sglViewPlatform.hpp>

Inheritance diagram for sglViewPlatform::

sglNode sglObject List of all members.

Public Methods

 sglViewPlatform (sglCamera &camera)
virtual ~sglViewPlatform ()
void setEnableZUp (bool on)
bool getEnableZUp () const
void computeViewMatrix (sglMat4f &curr_mat) const
void computeViewMatrix (sglMat4d &curr_mat) const
sglCameragetCamera () const
void setCamera (sglCamera &camera)
virtual sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

void computeBound ()
virtual void cull (sglCull< float > &, unsigned int) const
virtual void cull (sglCull< double > &, unsigned int) const
void copyTo (sglViewPlatform *dst, unsigned int mode) const

Detailed Description

sglViewPlatform is a placeholder in the scene graph that can be used to define the position and orientation of the camera. This class must be constructed with a reference to an sglCamera subclass to define the view frustum. This camera can subsequently be changed with a call to setCamera(). The sglViewPlatform::computeViewMatrix() member function (overloaded for single or double precision) traverses the scene graph from this node upward to the root of the tree while computing the matrix that is needed by the sglScene::cull() functions. If multiple paths to the root of the tree are encountered (i.e. multiple parents), an arbitrary selection is made (generally the path using the parents with the 0 index). An overloaded version of sglScene::cull(..) can take an sglViewPlatform reference which, in turn, will call the computeViewMatrix(..) function.

By default, the view matrix is computed assuming the OpenGL convention that the camera looks down the -Z axis with the +X axis to the right and the +Y axis up. A convenience mode for Performer users (and others?) can be enabled by calling sglViewPlatform::enableZUp(true). This will cause the computeViewMatrix function to return a matrix that has the camera looking down the +Y axis, with +Z up and +X to the right.

The following example attaches the view platform to an sglTransform node which will be used to move the camera around. Also shown in this example is the method for defining the camera projection (view frustum) parameters, associating them with the view platform, and using it in the cull traversal:

Example:

   sglCullf trav_state;

   // used to move the camera
   sgluSphericalTransformf view_trans = new sgluSphericalTransformf;

   sglPerspectiveCamera *view_camera = new sglPerspectiveCamera;
   view_camera->setFOV(M_PI*0.25, (double)win_x/(double)win_y, 1.0, 200.0);

   sglViewPlatform *view_platform = new sglViewPlatform(*view_camera);
   view_platform->setEnableZUp(true);
   view_trans->addChild(view_platform);
        :
   root->cull(trav_state,                          //  sglScene::cull(..)
              ...,
              *view_platform,
              ...);

   (view_platform->getCamera()).applyProjection(); // setup projection matrix

   trav_state.draw();                              // draw the geometry

Definition at line 85 of file sglViewPlatform.hpp.


Constructor & Destructor Documentation

sglViewPlatform::sglViewPlatform ( sglCamera & camera )
 

Constructor

Parameters:
camera   Reference to an sglCamera

sglViewPlatform::~sglViewPlatform ( ) [virtual]
 

virtual destructor. Will dereference but not delete camera object.


Member Function Documentation

void sglViewPlatform::setEnableZUp ( bool on ) [inline]
 

This function enables the "Performer/PLIB" compatibility mode that assumes the camera looks along the y-axis (x-axis to the right) Otherwise it assumes the default OpenGL mode where the camera looks along the negative z-axis.

Parameters:
on   If true then enable the compatibility mode.

Definition at line 102 of file sglViewPlatform.hpp.

bool sglViewPlatform::getEnableZUp ( ) const [inline]
 

Query the current compatibility mode.

Returns:
True if compatibility mode is on.

Definition at line 107 of file sglViewPlatform.hpp.

void sglViewPlatform::computeViewMatrix ( sglMat4f & curr_mat ) const
 

Compute a single precision transform to root of tree this node is connected to. Since this node is the first in the progression these functions initialize the matrix.

Parameters:
curr_mat   Reference to the matrix that will contain the result on return from this function.

void sglViewPlatform::computeViewMatrix ( sglMat4d & curr_mat ) const
 

Compute a double precision transform to root of tree this node is connected to. Since this node is the first in the progression these functions initialize the matrix.

Parameters:
curr_mat   Reference to the matrix that will contain the result on return from this function.

sglCamera & sglViewPlatform::getCamera ( ) const [inline]
 

Query the current sglCamera.

Returns:
A reference to the sglCamera object being used by this class.

Definition at line 128 of file sglViewPlatform.hpp.

void sglViewPlatform::setCamera ( sglCamera & camera )
 

Switch the camera being used by this node. The old camera object is dereferenced but if the reference count goes to zero it will not be deleted. The reference count of the new camera will be incremented.

Parameters:
camera   Reference to an sglCamera (subclass) object.

virtual sglNode* sglViewPlatform::clone ( unsigned int mode ) const [virtual]
 

Make a copy of the scenegraph rooted at this node.

Parameters:
mode   Bit masks to control the behaviour of the clone. These are OR-ed together from the mode values in sglObject::CloneModeEnum.
Returns:
Pointer to root of cloned scene graph.

Reimplemented from sglNode.

virtual void sglViewPlatform::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]
 

Output the state of this node to the specified ostream.

Parameters:
ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglNode.

void sglViewPlatform::cull ( sglCull< float > & trav_state,
unsigned int cull_flags ) const [inline, protected, virtual]
 

The single precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.

Parameters:
trav_state   The single precision traversal state that collects all the state and geometry information that passes the cull.
cull_flags   Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0.

Reimplemented from sglNode.

Definition at line 147 of file sglViewPlatform.hpp.

void sglViewPlatform::cull ( sglCull< double > & trav_state,
unsigned int cull_flags ) const [inline, protected, virtual]
 

The double precision cull traversal function that culls out subgraphs that do not lie in the view frustum (stored in the sglCull parameter). Subclasses must implement this function. The entry point for user-friendly culling is in the sglScene class.

Parameters:
trav_state   The single precision traversal state that collects all the state and geometry information that passes the cull.
cull_flags   Bit flags that indicate which planes of the view frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free drawing can be accomplished with cull_flags = 0.

Reimplemented from sglNode.

Definition at line 149 of file sglViewPlatform.hpp.


The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:11 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001