#include <constraint.h>
Inherits Constraint.
Inherited by CameraConstraint, LocalConstraint, and WorldConstraint.
Translation constraints | |
virtual void | constrainTranslation (Vec &, Frame *const)=0 |
void | setTranslationConstraint (const Type t, const Vec &dir) |
void | setTranslationConstraint (const Type t, const float x, const float y, const float z) |
void | setTranslationConstraintType (const Type t) |
void | setTranslationConstraintDir (const Vec &dir) |
Type | translationConstraintType () const |
void | getTranslationConstraintDir (float &x, float &y, float &z) const |
Vec | translationConstraintDir () const |
Rotation constraints | |
virtual void | constrainRotation (Quaternion &, Frame *const)=0 |
void | setRotationConstraint (const Type t, const Vec &dir) |
void | setRotationConstraint (const Type t, const float x, const float y, const float z) |
void | setRotationConstraintType (const Type t) |
void | setRotationConstraintDir (const Vec &dir) |
Type | rotationConstraintType () const |
void | getRotationConstraintDir (float &x, float &y, float &z) const |
Vec | rotationConstraintDir () const |
Public Types | |
enum | Type { FREE, PLANE, AXIS, FORBIDDEN } |
Public Member Functions | |
AxisPlaneConstraint () | |
virtual | ~AxisPlaneConstraint () |
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. The three implementations of this class: LocalConstraint, WorldConstraint and CameraConstraint each define the constraint axis/plane in a different coordinate system.
Different implementations of this class are illustrated in the contrainedCamera and constrainedFrame examples.
To completely forbid the displacement of a Frame, use a code like this:
AxisPlaneConstraint* apc = new Any_Derived_Class(); apc->setTranslationConstraintType(AxisPlaneConstraint::FORBIDDEN); // forbids translation // apc->setRotationConstraintType(AxisPlaneConstraint::FORBIDDEN); // or forbids rotation myFrame->setConstraint(apc);
|
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.
|
|
Translation and Rotation constraints are set to FREE. |
|
Virtual empty destructor. |
|
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 Constraint. Implemented in LocalConstraint, WorldConstraint, and CameraConstraint. |
|
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 Constraint. Implemented in LocalConstraint, WorldConstraint, and CameraConstraint. |
|
Same as getRotationConstraintDir() but result is returned as floats. |
|
Same as getTranslationConstraintDir() but result is returned as floats. |
|
Returns the current direction of the rotation constraint. If rotationConstraintType() is FREE or FORBIDDEN, this value is undefined. |
|
Returns the current rotation constraint. Result is of type Type(). The rotation constraint is set with setRotationConstraint(). |
|
Same as setRotationConstraint(), but with float parameters. |
|
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
The axis and plane normal directions are expressed in different coordinates system, depending on the derived class (WorldConstraint, CameraConstraint...). 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 rotationConstraintType() and rotationConstraintDir(). The axis direction is undefined when the constraint is of type FREE or FORBIDDEN.
|
|
Similar to setRotationConstraint(), but only set the direction. |
|
Set the Type() of the rotation constraint. See setRotationConstraint().
|
|
Same as setTranslationConstraint(), but with float parameters. |
|
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 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()).
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(). |
|
Similar to setTranslationConstraint(), but only set the direction. |
|
Set the Type() of the translation constraint. See setTranslationConstraint(). |
|
Returns the current direction of the translation constraint. If translationConstraintType() is FREE or FORBIDDEN, this value is undefined. |
|
Returns the current translation constraint. Result is of type Type(). The translation constraint is set with setTranslationConstraint(). |