66 set(
Vec3(5.0, 5.0, 5.0),
Vec3( 0.0, 0.0, 0.0),
Vec3(0, 1, 0));
137 if(_viewAngle >180.0
f)
143 if(_near<CAMERANEARLIMIT)
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);
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);
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";
343 _rib.getStream() <<
"ConcatTransform [ ";
344 for (
int i=0; i<16; i++)
348 _rib.getStream() <<
"]\n";
349 _rib.getStream() <<
"# now we Set the clipping \n";
352 _rib.getStream() <<
"#End of Camera from GraphicsLib\n";
392 points.push_back(
m_ntl);
393 points.push_back(
m_ftl);
395 points.push_back(
m_ntr);
396 points.push_back(
m_ftr);
398 points.push_back(
m_nbl);
399 points.push_back(
m_fbl);
401 points.push_back(
m_nbr);
402 points.push_back(
m_fbr);
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);
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);
430 vao->setVertexAttributePointer(0,3,
GL_FLOAT,
sizeof(
Vec3),0);
432 vao->setNumIndices(points.size());
444 for(
int i=0; i < 6; ++i)
463 for(
int i=0; i< 6; ++i)
466 if (distance < -_radius)
470 else if (distance < _radius)
483 for(
int i=0; i < 6; i++)
Plane m_planes[6]
array of planes for fustrum
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
void yaw(Real _angle) noexcept
roll the cameara around the y axis
Camera() noexcept
default constructor
void setAspect(Real _asp) noexcept
re-set the aspect ratio of the camera
Vec4 & normalize() noexcept
Normalize the vector using .
simple Vector class for OpenGL graphics, contains overloaded operators for most math functions...
Vec4 m_v
vector for the Camera local cord frame
const Mat4 & null() noexcept
clear the matrix to all 0
Mat4 m_projectionMatrix
Projection a Matrix to hold the perspective transfomatio matrix for the camera.
static AbstractVAO * createVAO(const std::string &_type, GLenum _mode=GL_TRIANGLES)
void setViewAngle(Real _angle) noexcept
set the viewangle for the Camera
void normalisedYaw(Real _angle) noexcept
used to do a Yaw based on Euler rotation with normalised values
Real m_aspect
used to store the current camera aspect ratio (can be derived from Width / Height ...
Vec4 m_look
where the camera is looking to, used with Eye to calculate the Vector m_n
Vec3 toVec3() const noexcept
get as a Vec3 for glsl etc
void setDefaultCamera() noexcept
sets some nice default camera values
void setViewMatrix() noexcept
method to set the modelview matrix values for the current camera, this method load the matrix Modelvi...
Real m_m[4][4]
matrix element m_m as a 4x4 array mapped by union to m_nn elements and m_openGL
void setProjectionMatrix() noexcept
set the projection matrix
simple Vec3 encapsulates a 3 float object like glsl vec3 but not maths use the Vec3 class for maths a...
implementation files for RibExport class
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...
PRECISION Real
create a variable called Real which is the main data type we use (GLfloat for most cases) ...
GLdouble GLdouble GLdouble b
void calculateFrustum() noexcept
calculate the frustum for clipping etc
Real m_fov
the feild of view of the camera view volume, measured from the eye
simple rib export class, attempts to auto tab the rib file etc. needs lots of work to make it complet...
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...
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...
void set(Real _x, Real _y, Real _z, Real _w=1.0) noexcept
sets the vector component from 3 values
a simple 3 tuple container for compatibility with glsl
Real m_zNear
the near clipping plane of the camera view volume
GLsizei GLsizei GLfloat distance
Vec4 m_eye
the position of the Camera used to calculate the local cord frame
Vec4 m_up
gives a general indication of which way up the camera is
Vec4 m_n
vector for the Camera local cord frame
void normalisedPitch(Real _angle) noexcept
used to do a Pitch based on Euler rotation with normalised values
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
void drawFrustum() noexcept
draw the frustum for clipping etc
Vec3 getNormal() const noexcept
accesor to get the normal
Real m_height
the height of the display image used for some perspective projection calculations ...
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...
void slide(Real _du, Real _dv, Real _dn) noexcept
slide the camera around the U V and N axis
CameraIntercept isSphereInFrustum(const Vec3 &_p, Real _radius) const noexcept
check to see if the sphere passed in is within the frustum
void pitch(Real _angle) noexcept
roll the cameara around the x axis
constexpr Real CAMERANEARLIMIT
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
void moveEye(Real _dx, Real _dy, Real _dz) noexcept
move the eye position
Real m_zFar
the far clipping plane of the camera view volume
Vec4 m_u
vector for the Camera local cord frame
Real dot(const Vec4 &_b) const noexcept
return this dotted with _b
CameraIntercept isPointInFrustum(const Vec3 &_p) const noexcept
check to see if the point passed in is within the frustum
Real distance(const Vec3 &_p) const noexcept
get the distance from the point _p to the plane
#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...
void moveLook(Real _dx, Real _dy, Real _dz) noexcept
move the look position
void moveBoth(Real _dx, Real _dy, Real _dz) noexcept
move both the eye and the look at the same time
NGL_DLLEXPORT Real radians(const Real _deg)
converts Degrees to Radians
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
Matrix Class to do simple matrix operations included operator overloaded functions for maths and matr...
CameraIntercept boxInFrustum(const AABB &b) const noexcept
check to see if the AABB passed in is within the frustum
void roll(Real _angle) noexcept
roll the cameara around the Z axis
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 ...
void setShape(Real _viewAngle, Real _aspect, Real _near, Real _far) noexcept
set the shape of the Camera
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
re impliment asserts so we don't exit on failure
void cross(const Vec4 &_v1, const Vec4 &_v2) noexcept
set the vector as the cross product from 2 other vectors
void normalisedRoll(Real _angle) noexcept
used to do a Roll based on Euler rotation with normalised values
void setPerspProjection() noexcept
function used to set the perspective projection matrix values
Mat4 m_viewMatrix
a Matrix to hold the combined modelling and viewing matrix to load into OpenGL
Vec3 m_ntl
points for the fustrum drawing
Real m_width
the width of the display image used for some perspective projection calculations
void update() noexcept
Use is called to make this the current camera and set the MODELVIEW and PROJECTION matrices in OpenGL...