Main Page   Class Hierarchy   Compound List   Compound Members  

qglviewer::AxisPlaneConstraint Class Reference

An abstract class for Frame constraints that use an axis or a plane. More...

Inherits qglviewer::Constraint.

Inherited by qglviewer::CameraConstraint, qglviewer::LocalConstraint, and qglviewer::WorldConstraint.

List of all members.

Public Types

enum  Type { FREE, PLANE, AXIS, FORBIDDEN }

Public Methods

 AxisPlaneConstraint ()
virtual ~AxisPlaneConstraint ()
Translation constraints
virtual void constrainTranslation (qglviewer::Vec &, Frame *const)=0
void setTranslationConstraint (const Type c, const qglviewer::Vec &dir)
void setTranslationConstraint (const Type c, const float x, const float y, const float z)
void setTranslationConstraintType (const Type c)
void setTranslationConstraintDir (const qglviewer::Vec &dir)
Type translationConstraintType () const
void getTranslationConstraintDir (float &x, float &y, float &z) const
qglviewer::Vec translationConstraintDir () const
Rotation constraints
virtual void constrainRotation (qglviewer::Quaternion &, Frame *const)=0
void setRotationConstraint (const Type c, const qglviewer::Vec &dir)
void setRotationConstraint (const Type c, const float x, const float y, const float z)
void setRotationConstraintType (const Type c)
void setRotationConstraintDir (const qglviewer::Vec &dir)
Type rotationConstraintType () const
void getRotationConstraintDir (float &x, float &y, float &z) const
qglviewer::Vec rotationConstraintDir () const


Detailed Description

An abstract class for Frame constraints that use an axis or a plane.

This class defines and implements a translation and a rotation constraint direction and type. The type is defined by the Type enum which could be extended in derived classes to define new constraint types.

Different implementations of this class are illustrated in the contrainedCamera and constrainedFrame examples.

Attention:
The Axis rotationnal constraint is implemented by projecting the rotation axis drection of the constrained axis. The constrain is hence satisfied, but unpleasant behavior may appear when a mouse ManipulatedFrame is used to move the frame (try the above examples to see what I mean). A solution would be to directly measure the rotation angle in screen coordinates, but that would imply to know the Camera associated to the viewer, so that we can compute the projected coordinates of the rotation center. This is the way the Camera screen Z axis rotation is implemented (see the mouse page for details). However, we chose not to fix this problem, as it would imply an extra Camera pointer in all the AxisPlaneConstraint derived classes (which the user should have to update depending on the used viewer in a multi-viewer application).


Member Enumeration Documentation

enum Type
 

The different types of translation and rotation constraints that are available. New derived classes can introduce their own enum for specific constraints.

Use setTranslationConstraint() and setRotationConstraint() to set constraints, translationConstraintType() and rotationConstraintType() to get the current constraint type.

Note:
See the warning section of the Detailed Description section for limitations on the AXIS rotationnal constraint.


Constructor & Destructor Documentation

AxisPlaneConstraint  
 

Translation and Rotation constraints are set to FREE.

virtual ~AxisPlaneConstraint   [inline, virtual]
 

Virtual empty destructor.


Member Function Documentation

virtual void constrainRotation qglviewer::Quaternion  ,
Frame   const
[pure virtual]
 

Default un-constrained rotation function. Desired rotation is expressed in local frame coordinate system. Try the constrainedFrame and constrainedCamera examples for an illustration.

Reimplemented from qglviewer::Constraint.

Implemented in qglviewer::LocalConstraint.

virtual void constrainTranslation qglviewer::Vec  ,
Frame   const
[pure virtual]
 

Default un-constrained translation function. Desired translation is expressed in local frame coordinate system. Try the constrainedFrame and constrainedCamera examples for an illustration.

Reimplemented from qglviewer::Constraint.

Implemented in qglviewer::LocalConstraint.

void getRotationConstraintDir float &    x,
float &    y,
float &    z
const
 

Same as getRotConstraintDir() but result is returned as floats.

void getTranslationConstraintDir float &    x,
float &    y,
float &    z
const
 

Same as getTransConstraintDir() but result is returned as floats.

qglviewer::Vec rotationConstraintDir   const [inline]
 

Returns the current direction of the rotation constraint. If rotationConstraintType() is FREE or FORBIDDEN, this value is undefined. dir is the plane normal or the axis direction, depending on the constraint. It is expressed in a different coordinate system depending on the derived class (WorldConstraint, CameraConstraint()...). This value can be changed with setRotationConstraint().

Type rotationConstraintType   const [inline]
 

Returns the current rotation constraint. Result is of type Type. The rotation constraint is set with setRotationConstraint().

void setRotationConstraint const Type    c,
const float    x,
const float    y,
const float    z
 

Same as setRotationConstraint(), but with float parameters.

void setRotationConstraint const Type    c,
const qglviewer::Vec   dir
 

Set possible constraints on the frame rotation. By default, the frame has no rotation constraint.

Type defines all the possible constraints.

Depending on the value of c, the frame frame will be FREE, will only be able to move around an AXIS, in a PLANE, or will not able to move at all (FORBIDDEN).

The axis and plane normal directions are expressed in different coordinates system, depending on the derived class (WorldConstraint, CameraConstraint...). dir is useless if c is FREE or FORBIDDEN.

Call Frame::setOrientation() or Frame::setRotation() before calling this method in order to define the relative constrained orientation of the frame.

The current constraint is given by rotationConstraint() and rotationConstraintDir(). The axis direction is undefined when the constraint is of type FREE or FORBIDDEN.

Attention:
The PLANE rotationnal constraint is not yet implemnented.

void setRotationConstraintDir const qglviewer::Vec   dir
 

Similar to setRotationConstraint(), but only set the direction.

void setRotationConstraintType const Type    c [inline]
 

Set the Type of the rotation constraint. See setRotationConstraint().

void setTranslationConstraint const Type    c,
const float    x,
const float    y,
const float    z
 

Same as setTranslationConstraint(), but with float parameters.

void setTranslationConstraint const Type    c,
const qglviewer::Vec   dir
 

Set possible constraints on the frame translation. By default, the frame has no translation constraint.

Type defines all the possible constraints. Depending on the value of c, the frame frame will be FREE, or will not be allowed to move out of a PLANE, or only along an AXIS, or not able to move at all (FORBIDDEN).

The plane is defined by its normal vector and the axis is defined by its direction, both expressed in a coordinate system that depends on the derived class (see translationConstraintDir()).

dir is not used if c is FREE or FORBIDDEN.

Call Frame::setPosition() or Frame::setTranslation() before calling any of this method in order to define the relative constrained position of the frame.

The current constraint is given by translationConstraintType() and translationConstraintDir().

void setTranslationConstraintDir const qglviewer::Vec   dir
 

Similar to setTranslationConstraint(), but only set the direction.

void setTranslationConstraintType const Type    c [inline]
 

Set the Type of the translation constraint. See setTranslationConstraint().

qglviewer::Vec translationConstraintDir   const [inline]
 

Returns the current direction of the translation constraint. If translationConstraintType() is FREE or FORBIDDEN, this value is undefined. dir is the plane normal or the axis direction, depending on the constraint type. It is expressed in different coordinate system, depending on the actual constraint class (camera for CameraConstraint, local for LocalConstraint, world for WorldConstraint, etc.) This value can be changed with setTranslationConstraintDir().

Type translationConstraintType   const [inline]
 

Returns the current translation constraint. Result is of type Type. The translation constraint is set with setTranslationConstraint().


Generated on Thu Jan 16 12:53:46 2003 for libQGLViewer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002