Code_TYMPAN  4.4.0
Industrial site acoustic simulation
OGLCamera.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  *
19  *
20  *
21  */
22 
23 #ifndef __O_GLCAMERA__
24 #define __O_GLCAMERA__
25 
26 #include "Tympan/core/smartptr.h"
27 
28 #if _WIN32
29  #include <windows.h>
30 #endif //_WIN32
31 
32 #include <GL/gl.h>
33 #include <GL/glu.h>
34 #include "NxVec3.h"
36 
37 typedef enum
38 {
41  FREE
43 
44 class OGLCamera
45 {
46 
47 public:
48  OGLCamera(NxReal* _from, NxReal* _to, NxReal* _up, int w, int h, CameraType eCameraType);
49  void setCameraType(CameraType eCameraType);
50  void lookAt();
51  void moveFront();
52  void moveBack();
53  void moveUp();
54  void moveDown();
55  void moveLeft();
56  void moveRight();
57  void rotateUpLockSrc();
58  void rotateDownLockSrc();
61  void rotateLeftLockSrc();
62  void rotateRightLockSrc();
63  void rotateUpLockDst();
64  void rotateDownLockDst();
65  void rotateLeftLockDst();
66  void rotateRightLockDst();
67  void rotateSideLeft();
68  void rotateSideRight();
69  void move(NxReal* _direction);
70  void moveFront(NxReal _distance);
71  void moveBack(NxReal _distance);
72  void moveUp(NxReal _distance);
73  void moveDown(NxReal _distance);
74  void moveLeft(NxReal _distance);
75  void moveRight(NxReal _distance);
76  void rotateUpLockSrc(NxReal _angle);
77  void rotateDownLockSrc(NxReal _angle);
80  void rotateLeftLockSrc(NxReal _angle);
81  void rotateRightLockSrc(NxReal _angle);
82  void rotateUpLockDst(NxReal _angle);
83  void rotateDownLockDst(NxReal _angle);
84  void rotateLeftLockDst(NxReal _angle);
85  void rotateRightLockDst(NxReal _angle);
86  void rotateSideLeft(NxReal _angle);
87  void rotateSideRight(NxReal _angle);
88  void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft);
89  void setAllAngleStep(NxReal _angle);
90  void setAngleStep(NxReal _stepAngleUpDown, NxReal _stepAngleLeftRight, NxReal _stepAngleSide);
91  void setFrom(NxReal* _from);
92  void setTo(NxReal* _to);
93  void setUp(NxReal* _up);
94  void setFromToUp(NxReal* _from, NxReal* _to, NxReal* _up);
95  void setFromToUp();
96  void setDistanceFromToLockFrom(NxReal _distanceFromTo);
97  void setDistanceFromToLockTo(NxReal _distanceFromTo);
98  void setModeLock(bool _modeLockUpDown, bool _modeLockLeftRight, bool _modeLockSide);
99  void setMinMaxCurrentUpDown(NxReal _minUpDown, NxReal _maxUpDown, NxReal _currentUpDown);
100  void setMinMaxCurrentLeftRight(NxReal _minLeftRight, NxReal _maxLeftRight, NxReal _currentLeftRight);
101  void setMinMaxCurrentSide(NxReal _minSide, NxReal _maxSide, NxReal _currentSide);
102  void setAllMinMaxCurrent(NxReal _angle);
103  void setSize(int w, int h);
104  void calculateStepVectors();
105  static NxVec3 displayToWorld(NxVec3 display);
106  static NxVec3 worldToDisplay(NxVec3 world);
107  NxVec3 getCenter(int sizeX, int sizeY);
108  void getViewPort(double* vp);
109  void zoom(double zoomFactor);
110  void azimuth(NxReal _angle);
111  void elevation(NxReal _angle);
112  void roll(NxReal _angle);
113  void resetZoom(int w = -1, int h = -1);
114  void resetTranslation();
115  void setTranslation(double x, double y, double z);
116  void getTranslation(double& x, double& y, double& z);
117  void resetRotations();
118  void setDefaultZoomFactor(double defaultZoomFactor);
119  void getPosition(double& x, double& y, double& z);
120 
121  NxVec3 // points:
123  to,
124  // normalized vectors:
126  // balanced vectors:
128 
131  // distance and vector from - to :
134 
136 
139 
140  int m_w, m_h;
144 };
145 
146 // Smart pointer sur OGLCamera.
148 
149 #endif // __O_GLCAMERA__
All base classes related to 3D manipulation.
#define NxReal
Definition: NxVec3.h:20
SmartPtr< OGLCamera > LPOGLCamera
Definition: OGLCamera.h:147
CameraType
Definition: OGLCamera.h:38
@ PERSPECTIVE
Definition: OGLCamera.h:40
@ PARALLEL
Definition: OGLCamera.h:39
@ FREE
Definition: OGLCamera.h:41
Definition: NxVec3.h:23
NxVec3 flyTo
Definition: OGLCamera.h:127
double m_angleAz
Definition: OGLCamera.h:141
NxVec3 left
Definition: OGLCamera.h:125
void getViewPort(double *vp)
Definition: OGLCamera.cpp:739
NxVec3 stepUp
Definition: OGLCamera.h:127
void setDefaultZoomFactor(double defaultZoomFactor)
Definition: OGLCamera.cpp:835
void setMinMaxCurrentSide(NxReal _minSide, NxReal _maxSide, NxReal _currentSide)
Definition: OGLCamera.cpp:657
NxReal minSide
Definition: OGLCamera.h:138
NxVec3 getCenter(int sizeX, int sizeY)
Definition: OGLCamera.cpp:749
void moveDown()
Definition: OGLCamera.cpp:195
double m_angleEl
Definition: OGLCamera.h:141
double m_zoomFactor
Definition: OGLCamera.h:141
void setAngleStep(NxReal _stepAngleUpDown, NxReal _stepAngleLeftRight, NxReal _stepAngleSide)
Definition: OGLCamera.cpp:567
NxReal sinLeftRight
Definition: OGLCamera.h:129
void elevation(NxReal _angle)
Definition: OGLCamera.cpp:788
void rotateUpLockSrcKeepUpAndFront()
Definition: OGLCamera.cpp:261
static NxVec3 displayToWorld(NxVec3 display)
Definition: OGLCamera.cpp:699
void azimuth(NxReal _angle)
Definition: OGLCamera.cpp:782
NxVec3 m_translate
Definition: OGLCamera.h:143
NxVec3 flyLeft
Definition: OGLCamera.h:127
void setAllAngleStep(NxReal _angle)
Definition: OGLCamera.cpp:559
double m_angleRo
Definition: OGLCamera.h:141
NxReal stepAngleLeftRight
Definition: OGLCamera.h:129
NxVec3 flyFront
Definition: OGLCamera.h:127
void roll(NxReal _angle)
Definition: OGLCamera.cpp:794
void setModeLock(bool _modeLockUpDown, bool _modeLockLeftRight, bool _modeLockSide)
Definition: OGLCamera.cpp:635
NxReal magnitudeStepLeft
Definition: OGLCamera.h:137
void zoom(double zoomFactor)
Definition: OGLCamera.cpp:761
void getTranslation(double &x, double &y, double &z)
Definition: OGLCamera.cpp:854
void lookAt()
Definition: OGLCamera.cpp:80
void setTo(NxReal *_to)
Definition: OGLCamera.cpp:587
NxReal cosSide
Definition: OGLCamera.h:130
void rotateSideRight()
Definition: OGLCamera.cpp:367
void resetTranslation()
Definition: OGLCamera.cpp:829
static NxVec3 worldToDisplay(NxVec3 world)
Definition: OGLCamera.cpp:722
NxVec3 stepLeft
Definition: OGLCamera.h:127
void moveRight()
Definition: OGLCamera.cpp:223
NxReal currentLeftRight
Definition: OGLCamera.h:138
NxReal stepAngleSide
Definition: OGLCamera.h:130
NxReal cosUpDown
Definition: OGLCamera.h:129
NxVec3 flyUp
Definition: OGLCamera.h:127
void setUp(NxReal *_up)
Definition: OGLCamera.cpp:594
void rotateRightLockSrc()
Definition: OGLCamera.cpp:293
NxReal maxLeftRight
Definition: OGLCamera.h:138
NxVec3 stepFront
Definition: OGLCamera.h:127
void rotateDownLockSrc()
Definition: OGLCamera.cpp:249
NxReal minUpDown
Definition: OGLCamera.h:137
void setCameraType(CameraType eCameraType)
Definition: OGLCamera.cpp:138
NxReal magnitudeStepUp
Definition: OGLCamera.h:137
NxVec3 fromTo
Definition: OGLCamera.h:133
void calculateStepVectors()
Definition: OGLCamera.cpp:670
bool modeLockSide
Definition: OGLCamera.h:135
void rotateSideLeft()
Definition: OGLCamera.cpp:357
void resetZoom(int w=-1, int h=-1)
Definition: OGLCamera.cpp:800
void rotateLeftLockSrc()
Definition: OGLCamera.cpp:280
void resetRotations()
Definition: OGLCamera.cpp:840
void moveLeft()
Definition: OGLCamera.cpp:209
void setMinMaxCurrentUpDown(NxReal _minUpDown, NxReal _maxUpDown, NxReal _currentUpDown)
Definition: OGLCamera.cpp:642
NxVec3 from
Definition: OGLCamera.h:122
void rotateRightLockDst()
Definition: OGLCamera.cpp:344
NxVec3 to
Definition: OGLCamera.h:123
NxReal stepAngleUpDown
Definition: OGLCamera.h:129
NxVec3 flyFrom
Definition: OGLCamera.h:127
void setTranslation(double x, double y, double z)
Definition: OGLCamera.cpp:848
void getPosition(double &x, double &y, double &z)
Definition: OGLCamera.cpp:861
NxReal sinUpDown
Definition: OGLCamera.h:129
void rotateLeftLockDst()
Definition: OGLCamera.cpp:331
OGLCamera(NxReal *_from, NxReal *_to, NxReal *_up, int w, int h, CameraType eCameraType)
Definition: OGLCamera.cpp:36
CameraType m_eCameraType
Definition: OGLCamera.h:142
void setSize(int w, int h)
Definition: OGLCamera.cpp:74
void rotateDownLockDst()
Definition: OGLCamera.cpp:318
NxVec3 flyFromTo
Definition: OGLCamera.h:127
bool modeLockLeftRight
Definition: OGLCamera.h:135
void rotateDownLockSrcKeepUpAndFront()
Definition: OGLCamera.cpp:270
NxReal sinSide
Definition: OGLCamera.h:129
NxReal currentUpDown
Definition: OGLCamera.h:137
NxReal maxSide
Definition: OGLCamera.h:138
NxReal currentSide
Definition: OGLCamera.h:138
double m_defaultZoomFactor
Definition: OGLCamera.h:141
NxReal distanceFromTo
Definition: OGLCamera.h:132
void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft)
Definition: OGLCamera.cpp:545
NxReal magnitudeStepFront
Definition: OGLCamera.h:137
void rotateUpLockSrc()
Definition: OGLCamera.cpp:237
void move(NxReal *_direction)
Definition: OGLCamera.cpp:143
void setDistanceFromToLockTo(NxReal _distanceFromTo)
Definition: OGLCamera.cpp:628
void setDistanceFromToLockFrom(NxReal _distanceFromTo)
Definition: OGLCamera.cpp:621
void moveBack()
Definition: OGLCamera.cpp:167
NxReal minLeftRight
Definition: OGLCamera.h:138
void moveFront()
Definition: OGLCamera.cpp:153
NxReal maxUpDown
Definition: OGLCamera.h:137
NxReal cosLeftRight
Definition: OGLCamera.h:129
void setFromToUp()
Definition: OGLCamera.cpp:616
NxVec3 up
Definition: OGLCamera.h:125
void setFrom(NxReal *_from)
Definition: OGLCamera.cpp:580
void moveUp()
Definition: OGLCamera.cpp:181
void rotateUpLockDst()
Definition: OGLCamera.cpp:306
NxVec3 front
Definition: OGLCamera.h:125
void setAllMinMaxCurrent(NxReal _angle)
Definition: OGLCamera.cpp:664
void setMinMaxCurrentLeftRight(NxReal _minLeftRight, NxReal _maxLeftRight, NxReal _currentLeftRight)
Definition: OGLCamera.cpp:649
bool modeLockUpDown
Definition: OGLCamera.h:135