Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef QGLVIEWER_CONSTRAINT_H
00024 #define QGLVIEWER_CONSTRAINT_H
00025 
00026 #include "vec.h"
00027 #include "quaternion.h"
00028 
00029 namespace qglviewer {
00030   class Frame;
00031   class Camera;
00032 
00117   class QGLVIEWER_EXPORT Constraint
00118   {
00119   public:
00121     virtual ~Constraint() {};
00122 
00133     virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); };
00142     virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); };
00143   };
00144 
00168   class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint
00169   {
00170   public:
00171     AxisPlaneConstraint();
00173     virtual ~AxisPlaneConstraint() {};
00174 
00207     enum Type { FREE, AXIS, PLANE, FORBIDDEN };
00208 
00212     virtual void constrainTranslation(Vec& translation, Frame* const frame) { Q_UNUSED(translation); Q_UNUSED(frame); };
00213 
00214     void setTranslationConstraint(Type type, const Vec& direction);
00216     void setTranslationConstraintType(Type type) { translationConstraintType_ = type; };
00217     void setTranslationConstraintDirection(const Vec& direction);
00218 
00228     Type translationConstraintType() const { return translationConstraintType_; };
00238     Vec translationConstraintDirection() const { return translationConstraintDir_; };
00240 
00244     virtual void constrainRotation(Quaternion& rotation, Frame* const frame) { Q_UNUSED(rotation); Q_UNUSED(frame); };
00245 
00246     void setRotationConstraint(Type type, const Vec& direction);
00247     void setRotationConstraintType(Type type);
00248     void setRotationConstraintDirection(const Vec& direction);
00249 
00251     Type rotationConstraintType() const { return rotationConstraintType_; };
00259     Vec rotationConstraintDirection() const { return rotationConstraintDir_; };
00261 
00262   private:
00263     
00264     Type translationConstraintType_;
00265     Type rotationConstraintType_;
00266 
00267     Vec translationConstraintDir_;
00268     Vec rotationConstraintDir_;
00269   };
00270 
00271 
00279   class QGLVIEWER_EXPORT LocalConstraint : public AxisPlaneConstraint
00280   {
00281   public:
00283     virtual ~LocalConstraint() {};
00284 
00285     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00286     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00287   };
00288 
00289 
00290 
00299   class QGLVIEWER_EXPORT WorldConstraint : public AxisPlaneConstraint
00300   {
00301   public:
00303     virtual ~WorldConstraint() {};
00304 
00305     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00306     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00307   };
00308 
00309 
00310 
00319   class QGLVIEWER_EXPORT CameraConstraint : public AxisPlaneConstraint
00320   {
00321   public:
00322     explicit CameraConstraint(const Camera* const camera);
00324     virtual ~CameraConstraint() {};
00325 
00326     virtual void constrainTranslation(Vec&     translation, Frame* const frame);
00327     virtual void constrainRotation   (Quaternion& rotation, Frame* const frame);
00328 
00330     const Camera* camera() const { return camera_; };
00331 
00332   private:
00333     const Camera* const camera_;
00334   };
00335 
00336 } 
00337 
00338 #endif // QGLVIEWER_CONSTRAINT_H