Axis.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                              SOFA :: Framework                              *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 #ifndef SOFA_HELPER_GL_AXIS_H
00028 #define SOFA_HELPER_GL_AXIS_H
00029 
00030 #include <sofa/defaulttype/Vec.h>
00031 #include <sofa/defaulttype/Quat.h>
00032 
00033 #include <sofa/helper/system/gl.h>
00034 #include <sofa/helper/system/glu.h>
00035 
00036 #include <map>
00037 
00038 namespace sofa
00039 {
00040 
00041 namespace helper
00042 {
00043 
00044 namespace gl
00045 {
00046 
00047 using namespace sofa::defaulttype;
00048 
00049 class Axis
00050 {
00051 public:
00052 
00053     Axis(SReal len=(SReal)1);
00054     Axis(const Vector3& len);
00055     Axis(const Vector3& center, const Quaternion &orient, const Vector3& length);
00056     Axis(const Vector3& center, const double orient[4][4], const Vector3& length);
00057     Axis(const double *mat, const Vector3& length);
00058     Axis(const Vector3& center, const Quaternion &orient, SReal length=(SReal)1);
00059     Axis(const Vector3& center, const double orient[4][4], SReal length=(SReal)1);
00060     Axis(const double *mat, SReal length=(SReal)1.0);
00061 
00062     ~Axis();
00063 
00064     void update(const Vector3& center, const Quaternion& orient = Quaternion());
00065     void update(const Vector3& center, const double orient[4][4]);
00066     void update(const double *mat);
00067 
00068     void draw();
00069 
00070     static void draw(const Vector3& center, const Quaternion& orient, const Vector3& length);
00071     static void draw(const Vector3& center, const double orient[4][4], const Vector3& length);
00072     static void draw(const double *mat, const Vector3& length);
00073     static void draw(const Vector3& center, const Quaternion& orient, SReal length=(SReal)1);
00074     static void draw(const Vector3& center, const double orient[4][4], SReal length=(SReal)1);
00075     static void draw(const double *mat, SReal length=(SReal)1.0);
00076 
00077     //Draw a nice vector (cylinder + cone) given 2 points and a radius (used to draw the cylinder)
00078     static void draw(const Vector3& center, const Vector3& ext, const double& radius);
00079     //Draw a cylinder given two points and the radius of the extremities (to have a cone, simply set one radius to zero)
00080     static void draw(const Vector3& center, const Vector3& ext, const double& r1, const double& r2);
00081 private:
00082 
00083   Vector3 length;
00084   double matTransOpenGL[16];
00085 
00086   GLUquadricObj *quadratic;
00087   GLuint displayList;
00088 
00089   void initDraw();
00090 
00091   static std::map < std::pair<std::pair<float,float>,float>, Axis* > axisMap;
00092   static Axis* get(const Vector3& len);
00093 
00094 };
00095 
00096 } // namespace gl
00097 
00098 } // namespace helper
00099 
00100 } // namespace sofa
00101 
00102 #endif

Generated on Sun Nov 23 02:29:29 2008 for Sofa by  doxygen 1.5.7.1