1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Authors: |
---|
6 | * Wei Qiao <qiaow@purdue.edu> |
---|
7 | */ |
---|
8 | #ifndef NV_CAMERA_H |
---|
9 | #define NV_CAMERA_H |
---|
10 | |
---|
11 | #include <vrmath/Matrix4x4d.h> |
---|
12 | #include <vrmath/Vector3f.h> |
---|
13 | |
---|
14 | #include "config.h" |
---|
15 | |
---|
16 | namespace nv { |
---|
17 | |
---|
18 | class Camera |
---|
19 | { |
---|
20 | public: |
---|
21 | Camera(int startx, int starty, int w, int h, |
---|
22 | float loc_x, float loc_y, float loc_z); |
---|
23 | |
---|
24 | ~Camera() |
---|
25 | {} |
---|
26 | |
---|
27 | //move location of camera |
---|
28 | void x(float loc_x) |
---|
29 | { |
---|
30 | _location.x = loc_x; |
---|
31 | } |
---|
32 | |
---|
33 | float x() const |
---|
34 | { |
---|
35 | return _location.x; |
---|
36 | } |
---|
37 | |
---|
38 | void y(float loc_y) |
---|
39 | { |
---|
40 | _location.y = loc_y; |
---|
41 | } |
---|
42 | |
---|
43 | float y() const |
---|
44 | { |
---|
45 | return _location.y; |
---|
46 | } |
---|
47 | |
---|
48 | void z(float loc_z) |
---|
49 | { |
---|
50 | _location.z = loc_z; |
---|
51 | } |
---|
52 | |
---|
53 | float z() const |
---|
54 | { |
---|
55 | return _location.z; |
---|
56 | } |
---|
57 | |
---|
58 | void rotate(double *quat); |
---|
59 | |
---|
60 | void rotate(float angle_x, float angle_y, float angle_z); |
---|
61 | |
---|
62 | void fov(float fov) |
---|
63 | { |
---|
64 | _fov = fov; |
---|
65 | } |
---|
66 | |
---|
67 | float fov() const |
---|
68 | { |
---|
69 | return _fov; |
---|
70 | } |
---|
71 | |
---|
72 | void reset(const vrmath::Vector3f& bboxMin, |
---|
73 | const vrmath::Vector3f& bboxMax, |
---|
74 | bool resetOrientation = false); |
---|
75 | |
---|
76 | void setClippingRange(float near, float far) |
---|
77 | { |
---|
78 | _near = near; |
---|
79 | _far = far; |
---|
80 | } |
---|
81 | |
---|
82 | void resetClippingRange(const vrmath::Vector3f& bboxMin, |
---|
83 | const vrmath::Vector3f& bboxMax); |
---|
84 | |
---|
85 | void setScreenSize(int sx, int sy, int w, int h) |
---|
86 | { |
---|
87 | _width = w; |
---|
88 | _height = h; |
---|
89 | _startX = sx; |
---|
90 | _startY = sy; |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | * \brief Make the camera setting active, this has to be |
---|
95 | * called before drawing things |
---|
96 | */ |
---|
97 | void initialize(); |
---|
98 | |
---|
99 | void print() const; |
---|
100 | |
---|
101 | private: |
---|
102 | void getUpDirMatrix(vrmath::Matrix4x4d& upMat); |
---|
103 | |
---|
104 | /// Location of the camera in the scene |
---|
105 | vrmath::Vector3f _location; |
---|
106 | /// Camera view matrix (orientation only, no translation) |
---|
107 | vrmath::Matrix4x4d _cameraMatrix; |
---|
108 | /// Field of view (vertical angle in degrees) |
---|
109 | float _fov; |
---|
110 | /// Near, far z clipping |
---|
111 | float _near, _far; |
---|
112 | |
---|
113 | /// screen width |
---|
114 | int _width; |
---|
115 | /// screen height |
---|
116 | int _height; |
---|
117 | int _startX; |
---|
118 | int _startY; |
---|
119 | }; |
---|
120 | |
---|
121 | } |
---|
122 | |
---|
123 | #endif |
---|