Back to Jetson Inference

Jetson Inference: jetson

docs/html/glCamera_8h_source.html

latest11.5 KB
Original Source

| | 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

35 class glCamera

36 {

37 public:

41enum CameraMode

42 {

43LookAt,

44YawPitchRoll,

45Ortho

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

glCamera::CameraMode

CameraMode

Enum specifying the camera mode.

Definition: glCamera.h:41

glCamera::SetRoll

void SetRoll(float roll)

Set the roll angle, in radians.

Definition: glCamera.h:146

glCamera::SetNear

void SetNear(float near)

Set the distance to the near clipping plane.

Definition: glCamera.h:111

glCamera::Create

static glCamera * Create(CameraMode mode, int registerEvents=0)

Create OpenGL camera object with the specified CameraMode.

glCamera::~glCamera

~glCamera()

Free the camera.

glCamera::Ortho

@ Ortho

Ortho (2D)

Definition: glCamera.h:45

glCamera::SetPitch

void SetPitch(float pitch)

Set the pitch angle, in radians.

Definition: glCamera.h:141

glCamera::SetRotation

void SetRotation(float yaw, float pitch, float roll)

Set the yaw/pitch/roll angles, in radians.

Definition: glCamera.h:131

glCamera::SetMovementSpeed

void SetMovementSpeed(float speed)

Set the movement speed (in world units)

Definition: glCamera.h:151

glCamera::SetFar

void SetFar(float far)

Set the distance to the far clipping plane.

Definition: glCamera.h:116

glCamera::SetFOV

void SetFOV(float fov)

Set the field of view (FOV), in degrees.

Definition: glCamera.h:101

glCamera::SetYaw

void SetYaw(float yaw)

Set the yaw angle, in radians.

Definition: glCamera.h:136

glCamera::SetLookAt

void SetLookAt(float x, float y, float z)

Set the look-at point.

Definition: glCamera.h:126

glCamera::Reset

void Reset()

Reset camera orientation to defaults.

glCamera::YawPitchRoll

@ YawPitchRoll

YawPitchRoll (first person.

Definition: glCamera.h:44

glCamera

OpenGL perspective camera supporting Look-At, Yaw/Pitch/Roll, and Ortho modes.

Definition: glCamera.h:35

glCamera::Deactivate

void Deactivate()

Restore previous GL_PROJECTION and GL_MODELVIEW matrices.

glCamera::GetCameraMode

CameraMode GetCameraMode() const

Get the camera mode.

Definition: glCamera.h:91

glCamera::StoreDefaults

void StoreDefaults()

Store the current configuration as defaults.

glCamera::SetMovementEnabled

void SetMovementEnabled(bool enabled)

Enable or disable movement from user input.

Definition: glCamera.h:156

glCamera::Activate

void Activate()

Activate GL_PROJECTION and GL_MODELVIEW matrices.

glCamera::RegisterEvents

void RegisterEvents(uint32_t display=0)

Register to recieve input events (enable movement)

glCamera::SetEye

void SetEye(float x, float y, float z)

Set the eye position.

Definition: glCamera.h:121

glCamera::SetClippingPlane

void SetClippingPlane(float near, float far)

Set the near/far z-clipping plane.

Definition: glCamera.h:106

glCamera::SetCameraMode

void SetCameraMode(CameraMode mode)

Set the camera mode.

Definition: glCamera.h:96

glCamera::LookAt

@ LookAt

LookAt (orbit)

Definition: glCamera.h:43