NGL  6.5
The NCCA Graphics Library
ngl::BBox Class Reference

Simple Bounding box class used in various parts of ngl and other example programs. More...

#include <BBox.h>

+ Collaboration diagram for ngl::BBox:

Public Member Functions

 BBox (const Vec3 &_center, Real _width, Real _height, Real _depth) noexcept
 Bounding Box ctor using a Center and the 3 dimensions of the BBox. More...
 
 BBox (Real _minX, Real _maxX, Real _minY, Real _maxY, Real _minZ, Real _maxZ) noexcept
 ctor using +/- x,y,z dimensions More...
 
 BBox () noexcept
 Default constructor will create a BBox centered at point 0,0,0 With Unit length width and height (== 1) More...
 
 BBox (const BBox &_b) noexcept
 copy ctor More...
 
BBoxoperator= (const BBox &_other)
 
void draw () const noexcept
 Draw Method draws the BBox using OpenGL. More...
 
void setDrawMode (GLenum _mode) noexcept
 reset the draw mode for the BBox More...
 
 ~BBox () noexcept
 dtor no dynamic memory so empty More...
 
Real minX () const noexcept
 the min x value of the bbox More...
 
Real maxX () const noexcept
 the max x value of the bbox More...
 
Real minY () const noexcept
 the min y value of the bbox More...
 
Real maxY () const noexcept
 the max y value of the bbox More...
 
Real minZ () const noexcept
 the min z value of the bbox More...
 
Real maxZ () const noexcept
 the max z value of the bbox More...
 
Vec3 center () const noexcept
 This is the center of the BBox stored for caluculations in other classes s. More...
 
Real width () const noexcept
 accessor for the width of the BBox More...
 
void width (Real _w, bool _recalc=true) noexcept
 set the width More...
 
Real height () const noexcept
 Height of the BBox. More...
 
void height (Real _h, bool _recalc=true) noexcept
 set the height More...
 
Real depth () const noexcept
 Depth of the BBox. More...
 
void depth (Real _d, bool _recalc=true) noexcept
 set the depth More...
 
Vec3getNormalArray () noexcept
 the array of normals for the BBox More...
 
Vec3getVertexArray () noexcept
 the array of verts for the BBox More...
 
void setCenter (const Vec3 &_center, bool _recalc=true) noexcept
 set the center of the BBox and re-calculate the extents More...
 
void recalculate () noexcept
 recalculate the bbox values once things have been changed this will also re-do the VAO More...
 

Protected Member Functions

void setVAO ()
 method used to set the vao More...
 

Protected Attributes

Vec3 m_vert [8]
 Contains the 8 vertices for the BBox aranged from v[0] = Left-top-Max Z and then rotating clock wise for the top of the BBox The Bottom Square is a mirror of the 1st verts with the Y value changed See constructor code for caluculations. More...
 
Real m_minX
 the min x value of the bbox More...
 
Real m_maxX
 the max x value of the bbox More...
 
Real m_minY
 the min y value of the bbox More...
 
Real m_maxY
 the max y value of the bbox More...
 
Real m_minZ
 the min z value of the bbox More...
 
Real m_maxZ
 the max z value of the bbox More...
 
Vec3 m_center
 This is the center of the BBox stored for caluculations in other classes s. More...
 
Vec3 m_norm [6]
 used to store the 6 Normal faces for the BBox used for calculating BBox collisions if needed More...
 
Real m_width
 Width of the BBox. More...
 
Real m_height
 Height of the BBox. More...
 
Real m_depth
 Depth of the BBox. More...
 
std::unique_ptr< AbstractVAOm_vao
 a pointer to the VAO buffer used for drawing the bbox More...
 
GLuint m_drawMode
 sets the draw mode for the BBox Faces, set to GL_LINE for line faces and GL_FILL for filled More...
 

Detailed Description

Simple Bounding box class used in various parts of ngl and other example programs.

Author
Jonathan Macey
Version
4.1
Date
Last Revision updated to use Vec3 to fit with new shader attribute pipeline

Definition at line 40 of file BBox.h.

Constructor & Destructor Documentation

ngl::BBox::BBox ( const Vec3 _center,
Real  _width,
Real  _height,
Real  _depth 
)
noexcept

Bounding Box ctor using a Center and the 3 dimensions of the BBox.

Parameters
[in]_centerthe center of the BBox.
[in]_widththe width of the BBox (== X coord).
[in]_heightthe height of the BBox (== Y coord).
[in]_depththe Depth of the BBox (== Z coord).

Definition at line 46 of file BBox.cpp.

References GL_LINE, and GL_LINE_LOOP.

ngl::BBox::BBox ( Real  _minX,
Real  _maxX,
Real  _minY,
Real  _maxY,
Real  _minZ,
Real  _maxZ 
)
noexcept

ctor using +/- x,y,z dimensions

Parameters
[in]_minXthe x position of the min x extent
[in]_maxXthe x position of the max x extent
[in]_minYthe y position of the min y extent
[in]_maxYthe y position of the max y extent
[in]_minZthe z position of the min z extent
[in]_maxZthe z position of the max z extent

Definition at line 141 of file BBox.cpp.

References GL_LINE, GL_LINE_LOOP, m_center, m_depth, m_drawMode, m_height, m_maxX, m_maxY, m_maxZ, m_minX, m_minY, m_minZ, m_vao, m_vert, m_width, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, ngl::Vec3::set(), and setVAO().

+ Here is the call graph for this function:

ngl::BBox::BBox ( )
noexcept

Default constructor will create a BBox centered at point 0,0,0 With Unit length width and height (== 1)

Definition at line 88 of file BBox.cpp.

References GL_LINE, GL_LINE_LOOP, m_center, m_depth, m_drawMode, m_height, m_vao, m_width, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, and setVAO().

+ Here is the call graph for this function:

ngl::BBox::BBox ( const BBox _b)
noexcept

copy ctor

Parameters
[in]_bthe bbox to copy

Definition at line 104 of file BBox.cpp.

References m_center, m_depth, m_drawMode, m_height, m_maxX, m_maxY, m_maxZ, m_minX, m_minY, m_minZ, m_vao, m_width, and recalculate().

+ Here is the call graph for this function:

ngl::BBox::~BBox ( )
noexcept

dtor no dynamic memory so empty

Definition at line 312 of file BBox.cpp.

References m_vao.

Member Function Documentation

Vec3 ngl::BBox::center ( ) const
inlinenoexcept

This is the center of the BBox stored for caluculations in other classes s.

Definition at line 115 of file BBox.h.

Real ngl::BBox::depth ( ) const
inlinenoexcept

Depth of the BBox.

Definition at line 140 of file BBox.h.

void ngl::BBox::depth ( Real  _d,
bool  _recalc = true 
)
noexcept

set the depth

Parameters
[in]_dthe depth to set will re-calculate bbox and VAO
[in]_recalcflag to indicate if we need to recalc the vao defauts to true

Definition at line 284 of file BBox.cpp.

References m_depth, and recalculate().

+ Here is the call graph for this function:

void ngl::BBox::draw ( ) const
noexcept

Draw Method draws the BBox using OpenGL.

Definition at line 229 of file BBox.cpp.

References GL_FILL, GL_FRONT_AND_BACK, glPolygonMode(), m_drawMode, and m_vao.

+ Here is the call graph for this function:

Vec3* ngl::BBox::getNormalArray ( )
inlinenoexcept

the array of normals for the BBox

Definition at line 150 of file BBox.h.

Vec3* ngl::BBox::getVertexArray ( )
inlinenoexcept

the array of verts for the BBox

Definition at line 154 of file BBox.h.

Real ngl::BBox::height ( ) const
inlinenoexcept

Height of the BBox.

Definition at line 130 of file BBox.h.

void ngl::BBox::height ( Real  _h,
bool  _recalc = true 
)
noexcept

set the height

Parameters
[in]_hthe height to set will re-calculate bbox and VAO
[in]_recalcflag to indicate if we need to recalc the vao defauts to true

Definition at line 275 of file BBox.cpp.

References m_height, and recalculate().

+ Here is the call graph for this function:

Real ngl::BBox::maxX ( ) const
inlinenoexcept

the max x value of the bbox

Definition at line 95 of file BBox.h.

Real ngl::BBox::maxY ( ) const
inlinenoexcept

the max y value of the bbox

Definition at line 103 of file BBox.h.

Real ngl::BBox::maxZ ( ) const
inlinenoexcept

the max z value of the bbox

Definition at line 111 of file BBox.h.

Real ngl::BBox::minX ( ) const
inlinenoexcept

the min x value of the bbox

Definition at line 91 of file BBox.h.

Real ngl::BBox::minY ( ) const
inlinenoexcept

the min y value of the bbox

Definition at line 99 of file BBox.h.

Real ngl::BBox::minZ ( ) const
inlinenoexcept

the min z value of the bbox

Definition at line 107 of file BBox.h.

BBox & ngl::BBox::operator= ( const BBox _other)

Definition at line 121 of file BBox.cpp.

References m_center, m_depth, m_drawMode, m_height, m_maxX, m_maxY, m_maxZ, m_minX, m_minY, m_minZ, m_vao, and m_width.

void ngl::BBox::recalculate ( )
noexcept

recalculate the bbox values once things have been changed this will also re-do the VAO

Definition at line 293 of file BBox.cpp.

References m_center, m_depth, m_height, m_vert, m_width, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, and setVAO().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ngl::BBox::setCenter ( const Vec3 _center,
bool  _recalc = true 
)
noexcept

set the center of the BBox and re-calculate the extents

Parameters
_centerthe new center of the BBox

Definition at line 245 of file BBox.cpp.

References m_center, m_depth, m_height, m_vert, m_width, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, and recalculate().

+ Here is the call graph for this function:

void ngl::BBox::setDrawMode ( GLenum  _mode)
noexcept

reset the draw mode for the BBox

Parameters
[in]_modethe mode to draw

Definition at line 177 of file BBox.cpp.

References m_drawMode, and setVAO().

+ Here is the call graph for this function:

void ngl::BBox::setVAO ( )
protected

method used to set the vao

Definition at line 183 of file BBox.cpp.

References ngl::VAOFactory::createVAO(), GL_FLOAT, GL_LINE, GL_LINE_LOOP, GL_STATIC_DRAW, GL_TRIANGLES, GL_UNSIGNED_BYTE, m_drawMode, m_vao, and m_vert.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Real ngl::BBox::width ( ) const
inlinenoexcept

accessor for the width of the BBox

Returns
the width of the BBox

Definition at line 120 of file BBox.h.

void ngl::BBox::width ( Real  _w,
bool  _recalc = true 
)
noexcept

set the width

Parameters
[in]_wthe width to set will re-calculate bbox and VAO
[in]_recalcflag to indicate if we need to recalc the vao defauts to true

Definition at line 266 of file BBox.cpp.

References m_width, and recalculate().

+ Here is the call graph for this function:

Member Data Documentation

Vec3 ngl::BBox::m_center
protected

This is the center of the BBox stored for caluculations in other classes s.

Definition at line 206 of file BBox.h.

Real ngl::BBox::m_depth
protected

Depth of the BBox.

Definition at line 222 of file BBox.h.

GLuint ngl::BBox::m_drawMode
protected

sets the draw mode for the BBox Faces, set to GL_LINE for line faces and GL_FILL for filled

Definition at line 231 of file BBox.h.

Real ngl::BBox::m_height
protected

Height of the BBox.

Definition at line 218 of file BBox.h.

Real ngl::BBox::m_maxX
protected

the max x value of the bbox

Definition at line 186 of file BBox.h.

Real ngl::BBox::m_maxY
protected

the max y value of the bbox

Definition at line 194 of file BBox.h.

Real ngl::BBox::m_maxZ
protected

the max z value of the bbox

Definition at line 202 of file BBox.h.

Real ngl::BBox::m_minX
protected

the min x value of the bbox

Definition at line 182 of file BBox.h.

Real ngl::BBox::m_minY
protected

the min y value of the bbox

Definition at line 190 of file BBox.h.

Real ngl::BBox::m_minZ
protected

the min z value of the bbox

Definition at line 198 of file BBox.h.

Vec3 ngl::BBox::m_norm[6]
protected

used to store the 6 Normal faces for the BBox used for calculating BBox collisions if needed

Definition at line 210 of file BBox.h.

std::unique_ptr< AbstractVAO > ngl::BBox::m_vao
protected

a pointer to the VAO buffer used for drawing the bbox

Definition at line 226 of file BBox.h.

Vec3 ngl::BBox::m_vert[8]
protected

Contains the 8 vertices for the BBox aranged from v[0] = Left-top-Max Z and then rotating clock wise for the top of the BBox The Bottom Square is a mirror of the 1st verts with the Y value changed See constructor code for caluculations.

Definition at line 178 of file BBox.h.

Real ngl::BBox::m_width
protected

Width of the BBox.

Definition at line 214 of file BBox.h.


The documentation for this class was generated from the following files: