Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

constraint.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the QGLViewer library
00004  Copyright (C) 2002-2004  Gilles Debunne (Gilles.Debunne@imag.fr)
00005  Version 1.3.5 Release 8. Packaged on Monday December 22, 2003.
00006 
00007  http://www-imagis.imag.fr/Membres/Gilles.Debunne/CODE/QGLViewer
00008 
00009  libQGLViewer is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  libQGLViewer is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with libQGLViewer; if not, write to the Free Software
00021  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023 *****************************************************************************/
00024 
00025 #ifndef QGLVIEWER_CONSTRAINT_H
00026 #define QGLVIEWER_CONSTRAINT_H
00027 
00028 #include "vec.h"
00029 #include "quaternion.h"
00030 
00031 namespace qglviewer {
00032   class Frame;
00033   class Camera;
00034 
00110   class QGLVIEWER_EXPORT Constraint
00111   {
00112   public:
00114     virtual ~Constraint() {};
00115 
00123     virtual void constrainTranslation(Vec&, Frame* const) {};
00124 
00131     virtual void constrainRotation(Quaternion& , Frame* const) {};
00132   };
00133 
00164   class QGLVIEWER_EXPORT AxisPlaneConstraint : public Constraint
00165   {
00166   public:
00167     AxisPlaneConstraint();
00169     virtual ~AxisPlaneConstraint() {};
00170 
00181     enum Type { FREE, PLANE, AXIS, FORBIDDEN };
00182 
00189     virtual void constrainTranslation(Vec&, Frame* const)=0;
00190     
00191     void setTranslationConstraint(const Type t, const Vec& dir);
00192     void setTranslationConstraint(const Type t, const float x, const float y, const float z);
00194     void setTranslationConstraintType(const Type t) { translationConstraint_ = t; };
00195     void setTranslationConstraintDir(const Vec& dir);
00196   
00199     Type translationConstraintType() const { return translationConstraint_; };
00200  
00202     void getTranslationConstraintDir(float& x, float& y, float& z) const;
00203 
00209     Vec translationConstraintDir() const { return translationConstraintDir_; };
00211     
00218     virtual void constrainRotation(Quaternion& , Frame* const)=0;
00219       
00220     void setRotationConstraint(const Type t, const Vec& dir);
00221     void setRotationConstraint(const Type t, const float x, const float y, const float z);
00222     void setRotationConstraintType(const Type t);
00223     void setRotationConstraintDir(const Vec& dir);
00224 
00227     Type rotationConstraintType() const { return rotationConstraint_; };
00228 
00230     void getRotationConstraintDir(float& x, float& y, float& z) const;
00236     Vec rotationConstraintDir() const { return rotationConstraintDir_; };
00238   
00239   private:
00241     Type translationConstraint_;
00243     Type rotationConstraint_;
00244 
00246     Vec translationConstraintDir_;
00248     Vec rotationConstraintDir_;
00249   };
00250 
00251   
00253   class QGLVIEWER_EXPORT LocalConstraint : public AxisPlaneConstraint
00254   {
00255   public:
00257     virtual ~LocalConstraint() {};
00258 
00259     virtual void constrainTranslation(Vec&        , Frame* const);
00260     virtual void constrainRotation   (Quaternion& , Frame* const);
00261   };
00262 
00263 
00264   
00266   class QGLVIEWER_EXPORT WorldConstraint : public AxisPlaneConstraint
00267   {
00268   public:
00270     virtual ~WorldConstraint() {};
00271 
00272     virtual void constrainTranslation(Vec&        , Frame* const);
00273     virtual void constrainRotation   (Quaternion& , Frame* const);
00274   };
00275 
00276   
00278   class QGLVIEWER_EXPORT CameraConstraint : public AxisPlaneConstraint
00279   {
00280   public:
00281     explicit CameraConstraint(const Camera* const cam);
00283     virtual ~CameraConstraint() {};
00284 
00285     virtual void constrainTranslation(Vec&        , Frame* const);
00286     virtual void constrainRotation   (Quaternion& , Frame* const);
00287 
00289     const Camera* camera() const { return camera_; };
00290     
00291   private:
00293     const Camera* const camera_;
00294   };
00295  
00296 } // namespace qglviewer
00297 
00298 #endif // QGLVIEWER_CONSTRAINT_H

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2