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

sglSphericalTransform Class Template Reference

#include <sglSphericalTransform.hpp>

Inheritance diagram for sglSphericalTransform::

sglTransform sglGroup sglNode sglObject sgluSphericalTransform List of all members.

Public Types

enum  ModeEnum {
  eX_UP,
  eY_UP,
  eZ_UP
}

Public Methods

 sglSphericalTransform ()
virtual ~sglSphericalTransform ()
void setMode (ModeEnum mode)
ModeEnum getMode () const
virtual void reset ()
void updateAzimuth (T delta_azimuth)
void updateElevation (T delta_elevation)
void updateRadius (T delta_radius)
void updateCOI (const sglVec3< T > &delta_coi)
void updateCOI (T delta_x, T delta_y, T delta_z)
getAzimuth () const
void setAzimuth (T new_azimuth)
getElevation () const
void setElevation (T new_elevation)
getRadius () const
void setRadius (T new_radius)
const sglVec3<T>& getCOI () const
void setCOI (const sglVec3< T > &pos_coi)
void setCOI (T x, T y, T z)
void computeMatrix ()
virtual sglNodeclone (unsigned int mode) const
virtual void printInfo (ostream &ostrm, const char *indent_spaces) const

Protected Attributes

ModeEnum m_mode
sglVec3<T> m_pos_coi
m_radius
m_elevation
m_sin_el
m_cos_el
m_azimuth
m_sin_az
m_cos_az
sglVec2<T> m_delta_pos

Detailed Description

template<class T> class sglSphericalTransform

This is a convenience subclass of sglTransform that restricted the motion to 3 DOF spherical motion consisting of rotations of azimuth (heading) and elevation (pitch), and translations of radius. An additional 3 DOF translation of the center of interest (COI) can move this "sphere" anywhere in 3-space. It rotates and translates the coordinate system while always keeping the z-axis of the new coordinate system pointing directly away from the origin of the previous system (if OpenGL's view is defined by the new coordinate system it will always look at the center of interest.

The user can select between three modes where any of the basic axes of the local coordinate system is considered "up". The azimuth angle rotates about this axes and can range from -pi to pi (values outside this range are wrapped around). The pitch angle rotates about the "right" vector and can range from -pi/2 to pi/2. Values outside this range will be clamped to this range. A radius of zero places the transformed coordinate system at the COI and positive values move it away from this point (a negative radius is clamped to zero).

After any changes to the variables, the user must call sglSphericalTransform::computeMatrix() to build the new transformation matrix and store it in the base class.

Example:

    sglSphericalTransformf *tx_node = new sglSphericalTransformf;
    tx_node->setMode(sglSphericalTransform::eY_UP); // y up
    tx_node->setCOI(-10.f, 0.f, 0.f);               // move out along -X axis
    tx_node->setAzimuth(M_PI*0.5f);                 // rotate "right"
    tx_node->setElevation(M_PI*0.25f);              // rotate "up"
    tx_node->setRadius(1000.f);                     // move out
    tx_node->computeMatrix();                       // compute tx matrix.

    tx_node->addChild(...);

Definition at line 71 of file sglSphericalTransform.hpp.


Member Enumeration Documentation

template<class T>
enum sglSphericalTransform<T>::ModeEnum
 

Used to specify which vector is "up".

Definition at line 75 of file sglSphericalTransform.hpp.


Constructor & Destructor Documentation

template<class T>
sglSphericalTransform<T>::sglSphericalTransform<T> ( )
 

default constructor: initializes all values to zero (equals identity).

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

virtual destructor.

Definition at line 81 of file sglSphericalTransform.hpp.


Member Function Documentation

template<class T>
void sglSphericalTransform<T>::setMode ( ModeEnum mode ) [inline]
 

Set the "up" axis.

Parameters:
mode   One of the three ModeEnums (for each axis). The default is eZ_UP.

Definition at line 87 of file sglSphericalTransform.hpp.

template<class T>
ModeEnum sglSphericalTransform<T>::getMode ( ) const [inline]
 

Query the current "up" axis.

Returns:
The ModeEnum corresponding to the current up axis.

Definition at line 92 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::reset ( ) [virtual]
 

Reset this transform back to identity (all zeroes).

Reimplemented in sgluSphericalTransform.

Referenced by sgluSphericalTransform::reset().

template<class T>
void sglSphericalTransform<T>::updateAzimuth ( T delta_azimuth ) [inline]
 

Add a delta to the current azimuth (and wrap around if necessary).

Parameters:
delta_azimuth   The angle to add to the current azimuth (radians).

Definition at line 100 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::updateElevation ( T delta_elevation ) [inline]
 

Add a delta to the current elevation (and clamp if necessary).

Parameters:
delta_elevation   The angle to add to the current elevation (radians).

Definition at line 109 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::updateRadius ( T delta_radius ) [inline]
 

Add a delta to the current radius (and clamp if necessary).

Parameters:
delta_radius   The angle to add to the current radius.

Definition at line 117 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::updateCOI ( const sglVec3< T > & delta_coi ) [inline]
 

Add a 3D delta vector to the current center of interest position.

Parameters:
delta_coi   The change vector.

Definition at line 125 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::updateCOI ( T delta_x,
T delta_y,
T delta_z ) [inline]
 

Add a 3D delta to the current center of interest position.

Parameters:
x   X-component of the change vector.
y   Y-component of the change vector.
z   Z-component of the change vector.

Definition at line 135 of file sglSphericalTransform.hpp.

template<class T>
T sglSphericalTransform<T>::getAzimuth ( ) const [inline]
 

Query the current azimuth angle.

Returns:
The current azimuth in radians.

Definition at line 143 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::setAzimuth ( T new_azimuth )
 

Set the current azimuth angle.

Parameters:
new_azimuth   The new azimuth angle in radians. Values that are out of range will be wrapped around.

Referenced by updateAzimuth().

template<class T>
T sglSphericalTransform<T>::getElevation ( ) const [inline]
 

Query the current elevation angle.

Returns:
The current elevation in radians.

Definition at line 154 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::setElevation ( T new_elevation )
 

Set the current elevation angle.

Parameters:
new_elevation   The new elevation angle in radians. Values that are out of range will be clamped in the range -pi/2 to pi/2.

Referenced by updateElevation().

template<class T>
T sglSphericalTransform<T>::getRadius ( ) const [inline]
 

Query the current radius.

Returns:
The current radius.

Definition at line 165 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::setRadius ( T new_radius )
 

Set the current radius.

Parameters:
new_radius   The new radius. Values less than zero will be clamped to zero.

Referenced by updateRadius().

template<class T>
const sglVec3< T > & sglSphericalTransform<T>::getCOI ( ) const [inline]
 

Query the current center of interest position.

Returns:
The current COI (as a sglVec3).

Definition at line 176 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::setCOI ( const sglVec3< T > & pos_coi ) [inline]
 

Set the current COI as an sglVec3.

Parameters:
pos_coi   The new COI.

Definition at line 181 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::setCOI ( T x,
T y,
T z ) [inline]
 

Set the current COI as three scalars.

Parameters:
x   X-component of the new COI.
y   Y-component of the new COI.
z   Z-component of the new COI.

Definition at line 188 of file sglSphericalTransform.hpp.

template<class T>
void sglSphericalTransform<T>::computeMatrix ( )
 

Must be called after any changes so that the new transformation matrix is computed.

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

template<class T>
virtual void sglSphericalTransform<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 sglTransform.


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