docs/html/glCamera_8h_source.html
| | Jetson Inference
DNN Vision Library |
glCamera.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __GL_CAMERA_H__
24 #define __GL_CAMERA_H__
25
26
27 #include <stdint.h>
28 #include <stdio.h>
29
30
36 {
37 public:
41enum CameraMode
42 {
46 };
47
56static glCamera* Create( CameraMode mode, int registerEvents=0 );
57
66static glCamera* Create( int registerEvents=0 );
67
71~glCamera();
72
76void Activate();
77
81void Activate( CameraMode mode );
82
86void Deactivate();
87
91inline CameraMode GetCameraMode() const { return mMode; }
92
96inline void SetCameraMode( CameraMode mode ) { mMode = mode; }
97
101inline void SetFOV( float fov ) { mFoV = fov; }
102
106inline void SetClippingPlane( float near, float far ) { mNear = near; mFar = far; }
107
111inline void SetNear( float near ) { mNear = near; }
112
116inline void SetFar( float far ) { mFar = far; }
117
121inline void SetEye( float x, float y, float z ) { mEye[0] = x; mEye[1] = y; mEye[2] = z; }
122
126inline void SetLookAt( float x, float y, float z ) { mLookAt[0] = x; mLookAt[1] = y; mLookAt[2] = z; }
127
131inline void SetRotation( float yaw, float pitch, float roll ) { mRotation[0] = pitch; mRotation[1] = yaw; mRotation[2] = roll; }
132
136inline void SetYaw( float yaw ) { mRotation[1] = yaw; }
137
141inline void SetPitch( float pitch ) { mRotation[0] = pitch; }
142
146inline void SetRoll( float roll ) { mRotation[2] = roll; }
147
151inline void SetMovementSpeed( float speed ) { mMovementSpeed = speed; }
152
156inline void SetMovementEnabled( bool enabled ) { mMovementEnabled = enabled; }
157
161void StoreDefaults();
162
166void Reset();
167
171void RegisterEvents( uint32_t display=0 );
172
173 private:
174glCamera( CameraMode mode );
175
176bool mouseInViewport() const;
177
178bool onEventLookAt( uint16_t msg, int a, int b );
179bool onEventYawPitchRoll( uint16_t msg, int a, int b );
180
181static bool onEvent( uint16_t msg, int a, int b, void* user );
182
183CameraMode mMode;
184
185float mNear;
186float mFar;
187float mFoV;
188
189float mEye[3]; // camera location
190float mRotation[3]; // pitch/yaw/roll euler angles
191float mLookAt[3]; // look-at point
192float mUp[3]; // up direction
193
194float mDefaultEye[3];
195float mDefaultRotation[3];
196float mDefaultLookAt[3];
197
198float mPrevModelView[16];
199float mPrevProjection[16];
200
201float mMovementSpeed;
202bool mMovementEnabled;
203
204void* mDisplay;
205int mViewport[4];
206bool mMouseActive;
207 };
208
209 #endif
210
CameraMode
Enum specifying the camera mode.
Definition: glCamera.h:41
void SetRoll(float roll)
Set the roll angle, in radians.
Definition: glCamera.h:146
void SetNear(float near)
Set the distance to the near clipping plane.
Definition: glCamera.h:111
static glCamera * Create(CameraMode mode, int registerEvents=0)
Create OpenGL camera object with the specified CameraMode.
~glCamera()
Free the camera.
@ Ortho
Ortho (2D)
Definition: glCamera.h:45
void SetPitch(float pitch)
Set the pitch angle, in radians.
Definition: glCamera.h:141
void SetRotation(float yaw, float pitch, float roll)
Set the yaw/pitch/roll angles, in radians.
Definition: glCamera.h:131
void SetMovementSpeed(float speed)
Set the movement speed (in world units)
Definition: glCamera.h:151
void SetFar(float far)
Set the distance to the far clipping plane.
Definition: glCamera.h:116
void SetFOV(float fov)
Set the field of view (FOV), in degrees.
Definition: glCamera.h:101
void SetYaw(float yaw)
Set the yaw angle, in radians.
Definition: glCamera.h:136
void SetLookAt(float x, float y, float z)
Set the look-at point.
Definition: glCamera.h:126
void Reset()
Reset camera orientation to defaults.
@ YawPitchRoll
YawPitchRoll (first person.
Definition: glCamera.h:44
OpenGL perspective camera supporting Look-At, Yaw/Pitch/Roll, and Ortho modes.
Definition: glCamera.h:35
void Deactivate()
Restore previous GL_PROJECTION and GL_MODELVIEW matrices.
CameraMode GetCameraMode() const
Get the camera mode.
Definition: glCamera.h:91
void StoreDefaults()
Store the current configuration as defaults.
void SetMovementEnabled(bool enabled)
Enable or disable movement from user input.
Definition: glCamera.h:156
void Activate()
Activate GL_PROJECTION and GL_MODELVIEW matrices.
void RegisterEvents(uint32_t display=0)
Register to recieve input events (enable movement)
void SetEye(float x, float y, float z)
Set the eye position.
Definition: glCamera.h:121
void SetClippingPlane(float near, float far)
Set the near/far z-clipping plane.
Definition: glCamera.h:106
void SetCameraMode(CameraMode mode)
Set the camera mode.
Definition: glCamera.h:96
@ LookAt
LookAt (orbit)
Definition: glCamera.h:43