NGL  6.5
The NCCA Graphics Library
Camera.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #include "Camera.h"
18 #include "Util.h"
19 #include "NGLassert.h"
20 #include "VAOFactory.h"
21 #include "SimpleVAO.h"
22 #include <vector>
23 #include "Vec3.h"
24 #include <iostream>
25 #include <cmath>
26 #include <memory>
27 //----------------------------------------------------------------------------------------------------------------------
30 //----------------------------------------------------------------------------------------------------------------------
31 namespace ngl
32 {
33 // a lot of this stuff is from the HILL book Computer Graphics with OpenGL 2nd Ed Prentice Hall
34 // a very good book
35 constexpr Real CAMERANEARLIMIT=0.00001f;
36 
37 //----------------------------------------------------------------------------------------------------------------------
38 
39 Camera::Camera() noexcept
40 {
41 
42  m_zNear=0.0001f;
43  m_zFar=350.0f;
44  m_aspect=720.0f/576.0f;
45  m_fov=45.0f;
46  m_width=720;
47  m_height=576;
48  m_eye.set(1,1,1);
49 }
50 
51 
52 //----------------------------------------------------------------------------------------------------------------------
54 {
55  // make default camera
56  m_eye=1.0f;
57  m_look=0.0f;
59  m_fov=45.0;
60  m_zNear=0.0001f;
61  m_zFar=350.0f;
62  m_aspect=720.0f/576.0f;
63  m_fov=45.0f;
64 
65  setShape(m_fov, m_aspect, m_zNear, m_zFar); // good default values here
66  set(Vec3(5.0, 5.0, 5.0),Vec3( 0.0, 0.0, 0.0),Vec3(0, 1, 0));
67 }
68 
69 //----------------------------------------------------------------------------------------------------------------------
70 void Camera::set(const Vec3 &_eye, const Vec3 &_look, const Vec3 &_up ) noexcept
71 {
72  // make U, V, N vectors
73  m_eye=_eye;
74  m_look=_look;
75  m_up=_up;
77  m_u=m_up.cross(m_n);
78  m_v=m_n.cross(m_u);
79  m_u.normalize();
80  m_v.normalize();
81  m_n.normalize();
82  setViewMatrix();
83 }
84 
85 //----------------------------------------------------------------------------------------------------------------------
86 Camera::Camera(const Vec3 &_eye, const Vec3 &_look, const Vec3 &_up ) noexcept
87 {
89  set(_eye,_look,_up);
90 }
91 
92 
93 
94 //----------------------------------------------------------------------------------------------------------------------
95 void Camera::setViewMatrix() noexcept
96 {
97  // grab a pointer to the matrix so we can index is quickly
98  auto M = &m_viewMatrix.m_m[0][0];
99  M[0] = m_u.m_x; M[1] = m_v.m_x; M[2] = m_n.m_x; M[3] = 0.0;
100  M[4] = m_u.m_y; M[5] = m_v.m_y; M[6] = m_n.m_y; M[7] = 0.0;
101  M[8] = m_u.m_z; M[9] = m_v.m_z; M[10]= m_n.m_z; M[11] =0.0;
102  M[12] = -m_eye.dot(m_u); M[13]= -m_eye.dot(m_v); M[14]= -m_eye.dot(m_n); M[15] =1.0;
103 
105 }
106 
107 //----------------------------------------------------------------------------------------------------------------------
109 {
110  // note 1/tan == cotangent
111  Real f= 1.0f/tanf(radians(m_fov)/2.0f);
113 
115  m_projectionMatrix.m_m[1][1]=f;
116 
119 
120  m_projectionMatrix.m_m[2][3]=-1.0f;
121  m_projectionMatrix.m_m[3][3]=1.0f;
122 
123 }
124 
125 //----------------------------------------------------------------------------------------------------------------------
127 {
130 
131 }
132 //----------------------------------------------------------------------------------------------------------------------
133 
134 void Camera::setShape(Real _viewAngle, Real _aspect, Real _near, Real _far ) noexcept
135 
136 { // load projection matrix and camera values
137  if(_viewAngle >180.0f)
138  {
139  _viewAngle=180.0f;
140  }
141  NGL_ASSERT(_far>_near);
142  NGL_ASSERT(_near>CAMERANEARLIMIT);
143  if(_near<CAMERANEARLIMIT)
144  {
145  _near=CAMERANEARLIMIT;
146  }
147  m_fov = _viewAngle; // viewangle in degrees - must be < 180
148  m_aspect = _aspect;
149  m_zNear = _near;
150  m_zFar = _far;
152  //calculateFrustum();
153 }
154 
155 //----------------------------------------------------------------------------------------------------------------------
156 void Camera::setAspect( Real _asp ) noexcept
157 {
158  m_aspect = _asp;
160 }
161 
162 //----------------------------------------------------------------------------------------------------------------------
163 void Camera::setViewAngle( Real _angle ) noexcept
164 {
165  m_fov=_angle;
167 }
168 
169 
170 //----------------------------------------------------------------------------------------------------------------------
171 void Camera::slide( Real _du, Real _dv, Real _dn ) noexcept
172 {
173  // slide eye by amount du * u + dv * v + dn * n;
174  m_eye.m_x += _du * m_u.m_x + _dv * m_v.m_x + _dn * m_n.m_x;
175  m_eye.m_y += _du * m_u.m_y + _dv * m_v.m_y + _dn * m_n.m_y;
176  m_eye.m_z += _du * m_u.m_z + _dv * m_v.m_z + _dn * m_n.m_z;
177  setViewMatrix();
178 }
179 
180 //----------------------------------------------------------------------------------------------------------------------
181 void Camera::move( Real _dx, Real _dy, Real _dz ) noexcept
182 {
183 // simply add the translation to the current eye point
184  m_eye.m_x += _dx;
185  m_eye.m_y += _dy;
186  m_eye.m_z += _dz;
187  setViewMatrix();
188 }
189 //----------------------------------------------------------------------------------------------------------------------
190 void Camera::moveBoth( Real _dx, Real _dy, Real _dz ) noexcept
191 {
192  m_eye.m_x +=_dx;
193  m_eye.m_y +=_dy;
194  m_eye.m_z +=_dz;
195  m_look.m_x+=_dx;
196  m_look.m_y+=_dy;
197  m_look.m_z+=_dz;
198  m_n=m_eye-m_look;
199  m_u=m_up.cross(m_n);
200  m_v.set(m_n.cross(m_u));
201  // normalize vectors
202  m_u.normalize();
203  m_v.normalize();
204  m_n.normalize();
205  // pass to OpenGL
206  setViewMatrix();
207 }
208 //----------------------------------------------------------------------------------------------------------------------
209 void Camera::rotAxes( Vec4& io_a, Vec4& io_b, const Real _angle ) noexcept
210 {
211 // rotate orthogonal vectors a (like x axis) and b(like y axis) through angle degrees
212  // convert to radians
213  Real ang = radians(_angle);
214  // pre-calc cos and sine
215  Real c = cosf(ang);
216  Real s = sinf(ang);
217  // tmp for io_a vector
218  Vec4 t( c * io_a.m_x + s * io_b.m_x, c * io_a.m_y + s * io_b.m_y, c * io_a.m_z + s * io_b.m_z);
219  // now set to new rot value
220  io_b.set(-s * io_a.m_x + c * io_b.m_x, -s * io_a.m_y + c * io_b.m_y, -s * io_a.m_z + c * io_b.m_z);
221  // put tmp into _a'
222  io_a.set(t.m_x, t.m_y, t.m_z);
223 }
224 
225 //----------------------------------------------------------------------------------------------------------------------
226 void Camera::roll(Real _angle ) noexcept
227 {
228  rotAxes(m_u, m_v, -_angle);
229  setViewMatrix();
230 }
231 
232 //----------------------------------------------------------------------------------------------------------------------
233 void Camera::pitch(Real _angle ) noexcept
234 {
235  rotAxes(m_n, m_v, _angle);
236  setViewMatrix();
237 }
238 
239 //----------------------------------------------------------------------------------------------------------------------
240 void Camera::yaw(Real _angle ) noexcept
241 {
242  rotAxes(m_u, m_n, _angle);
243  setViewMatrix();
244 }
245 
246 //----------------------------------------------------------------------------------------------------------------------
247 void Camera::moveEye( Real _dx, Real _dy, Real _dz ) noexcept
248 {
249  m_eye.m_x+=_dx;
250  m_eye.m_y+=_dy;
251  m_eye.m_z+=_dz;
252  m_n=m_eye-m_look;
253  m_u.set(m_up.cross(m_n));
254  m_v.set(m_n.cross(m_u));
255  // normalize the vectors
256  m_u.normalize();
257  m_v.normalize();
258  m_n.normalize();
259  // pass to OpenGL
260  setViewMatrix();
261 }
262 
263 //----------------------------------------------------------------------------------------------------------------------
264 void Camera::moveLook(Real _dx, Real _dy, Real _dz ) noexcept
265 {
266  m_look.m_x+=_dx;
267  m_look.m_y+=_dy;
268  m_look.m_z+=_dz;
269  m_n=m_eye-m_look;
270  m_u.set(m_up.cross(m_n));
271  m_v.set(m_n.cross(m_u));
272  // normalise vectors
273  m_u.normalize();
274  m_v.normalize();
275  m_n.normalize();
276  // pass to OpenGL
277  setViewMatrix();
278 }
279 
280 //----------------------------------------------------------------------------------------------------------------------
281 void Camera::update() noexcept
282 {
283  setViewMatrix();
284 }
285 
286 //----------------------------------------------------------------------------------------------------------------------
287 void Camera::normalisedYaw( Real _angle ) noexcept
288 {
289  // build a rotation matrix around the y axis
290  Mat4 mat;
291  mat.identity();
292  mat.rotateY(_angle);
293  //multiply all three local coord vectors by the matrix
294  m_u = m_u * mat;
295  m_v = m_v * mat;
296  m_n = m_n * mat;
297  // reset the modelview matrix
298  setViewMatrix();
299 }
300 //----------------------------------------------------------------------------------------------------------------------
301 void Camera::normalisedRoll(Real _angle ) noexcept
302 {
303  // build a rotation matrix around the y axis
304  Mat4 mat;
305  mat.identity();
306  mat.rotateZ(_angle);
307  //multiply all three local coord vectors by the matrix
308  m_u = m_u * mat;
309  m_v = m_v * mat;
310  m_n = m_n * mat;
311  // reset the modelview matrix
312  setViewMatrix();
313 }
314 
315 //----------------------------------------------------------------------------------------------------------------------
316 void Camera::normalisedPitch(Real _angle ) noexcept
317 {
318  // build a rotation matrix around the y axis
319  Mat4 mat;
320  mat.identity();
321  mat.rotateX(_angle);
322  //multiply all three local coord vectors by the matrix
323  m_u = m_u * mat;
324  m_v = m_v * mat;
325  m_n = m_n * mat;
326  // reset the modelview matrix
327  setViewMatrix();
328 }
329 
330 
331 
332 //----------------------------------------------------------------------------------------------------------------------
333 void Camera::writeRib( RibExport &_rib ) const noexcept
334 {
335  if(_rib.isOpen()!=0)
336  {
337 
338  _rib.writeTabs();
339  _rib.getStream() <<"# Camera transform from GraphicsLib Camera\n" ;
340  _rib.getStream() <<"# now we need to flip the Z axis\n";
341  _rib.getStream() <<"Scale 1 1 -1 \n";
342 
343  _rib.getStream() <<"ConcatTransform [ ";
344  for (int i=0; i<16; i++)
345  {
346  _rib.getStream() <<m_viewMatrix.m_openGL[i]<<" ";
347  }
348  _rib.getStream() <<"]\n";
349  _rib.getStream() <<"# now we Set the clipping \n";
350 // _rib.getStream() <<"Clipping "<<m_zNear<<" "<<m_zFar<<"\n";
351 // _rib.getStream() <<"Projection \"perspective\" \"fov\" ["<<m_fov<<"]\n";
352  _rib.getStream() <<"#End of Camera from GraphicsLib\n";
353  }
354 }
355 //----------------------------------------------------------------------------------------------------------------------
359 {
360 
361  Real tang = tanf(radians(m_fov) * 0.5f) ;
362  Real nh = m_zNear * tang;
363  Real nw = nh * m_aspect;
364  Real fh = m_zFar * tang;
365  Real fw = fh * m_aspect;
366 
367  Vec3 nc = (m_eye - m_n * m_zNear).toVec3();
368  Vec3 fc = (m_eye - m_n * m_zFar).toVec3();
369 
370  m_ntl = nc + m_v.toVec3() * nh - m_u.toVec3() * nw;
371  m_ntr = nc + m_v.toVec3() * nh + m_u.toVec3() * nw;
372  m_nbl = nc - m_v.toVec3() * nh - m_u.toVec3() * nw;
373  m_nbr = nc - m_v.toVec3() * nh + m_u.toVec3() * nw;
374 
375  m_ftl = fc + m_v.toVec3() * fh - m_u.toVec3() * fw;
376  m_ftr = fc + m_v.toVec3() * fh + m_u.toVec3() * fw;
377  m_fbl = fc - m_v.toVec3() * fh - m_u.toVec3() * fw;
378  m_fbr = fc - m_v.toVec3() * fh + m_u.toVec3() * fw;
379  m_planes[static_cast<int>(ProjPlane::TOP)].setPoints(m_ntr,m_ntl,m_ftl);
380  m_planes[static_cast<int>(ProjPlane::BOTTOM)].setPoints(m_nbl,m_nbr,m_fbr);
381  m_planes[static_cast<int>(ProjPlane::LEFT)].setPoints(m_ntl,m_nbl,m_fbl);
382  m_planes[static_cast<int>(ProjPlane::RIGHT)].setPoints(m_nbr,m_ntr,m_fbr);
383  m_planes[static_cast<int>(ProjPlane::NEARP)].setPoints(m_ntl,m_ntr,m_nbr);
384  m_planes[static_cast<int>(ProjPlane::FARP)].setPoints(m_ftr,m_ftl,m_fbl);
385 }
386 
387 void Camera::drawFrustum() noexcept
388 {
389  std::vector<Vec3>points;
390 
391  // draw the sides as lines
392  points.push_back(m_ntl);
393  points.push_back(m_ftl);
394 
395  points.push_back(m_ntr);
396  points.push_back(m_ftr);
397 
398  points.push_back(m_nbl);
399  points.push_back(m_fbl);
400 
401  points.push_back(m_nbr);
402  points.push_back(m_fbr);
403  // near plane lines
404  points.push_back(m_ntr);
405  points.push_back(m_ntl);
406  points.push_back(m_nbr);
407  points.push_back(m_nbl);
408  points.push_back(m_ntr);
409  points.push_back(m_nbr);
410  points.push_back(m_ntl);
411  points.push_back(m_nbl);
412  // far plane lines
413  points.push_back(m_ftr);
414  points.push_back(m_ftl);
415  points.push_back(m_fbr);
416  points.push_back(m_fbl);
417  points.push_back(m_ftr);
418  points.push_back(m_fbr);
419  points.push_back(m_ftl);
420  points.push_back(m_fbl);
421 
422 
423  // now we create a VAO to store the data
424  std::unique_ptr<AbstractVAO> vao( VAOFactory::createVAO("simpleVAO",GL_LINES));
425  // bind it so we can set values
426  vao->bind();
427  // set the vertex data (4 for x,y,z)
428  vao->setData(SimpleVAO::VertexData(points.size()*sizeof(Vec3),points[0].m_x));
429  // now we set the attribute pointer to be 0 (as this matches vertIn in our shader)
430  vao->setVertexAttributePointer(0,3,GL_FLOAT,sizeof(Vec3),0);
431  // say how many indecis to be rendered
432  vao->setNumIndices(points.size());
433  vao->draw();
434  // now unbind
435  vao->unbind();
436  vao->removeVAO();
437 
438 }
439 
440 
441 CameraIntercept Camera::isPointInFrustum( const Vec3 &_p ) const noexcept
442 {
444  for(int i=0; i < 6; ++i)
445  {
446 
447  if (m_planes[i].distance(_p) < 0)
448  {
450  }
451  }
452 
453  return result;
454 }
455 
456 
457 CameraIntercept Camera::isSphereInFrustum(const Vec3 &_p, Real _radius ) const noexcept
458 {
459 
461  Real distance;
462 
463  for(int i=0; i< 6; ++i)
464  {
465  distance = m_planes[i].distance(_p);
466  if (distance < -_radius)
467  {
469  }
470  else if (distance < _radius)
471  {
473  }
474  }
475  return result;
476 }
477 
478 
480 {
481 
483  for(int i=0; i < 6; i++)
484  {
485 
486  if (m_planes[i].distance(b.getVertexP(m_planes[i].getNormal())) < 0)
488  else if (m_planes[i].distance(b.getVertexN(m_planes[i].getNormal())) < 0)
490  }
491  return(result);
492 
493  }
494 
495 
496 
497 
499 
500 
501 } // end namespace ngl
502 
Plane m_planes[6]
array of planes for fustrum
Definition: Camera.h:359
some useful definitions and functions
void set(const Vec3 &_eye, const Vec3 &_look, const Vec3 &_up) noexcept
set the Camera position using eye look and up vectors
Definition: Camera.cpp:70
void yaw(Real _angle) noexcept
roll the cameara around the y axis
Definition: Camera.cpp:240
Camera() noexcept
default constructor
Definition: Camera.cpp:39
void setAspect(Real _asp) noexcept
re-set the aspect ratio of the camera
Definition: Camera.cpp:156
Vec4 & normalize() noexcept
Normalize the vector using .
Definition: Vec4.cpp:99
simple Vector class for OpenGL graphics, contains overloaded operators for most math functions...
Definition: Vec4.h:57
Vec4 m_v
vector for the Camera local cord frame
Definition: Camera.h:311
CameraIntercept
Definition: Camera.h:36
const Mat4 & null() noexcept
clear the matrix to all 0
Definition: Mat4.cpp:108
Mat4 m_projectionMatrix
Projection a Matrix to hold the perspective transfomatio matrix for the camera.
Definition: Camera.h:371
static AbstractVAO * createVAO(const std::string &_type, GLenum _mode=GL_TRIANGLES)
Definition: VAOFactory.cpp:19
const GLfloat * c
Definition: glew.h:16629
static Vec4 up()
Definition: Vec4.h:299
void setViewAngle(Real _angle) noexcept
set the viewangle for the Camera
Definition: Camera.cpp:163
void normalisedYaw(Real _angle) noexcept
used to do a Yaw based on Euler rotation with normalised values
Definition: Camera.cpp:287
Real m_aspect
used to store the current camera aspect ratio (can be derived from Width / Height ...
Definition: Camera.h:339
Vec4 m_look
where the camera is looking to, used with Eye to calculate the Vector m_n
Definition: Camera.h:323
Definition: AABB.h:42
Vec3 toVec3() const noexcept
get as a Vec3 for glsl etc
Definition: Vec4.h:128
void setDefaultCamera() noexcept
sets some nice default camera values
Definition: Camera.cpp:53
Vec3 m_ftl
Definition: Camera.h:367
void setViewMatrix() noexcept
method to set the modelview matrix values for the current camera, this method load the matrix Modelvi...
Definition: Camera.cpp:95
Real m_m[4][4]
matrix element m_m as a 4x4 array mapped by union to m_nn elements and m_openGL
Definition: Mat4.h:295
GLdouble GLdouble t
Definition: glew.h:1401
void setProjectionMatrix() noexcept
set the projection matrix
Definition: Camera.cpp:126
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
Definition: Vec3.h:51
Vec3 m_nbr
Definition: Camera.h:367
implementation files for RibExport class
Definition: AABB.cpp:22
void rotateZ(const Real _deg) noexcept
set this matrix to a rotation matrix in the Z axis for value _deg note the matrix should be set to id...
Definition: Mat4.cpp:430
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
Definition: Types.h:127
GLdouble GLdouble GLdouble b
Definition: glew.h:9162
void calculateFrustum() noexcept
calculate the frustum for clipping etc
Definition: Camera.cpp:358
Real m_fov
the feild of view of the camera view volume, measured from the eye
Definition: Camera.h:351
simple rib export class, attempts to auto tab the rib file etc. needs lots of work to make it complet...
Definition: RibExport.h:41
void rotateY(const Real _deg) noexcept
set this matrix to a rotation matrix in the Y axis for value _deg note the matrix should be set to id...
Definition: Mat4.cpp:418
GLuint64EXT * result
Definition: glew.h:14309
void rotateX(const Real _deg) noexcept
set this matrix to a rotation matrix in the X axis for value _deg note the matrix should be set to id...
Definition: Mat4.cpp:406
void set(Real _x, Real _y, Real _z, Real _w=1.0) noexcept
sets the vector component from 3 values
Definition: Vec4.cpp:41
a simple 3 tuple container for compatibility with glsl
Real m_zNear
the near clipping plane of the camera view volume
Definition: Camera.h:343
GLsizei GLsizei GLfloat distance
Definition: glew.h:13921
Vec4 m_eye
the position of the Camera used to calculate the local cord frame
Definition: Camera.h:319
Vec4 m_up
gives a general indication of which way up the camera is
Definition: Camera.h:327
Real m_z
z component
Definition: Vec4.h:323
Vec4 m_n
vector for the Camera local cord frame
Definition: Camera.h:315
void normalisedPitch(Real _angle) noexcept
used to do a Pitch based on Euler rotation with normalised values
Definition: Camera.cpp:316
const Mat4 & identity() noexcept
make the matrix m the identity matrix 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Definition: Mat4.cpp:114
void drawFrustum() noexcept
draw the frustum for clipping etc
Definition: Camera.cpp:387
Vec3 getNormal() const noexcept
accesor to get the normal
Definition: Plane.h:93
Real m_height
the height of the display image used for some perspective projection calculations ...
Definition: Camera.h:335
void writeRib(RibExport &_rib) const noexcept
write out the Camera so it may be used in Renderman, this writes a transform command in rib format so...
Definition: Camera.cpp:333
void slide(Real _du, Real _dv, Real _dn) noexcept
slide the camera around the U V and N axis
Definition: Camera.cpp:171
CameraIntercept isSphereInFrustum(const Vec3 &_p, Real _radius) const noexcept
check to see if the sphere passed in is within the frustum
Definition: Camera.cpp:457
Vec3 m_ftr
Definition: Camera.h:367
void pitch(Real _angle) noexcept
roll the cameara around the x axis
Definition: Camera.cpp:233
constexpr Real CAMERANEARLIMIT
Definition: Camera.cpp:35
Real m_x
x component
Definition: Vec4.h:321
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3458
void moveEye(Real _dx, Real _dy, Real _dz) noexcept
move the eye position
Definition: Camera.cpp:247
Real m_zFar
the far clipping plane of the camera view volume
Definition: Camera.h:347
Vec4 m_u
vector for the Camera local cord frame
Definition: Camera.h:307
Real dot(const Vec4 &_b) const noexcept
return this dotted with _b
Definition: Vec4.cpp:35
Vec3 m_fbl
Definition: Camera.h:367
CameraIntercept isPointInFrustum(const Vec3 &_p) const noexcept
check to see if the point passed in is within the frustum
Definition: Camera.cpp:441
Real distance(const Vec3 &_p) const noexcept
get the distance from the point _p to the plane
Definition: Plane.cpp:75
#define NGL_ASSERT(X)
re-define the standard assert to work for ngl first check to see if assert is defined and undef it th...
Definition: NGLassert.h:53
void moveLook(Real _dx, Real _dy, Real _dz) noexcept
move the look position
Definition: Camera.cpp:264
void moveBoth(Real _dx, Real _dy, Real _dz) noexcept
move both the eye and the look at the same time
Definition: Camera.cpp:190
NGL_DLLEXPORT Real radians(const Real _deg)
converts Degrees to Radians
Definition: Util.cpp:89
a simple camera class based on the Hill Book
void rotAxes(Vec4 &io_a, Vec4 &io_b, const Real _angle) noexcept
internal function to calculate the new rotation vectors for the camera after a roll, pitch or yaw
Definition: Camera.cpp:209
#define GL_FLOAT
Definition: glew.h:642
Matrix Class to do simple matrix operations included operator overloaded functions for maths and matr...
Definition: Mat4.h:58
CameraIntercept boxInFrustum(const AABB &b) const noexcept
check to see if the AABB passed in is within the frustum
Definition: Camera.cpp:479
Vec3 m_fbr
Definition: Camera.h:367
void roll(Real _angle) noexcept
roll the cameara around the Z axis
Definition: Camera.cpp:226
#define GL_LINES
Definition: glew.h:324
std::array< Real, 16 > m_openGL
The matrix in m_openGL 16 Real array format usefull for OpenGL fv formats mapped to m_m[][] elements ...
Definition: Mat4.h:300
void setShape(Real _viewAngle, Real _aspect, Real _near, Real _far) noexcept
set the shape of the Camera
Definition: Camera.cpp:134
void move(Real _dx, Real _dy, Real _dz) noexcept
move the camera in world space (i.e. add a translation to each of the axis
Definition: Camera.cpp:181
Vec3 m_ntr
Definition: Camera.h:367
Real m_y
y component
Definition: Vec4.h:322
re impliment asserts so we don&#39;t exit on failure
GLdouble s
Definition: glew.h:1393
Vec3 m_nbl
Definition: Camera.h:367
void cross(const Vec4 &_v1, const Vec4 &_v2) noexcept
set the vector as the cross product from 2 other vectors
Definition: Vec4.cpp:110
void normalisedRoll(Real _angle) noexcept
used to do a Roll based on Euler rotation with normalised values
Definition: Camera.cpp:301
void setPerspProjection() noexcept
function used to set the perspective projection matrix values
Definition: Camera.cpp:108
Mat4 m_viewMatrix
a Matrix to hold the combined modelling and viewing matrix to load into OpenGL
Definition: Camera.h:355
Vec3 m_ntl
points for the fustrum drawing
Definition: Camera.h:367
Real m_width
the width of the display image used for some perspective projection calculations
Definition: Camera.h:331
GLclampf f
Definition: glew.h:3511
void update() noexcept
Use is called to make this the current camera and set the MODELVIEW and PROJECTION matrices in OpenGL...
Definition: Camera.cpp:281