OpenMesh
OpenMesh/Tools/VDPM/ViewingParameters.hh
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         * 
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/ 
00034 
00035 /*===========================================================================*\
00036  *                                                                           *             
00037  *   $Revision: 362 $                                                         *
00038  *   $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 
00043 //=============================================================================
00044 //
00045 //  CLASS newClass
00046 //
00047 //=============================================================================
00048 
00049 #ifndef OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH
00050 #define OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH
00051 
00052 
00053 //== INCLUDES =================================================================
00054 
00055 #include <OpenMesh/Core/Geometry/VectorT.hh>
00056 #include <OpenMesh/Core/Geometry/Plane3d.hh>
00057 
00058 
00059 //== FORWARDDECLARATIONS ======================================================
00060 
00061 
00062 //== NAMESPACES ===============================================================
00063 
00064 namespace OpenMesh {
00065 namespace VDPM {
00066 
00067 //== CLASS DEFINITION =========================================================
00068 
00069               
00072 class ViewingParameters
00073 {
00074 private:
00075   double    modelview_matrix_[16];
00076   float     fovy_;
00077   float     aspect_;
00078   float     tolerance_square_;
00079 
00080   Vec3f   eye_pos_;
00081   Vec3f   right_dir_;
00082   Vec3f   up_dir_;
00083   Vec3f   view_dir_;
00084 
00085   Plane3d           frustum_plane_[4];
00086 
00087 public:
00088 
00089   ViewingParameters();
00090 
00091   void increase_tolerance()           { tolerance_square_ *= 5.0f; }
00092   void decrease_tolerance()           { tolerance_square_ /= 5.0f; }  
00093 
00094   float fovy() const                  { return  fovy_; }
00095   float aspect() const                { return  aspect_; }
00096   float tolerance_square() const      { return  tolerance_square_; } 
00097   
00098   void set_fovy(float _fovy)                            { fovy_ = _fovy; }
00099   void set_aspect(float _aspect)                        { aspect_ = _aspect; }
00100   void set_tolerance_square(float _tolerance_square)    { tolerance_square_ = _tolerance_square; }
00101 
00102   const Vec3f& eye_pos() const    { return eye_pos_; }
00103   const Vec3f& right_dir() const  { return right_dir_; }
00104   const Vec3f& up_dir() const     { return up_dir_; }
00105   const Vec3f& view_dir() const   { return view_dir_; }
00106   Vec3f& eye_pos()                { return eye_pos_; }
00107   Vec3f& right_dir()              { return right_dir_; }
00108   Vec3f& up_dir()                 { return up_dir_; }
00109   Vec3f& view_dir()               { return view_dir_; }
00110 
00111   void frustum_planes( Plane3d _plane[4] )
00112   {
00113     for (unsigned int i=0; i<4; ++i)
00114       _plane[i] = frustum_plane_[i];
00115   }
00116    
00117   void get_modelview_matrix(double _modelview_matrix[16])  
00118   {
00119     for (unsigned int i=0; i<16; ++i)
00120       _modelview_matrix[i] = modelview_matrix_[i];
00121   }  
00122 
00123   void set_modelview_matrix(const double _modelview_matrix[16])
00124   {
00125     for (unsigned int i=0; i<16; ++i)
00126       modelview_matrix_[i] = _modelview_matrix[i];   
00127   }
00128 
00129   void update_viewing_configurations();
00130 
00131   void PrintOut();
00132 };
00133 
00134 
00135 //=============================================================================
00136 } // namespace VDPM
00137 } // namespace OpenMesh
00138 //=============================================================================
00139 #endif // OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH defined
00140 //=============================================================================
00141