Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLCamera.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
43 #ifndef __GLCAMERA_H__
44 #define __GLCAMERA_H__
45 
46 #include "CoreConfig.h"
47 #include "graphCommon.h"
48 
49 namespace Menge {
50 
51  namespace SceneGraph {
52 
57  class MENGE_API GLCamera {
58  public:
62  enum CamEnum { ORTHO,
63  PERSP };
64 
68  GLCamera();
69 
75  GLCamera( const Vector3 & p);
76 
83  GLCamera( const Vector3 & p, const Vector3 & t);
84 
93  GLCamera( const Vector3 & p, const Vector3 & t, const Vector3 & u);
94 
102  void setOrtho( float scaleFactor=1.f );
103 
107  void setPersp();
108 
114  void setActive();
115 
121  Vector3 getPosition() const { return _position; }
122 
128  void setPosition( const Vector3 & p );
129 
137  void setPosition( float x, float y, float z );
138 
144  Vector3 getTarget() const { return _target; }
145 
151  void setTarget( const Vector3 & p );
152 
160  void setTarget( float x, float y, float z );
161 
167  Vector3 getUp() const { return _up; }
168 
175  void setUp( const Vector3 & u );
176 
184  void setUp( float x, float y, float z );
185 
192  inline void setFOV( float fov ) { _fov = fov; }
193 
197  inline float getFOV() const { return _fov; }
198 
204  inline void setFarPlane( float fp ) { _farPlane = fp; }
205 
211  inline float getFarPlane() const { return _farPlane; }
212 
218  inline void setNearPlane( float np ) { _nearPlane = np; }
219 
225  inline float getNearPlane() const { return _nearPlane; }
226 
237  float getOrthoScaleFactor() const;
238 
250  void setViewport( int w, int h, int left=0, int bottom=0 );
251 
253 
261  void setProjMat( int w, int h ) const ;
262 
269  void setSelectMat( int * selectPoint ) const ;
270 
274  void setGLView() const;
275 
285  void viewXAxis( bool downPositive=true );
286 
296  void viewYAxis( bool downPositive=true );
297 
307  void viewZAxis( bool downPositive=true );
308 
319  void pan( float angle );
320 
330  void tilt( float angle );
331 
341  void truck( float amount );
342 
354  void crane( float amount );
355 
366  void dolly ( float amount );
367 
378  void dollyPlane( float amount );
379 
390  void zoom( float amount );
391 
399  void orbitVerticalAxis( float angle );
400 
407  void orbitHorizontalAxis( float angle );
408 
410 
416  float targetDistance() const;
417 
423  Vector3 targetDir() const;
424 
433  Vector3 getActualUpDir() const;
434 
440  Vector3 getRightDir() const;
441 
447  void outputState() const;
448 
449  private:
450 
454  CamEnum _type;
455 
459  Vector3 _position;
460 
464  Vector3 _target;
465 
470  Vector3 _up;
471 
475  float _farPlane;
476 
480  float _nearPlane;
481 
485  float _fov;
486 
491  mutable unsigned int _viewWidth;
492 
497  mutable unsigned int _viewHeight;
498 
502  mutable bool _dirtyProj;
503 
510  float _orthoHWidth;
511 
516  void _setProjMat() const;
517  };
518 
519  } // namespace SceneGraph
520 } // namespace Menge
521 
522 #endif
Vector3 getTarget() const
Return the position of the camera's view target.
Definition: GLCamera.h:144
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
CamEnum
Determines the projection matrix of the 3D camera.
Definition: GLCamera.h:62
Sets up the proper compiler directives for platform and dll export/import.
void setFOV(float fov)
Sets the field of view of the camera – only applicable when using the perspective projection...
Definition: GLCamera.h:192
float getFOV() const
Returns the current horizontal field of view (in degrees).
Definition: GLCamera.h:197
Vector3 getUp() const
Return the orientation of the camera's up direction.
Definition: GLCamera.h:167
The SceneGraph (SceneGraph) name space, containing all elements to use in a SceneGraph.
void setFarPlane(float fp)
Sets the far plane distance.
Definition: GLCamera.h:204
Vector3 getPosition() const
Return the position of the camera.
Definition: GLCamera.h:121
The class for controlling the view camera: it's position, orientation field of view, projection matrix, etc.
Definition: GLCamera.h:57
void setNearPlane(float np)
Sets the near plane distance.
Definition: GLCamera.h:218
Various important pre-compiler directives for the scene graph.
float getFarPlane() const
Reports the camera's current far plane distance.
Definition: GLCamera.h:211
float getNearPlane() const
Reports the camera's current near plane distance.
Definition: GLCamera.h:225