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

sglTransform Class Template Reference

#include <sglTransform.hpp>

Inheritance diagram for sglTransform::

sglGroup sglNode sglObject sglSphericalTransform sgluSphericalTransform List of all members.

Public Methods

 sglTransform ()
virtual ~sglTransform ()
void loadIdentity ()
void setTranslation (T x, T y, T z)
void setRotation (T angle, T x, T y, T z)
void setRotation (T h, T p, T r)
void setMatrix (const sglMat4< T > &m)
const sglMat4<T>& getMatrix () const
virtual sglBound::IntersectResultEnum intersect (sglIntersectf &isector) const
virtual sglBound::IntersectResultEnum intersect (sglIntersectd &isector) const
virtual void pick (sglPickf &pick_state, unsigned int cull_flags) const
virtual void pick (sglPickd &pick_state, unsigned int cull_flags) const
virtual void computeTxToParent (sglMat4f &curr_mat) const
virtual void computeTxToParent (sglMat4d &curr_mat) const
virtual sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

virtual void computeBound ()
virtual void cull (sglCull< float > &trav_state, unsigned int cull_flags) const
virtual void cull (sglCull< double > &trav_state, unsigned int cull_flags) const
void checkForIdentity ()
void checkForDeformation ()
void copyTo (sglTransform *dst, unsigned int mode) const

Protected Attributes

sglMat4<T> m_matrix
sglMat4<T> m_inv_mat
bool m_is_ident
bool m_rescale
bool m_normalize

Detailed Description

template<class T> class sglTransform

With the matrix defined within this node, the model view matrix maintained within the various traversals is transformed (multiplied) before visiting the children. This node contains functions to define affine(?) 3D transformations that contain translation, rotation, and uniform scale. By changing the matrix within this node, you can change the position, orientation and size of all the children below. Currently the only way to specify the scale is by sending a matrix with scale into the setMatrix() member function. Note that even non-affine transformations can be specified using the setMatrix() member function, but I don't currently guarantee correct results (in particular the intersect traversal does not perform correctly in the presence of non-uniform scale).

Note that the sglTransform class is a templated class which can allow this to be instantiated with either single or double precision. Two typedefs, sglTransformf and sglTransformd, are added for convenience. The behaviour when using other templated types is undefined.

Example:

   sglTransformf *dcs_node = new sglTransformf;  // or new sglTransform<float>;
   dcs_node->setTranslation(0.0f, 0.0f, 25.0f);
   dcs_node->setRotation(M_PI, 1.0f, 0.0f, 0.0f);

Todo:
Add support for non-uniform scale (currently intersect traversal does not work in its presence).

Definition at line 67 of file sglTransform.hpp.


Constructor & Destructor Documentation

template<class T>
sglTransform<T>::sglTransform<T> ( ) [inline]
 

default constructor - creates an identity transform.

Definition at line 71 of file sglTransform.hpp.

template<class T>
sglTransform<T>::~sglTransform<T> ( ) [inline, virtual]
 

virtual destructor.

Definition at line 73 of file sglTransform.hpp.


Member Function Documentation

template<class T>
void sglTransform<T>::loadIdentity ( )
 

Reset this node to an identity transform.

Referenced by sglTransform().

template<class T>
void sglTransform<T>::setTranslation ( T x,
T y,
T z )
 

Set the translation part of the transform (affects the 4th row of the matrix only).

Parameters:
x   Translation along the x axis.
y   Translation along the y axis.
z   Translation along the z axis.

template<class T>
void sglTransform<T>::setRotation ( T angle,
T x,
T y,
T z )
 

Set the rotation portion of the transform (affects the upper left 3x3 portion of the matrix only) by specifying and angle and axis. The axis does not have to be normalized.

Parameters:
angle   The angle in radians.
x   X component of the axis.
y   Y component of the axis.
z   Z component of the axis.

template<class T>
void sglTransform<T>::setRotation ( T h,
T p,
T r )
 

Set the rotation portion of the transform (affects the upper left 3x3 portion of the matrix only) by specifying euler angles.

Parameters:
h   Heading angle is the rotation about the z-axis.
p   Pitch angle is the rotation about the once-rotated x-axis.
r   Roll angle is the rotation about the twice-rotated y-axis.

template<class T>
void sglTransform<T>::setMatrix ( const sglMat4< T > & m )
 

Set the transform matrix directly. There is currently no error checking to see if non-supported matrix types are set here. It should be non-singular though.

Parameters:
m   Homogenous transformation matrix in OpenGL format where the translation vector appears in the fourth row.

template<class T>
const sglMat4< T > & sglTransform<T>::getMatrix ( ) const [inline]
 

Get the current transform matrix.

Returns:
Current matrix.

Definition at line 115 of file sglTransform.hpp.

template<class T>
virtual sglBound::IntersectResultEnum sglTransform<T>::intersect ( sglIntersectf & isector ) const [virtual]
 

The single precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.

Parameters:
isector   A reference to a single precision intersection state

Reimplemented from sglGroup.

template<class T>
virtual sglBound::IntersectResultEnum sglTransform<T>::intersect ( sglIntersectd & isector ) const [virtual]
 

The double precision intersection traversal function which returns the closest object (bounding volume and/or triangle) that intersects with the given intersect segment.

Parameters:
isector   A reference to a double precision intersection state

Reimplemented from sglGroup.

template<class T>
virtual void sglTransform<T>::pick ( sglPickf & pick_state,
unsigned int cull_flags ) const [virtual]
 

The single precision pick traversal function which returns all objects that fall within the pick frustum.

Parameters:
pick_state   A reference to a single precision pick state.
cull_flags   Bit flags that indicate which planes of the pick frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free picking can be accomplished by setting this to 0.

Reimplemented from sglGroup.

template<class T>
virtual void sglTransform<T>::pick ( sglPickd & pick_state,
unsigned int cull_flags ) const [virtual]
 

The double precision pick traversal function which returns all objects that fall within the pick frustum.

Parameters:
pick_state   A reference to a double precision pick state.
cull_flags   Bit flags that indicate which planes of the pick frustum (polytope) still need to be tested to determine if bounding spheres and boxes lie within the frustum. Cull-free picking can be accomplished by setting this to 0.

Reimplemented from sglGroup.

template<class T>
virtual void sglTransform<T>::computeTxToParent ( sglMat4f & curr_mat ) const [virtual]
 

Compute a single precision transform to parent and append (via multiplication) the matrix passed in. This is part of an upward traversal, which most commonly begins with an sglViewPlatform and used for computing the position and orientation of said platform. This is the default implementation for all nodes that do not affect this matrix and therefore this function does nothing.

Parameters:
curr_mat   The current view matrix for nodes below this one.

Reimplemented from sglNode.

template<class T>
virtual void sglTransform<T>::computeTxToParent ( sglMat4d & curr_mat ) const [virtual]
 

Compute a double precision transform to parent and append (via multiplication) the matrix passed in. This is part of an upward traversal, which most commonly begins with an sglViewPlatform and used for computing the position and orientation of said platform. This is the default implementation for all nodes that do not affect this matrix and therefore this function does nothing.

Parameters:
curr_mat   The current view matrix for nodes below this one.

Reimplemented from sglNode.

template<class T>
virtual sglNode* sglTransform<T>::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 sglGroup.

Reimplemented in sglSphericalTransform.

template<class T>
virtual void sglTransform<T>::printInfo ( ostream & ostrm,
const char * indent_spaces ) 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 sglGroup.

Reimplemented in sglSphericalTransform.

template<class T>
virtual void sglTransform<T>::cull ( sglCull< float > & trav_state,
unsigned int cull_flags ) const [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 sglGroup.

template<class T>
virtual void sglTransform<T>::cull ( sglCull< double > & trav_state,
unsigned int cull_flags ) const [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 sglGroup.


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