Developer Documentation
ViewingParameters.hh
1 /* ========================================================================= *
2  * *
3  * OpenMesh *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openmesh.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenMesh. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  * ========================================================================= */
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Date$ *
46  * *
47 \*===========================================================================*/
48 
49 
50 //=============================================================================
51 //
52 // CLASS newClass
53 //
54 //=============================================================================
55 
56 #ifndef OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH
57 #define OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH
58 
59 
60 //== INCLUDES =================================================================
61 
62 #include <OpenMesh/Core/Geometry/VectorT.hh>
63 #include <OpenMesh/Core/Geometry/Plane3d.hh>
64 
65 
66 //== FORWARDDECLARATIONS ======================================================
67 
68 
69 //== NAMESPACES ===============================================================
70 
71 namespace OpenMesh {
72 namespace VDPM {
73 
74 //== CLASS DEFINITION =========================================================
75 
76 
79 class OPENMESHDLLEXPORT ViewingParameters
80 {
81 private:
82  double modelview_matrix_[16];
83  float fovy_;
84  float aspect_;
85  float tolerance_square_;
86 
87  Vec3f eye_pos_;
88  Vec3f right_dir_;
89  Vec3f up_dir_;
90  Vec3f view_dir_;
91 
92  Plane3d frustum_plane_[4];
93 
94 public:
95 
97 
98  void increase_tolerance() { tolerance_square_ *= 5.0f; }
99  void decrease_tolerance() { tolerance_square_ /= 5.0f; }
100 
101  float fovy() const { return fovy_; }
102  float aspect() const { return aspect_; }
103  float tolerance_square() const { return tolerance_square_; }
104 
105  void set_fovy(float _fovy) { fovy_ = _fovy; }
106  void set_aspect(float _aspect) { aspect_ = _aspect; }
107  void set_tolerance_square(float _tolerance_square) { tolerance_square_ = _tolerance_square; }
108 
109  const Vec3f& eye_pos() const { return eye_pos_; }
110  const Vec3f& right_dir() const { return right_dir_; }
111  const Vec3f& up_dir() const { return up_dir_; }
112  const Vec3f& view_dir() const { return view_dir_; }
113  Vec3f& eye_pos() { return eye_pos_; }
114  Vec3f& right_dir() { return right_dir_; }
115  Vec3f& up_dir() { return up_dir_; }
116  Vec3f& view_dir() { return view_dir_; }
117 
118  void frustum_planes( Plane3d _plane[4] )
119  {
120  for (unsigned int i=0; i<4; ++i)
121  _plane[i] = frustum_plane_[i];
122  }
123 
124  void get_modelview_matrix(double _modelview_matrix[16])
125  {
126  for (unsigned int i=0; i<16; ++i)
127  _modelview_matrix[i] = modelview_matrix_[i];
128  }
129 
130  void set_modelview_matrix(const double _modelview_matrix[16])
131  {
132  for (unsigned int i=0; i<16; ++i)
133  modelview_matrix_[i] = _modelview_matrix[i];
134  }
135 
136  void update_viewing_configurations();
137 
138  void PrintOut();
139 };
140 
141 
142 //=============================================================================
143 } // namespace VDPM
144 } // namespace OpenMesh
145 //=============================================================================
146 #endif // OPENMESH_VDPROGMESH_VIEWINGPARAMETERS_HH defined
147 //=============================================================================
148