Home | Documentation | Download | Screenshots | Developper |
A Frame
is a 3D coordinate system, represented by a position and an orientation. The
order of these transformations is important : in QGLViewer, we chosed to firstly translate the
frame, and then to define its orientation. These positions and orientations are defined with
respect to the world coordinate system (unless a specific reference frame is provided, see below).
Note : the world coordinate system is the one you are in at the beginning of the QGLViewer::draw()
function.
You can define and read the currrent frame state using Frame::position(), Frame::setPosition(), Frame::orientation(), Frame::setOrientation(). Use Frame::translate() and Frame::rotate() to modify the frame.
Many functions allow you to transform a 3D point from one coordinate system to an other : see
coordinatesOf()
, inverseCoordinatesOf()
, coordinatesOfIn()
,
coordinatesOfFrom()
... You may also want to transform a vector from one frame to
an other (which corresponds to applying only the rotationnal part of the frame transformation), see
transformOf()
, inverseTransformOf()
...
The translation and the rotation that are encapsulated in a Frame can also be used to represent a
solid transformation of space. Such a solid transformation can also be interpreted as a
change of coordinate system, and the provided functions actually allow you to use a Frame as a solid
transformation, using the inverseCoordinatesOf()
and coordinatesOf()
functions to apply the transformation and its inverse.
The manipulatedFrame class derives from Frame. It implements a mouse motion translation, so that a frame can be manipulated with the mouse (see the associated page and the manipulatedFrame example).
Setting a NULL
reference frame resets the world coordinate system as the reference
frame (default value).
The frame hierarchy must be a tree, which root is the world coordinate system. A loop in the hierarchy would result in an inconsistent frame definition. The settingAsReferenceFrameWillCreateALoop() function checks this and prevents setReferenceFrame() from creating such a loop.
Arbitrary constraints can be applied to the motion of a frame to limit its displacement. This is especially usefull for the manipulatedFrame instances, in order to forbid some mouse motions. See the constrainedFrame, constrainedCamera and luxo examples for an illustration.
The constraints are filters which are applied in the Frame::translate() and Frame::rotate() functions. The input desired motion is modified (or not) by the constraint, and only the resulting filtered motion will actually be applied to the frame. The default constraint of a frame applies no filter on the motion, which is hence completely free.
Use Frame::setConstraint() to attach a constraint to a frame. A NULL
value means that
no filter will be applied (default).
New constraints can very easily be implemented by deriving a class from the Constraint
class or any of its derived classes. All you need is to provide your own implementation of the
constrainTranslation(qglviewer::Vec&, Frame* const)
and
constrainRotation(qglviewer::Quaternion& , Frame* const)
functions.
See the Constraint class documentation for details.
Basic constraints are provided for convenience : see the LocalConstraint, WorldConstraint and CameraConstraint classes for axial and plane constraints. The TriangleSetConstraint() is very usefull for walkthrough applications, in order to force the camera to remain on a given path.
If you need to combine several constraints, simply create a new Constraint class, which will store pointers to
the other constraints. The constrainTranslation()
and/or
constrainRotation()
implementation will simply be made of successive calls to
the different constraints associated functions. Much more complex constraint composition classes can
be done in the same way.