Developer Documentation
CameraNode.hh
1 /* ========================================================================= *
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
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 
53 //=============================================================================
54 //
55 // CLASS CameraNode
56 //
57 //=============================================================================
58 
59 
60 #ifndef ACG_CAMERAVIS_NODE_HH
61 #define ACG_CAMERAVIS_NODE_HH
62 
63 //== INCLUDES =================================================================
64 
65 
66 #include <ACG/Scenegraph/BaseNode.hh>
67 #include <ACG/Scenegraph/DrawModes.hh>
68 #include <ACG/GL/GLPrimitives.hh>
69 #include <string>
70 #include <vector>
71 
72 #include <ACG/Math/QuaternionT.hh>
73 
75 
76 //== NAMESPACES ===============================================================
77 
78 namespace ACG {
79 namespace SceneGraph {
80 
81 //== CLASS DEFINITION =========================================================
82 
83 
89 class DLLEXPORT CameraNode: public BaseNode {
90 
91 public:
92 
94  CameraNode( BaseNode* _parent = 0, std::string _name = "<CameraVis>");
95 
97  virtual ~CameraNode();
98 
99  ACG_CLASSNAME( CameraNode);
100 
102  DrawModes::DrawMode availableDrawModes() const;
103 
105  void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
106 
108  void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
109 
111  void pick(GLState& _state, PickTarget _target);
112 
114  void setModelView(ACG::GLMatrixd _modelView) { modelView_ = _modelView; };
115 
117  void setProjection(ACG::GLMatrixd _projection) { projection_ = _projection; };
118 
120  void setSize(int _w, int _h) { width_ = _w; height_ = _h; aspectRatio_ = (double)width_ / (double)height_; }
121 
123  void setEncodedView(QString _encodedView) { encodedView_ = _encodedView; };
124 
126  void setFarPlane(double _far) { far_ = _far; };
127 
129  void setNearPlane(double _near) { near_ = _near; };
130 
132  QString getEncodedView() { return encodedView_; };
133 
135  void showFrustum(bool _showFrustum) { showFrustum_ = _showFrustum; }
136 
138  bool showFrustum() { return showFrustum_; }
139 
140 private:
141 
142  void updateBoundingBoxes(GLMatrixd& _modelview);
143 
144  OpenMesh::Vec3d bbmin_;
145  OpenMesh::Vec3d bbmax_;
146 
147  ACG::GLMatrixd modelView_;
148  ACG::GLMatrixd projection_;
149 
150  int width_, height_;
151 
152  double fovy_;
153 
154  double half_height_;
155  double half_width_;
156 
157  double far_half_height_;
158  double far_half_width_;
159 
160  double aspectRatio_;
161  double near_;
162  double far_;
163 
164  GLCylinder* cylinder_;
165  GLCone* cone_;
166 
167 
168  QString encodedView_;
169 
170  bool showFrustum_;
171 };
172 
173 
174 
175 //=============================================================================
176 } // namespace SceneGraph
177 } // namespace ACG
178 
179 //=============================================================================
180 #endif // ACG_CameraVis_NODE_HH
181 //=============================================================================
QString getEncodedView()
Return encoded view string.
Definition: CameraNode.hh:132
void showFrustum(bool _showFrustum)
Set if viewing frustum should be shown or not.
Definition: CameraNode.hh:135
#define DLLEXPORT
void setProjection(ACG::GLMatrixd _projection)
Set projection Matrix ( used to calculate frustum ... )
Definition: CameraNode.hh:117
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
void setNearPlane(double _near)
Set distance to near plane.
Definition: CameraNode.hh:129
ACG::SceneGraph::CameraNode CameraNode
Simple Name for CameraNode.
Definition: CameraTypes.hh:75
void setEncodedView(QString _encodedView)
Return encoded view string.
Definition: CameraNode.hh:123
void setModelView(ACG::GLMatrixd _modelView)
set model view matrix
Definition: CameraNode.hh:114
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
void setSize(int _w, int _h)
Set viewport size ( This will be used to compute the aspect ratio )
Definition: CameraNode.hh:120
void setFarPlane(double _far)
Set distance to far plane ( e.g. scene radius )
Definition: CameraNode.hh:126
bool showFrustum()
Returns true if camera renders its whole frustum.
Definition: CameraNode.hh:138