NGL  6.5
The NCCA Graphics Library
ngl::AbstractMesh Class Referenceabstract

an abstract base mesh used to build specific meshes such as Obj More...

#include <AbstractMesh.h>

+ Inheritance diagram for ngl::AbstractMesh:
+ Collaboration diagram for ngl::AbstractMesh:

Public Member Functions

virtual bool load (const std::string &_fname, bool _calcBB=true) noexcept=0
 Method to load the file in. More...
 
 AbstractMesh () noexcept
 default ctor must be called from the child class so our dtor is called More...
 
virtual ~AbstractMesh () noexcept
 destructor this will clear out all the vert data and the vbo if created More...
 
void drawBBox () const noexcept
 method to draw the bounding box More...
 
void draw () const noexcept
 draw method to draw the obj as a VBO. The VBO first needs to be created using the CreateVBO method More...
 
void loadTexture (const std::string &_fname) noexcept
 load int a texture and set it as the active texture of the Obj More...
 
void scale (Real _sx, Real _sy, Real _sz) noexcept
 scale the obj by multiplying the actual vertex values by sx,sy and sz More...
 
void calcDimensions () noexcept
 a method to set the BBox and center More...
 
void calcBoundingSphere () noexcept
 a method to caluculate the bounding Sphere will set m_sphereCenter and m_sphereRadius More...
 
void writeToRibSubdiv (RibExport &_ribFile) const noexcept
 
virtual void createVAO () noexcept
 
unsigned int getTextureID () const noexcept
 get the texture id More...
 
RealmapVAOVerts () noexcept
 map the VBO vertex data More...
 
void unMapVAO () noexcept
 unmap the VBO based More...
 
const std::vector< IndexRef > & getIndices () noexcept
 get a pointer to the indices used to represent the VBO data, this is used in the clip class when re-ordering the clip data values More...
 
void saveNCCABinaryMesh (const std::string &_fname) noexcept
 save the mesh as NCCA Binary VBO format basically this format is the processed binary vbo mesh data as as packed by the CreateVBO() method is called. More...
 
BBoxgetBBox () noexcept
 a method to get the current bounding box of the mesh More...
 
std::vector< Vec3getVertexList () noexcept
 accessor for the vertex data More...
 
Vec3 getVertexAtIndex (uint32_t _i) const noexcept
 accessor for the vertex data More...
 
std::vector< Vec3getNormalList () noexcept
 accessor for the normals data More...
 
std::vector< Vec3getTextureCordList () noexcept
 accessor for the texture co-ordinates data More...
 
std::vector< FacegetFaceList () noexcept
 accessor for the Face data More...
 
unsigned int getNumVerts () const noexcept
 accessor to get the number of vertices in the object More...
 
unsigned int getNumNormals () const noexcept
 accessor to get the number of normals in the object More...
 
unsigned int getNumTexCords () const noexcept
 accessor to get the number of texture co-ordinates in the object More...
 
unsigned int getNumFaces () const noexcept
 accessor to get the number of faces in the object More...
 
unsigned int getMeshSize () const noexcept
 
Vec3 getSphereCenter () const noexcept
 accesor to get the bounding sphere center More...
 
Real getSphereRadius () const noexcept
 accesor to get the bounding sphere center More...
 
Vec3 getCenter () const noexcept
 accesor to get the center More...
 
bool isTriangular () noexcept
 check to see if obj is triangulated as we only support tri or quad objs at the moment More...
 

Protected Attributes

unsigned int m_nVerts
 The number of vertices in the object. More...
 
unsigned int m_nNorm
 The number of normals in the object. More...
 
unsigned int m_nTex
 the number of texture co-ordinates in the object More...
 
unsigned int m_nFaces
 the number of faces in the object More...
 
std::vector< Vec3m_verts
 Pointer to the Vertex list. More...
 
std::vector< Vec3m_norm
 Pointer to the Normal List. More...
 
std::vector< Vec3m_tex
 Pointer to the Texture co-ord list (note that only x and y are used) More...
 
std::vector< Facem_face
 Pointer to the Face list. More...
 
Vec3 m_center
 Center of the object. More...
 
std::vector< IndexRefm_indices
 a vector of indices used to pass the index into the Data arrays to the VBO More...
 
std::vector< GLuintm_outIndices
 a vectr of indices without duplicates which are actually passed to the VBO when creating More...
 
size_t m_indexSize
 the size of the index array More...
 
size_t m_meshSize
 
GLuint m_vboBuffers
 buffers for the VBO in order Vert, Tex, Norm More...
 
std::unique_ptr< AbstractVAOm_vaoMesh
 id for our vertexArray object More...
 
bool m_vbo
 flag to indicate if a VBO has been created More...
 
bool m_vao
 flag to indicate if a VBO has been created More...
 
bool m_vboMapped
 flag to indicate if the VBO vertex data has been mapped More...
 
bool m_texture
 flag to indicate if texture assigned More...
 
GLuint m_textureID
 The openGL id of the texture for the texture generation. More...
 
Real m_maxX
 The Maximum X value in the obj file used to calculate the extents bbox. More...
 
Real m_minX
 The Min X value in the obj file used to calculate the extents bbox. More...
 
Real m_maxY
 The Max Y value in the obj file used to calculate the extents bbox. More...
 
Real m_minY
 The Min Y value in the obj file used to calculate the extents bbox. More...
 
Real m_maxZ
 The Max Z value in the obj file used to calculate the extents bbox. More...
 
Real m_minZ
 The Min Z value in the obj file used to calculate the extents bbox. More...
 
std::unique_ptr< BBoxm_ext
 Create a bounding box of the object to store it's extents. More...
 
GLuint m_dataPackType
 determines if the data is Packed as either TRI or QUAD More...
 
unsigned int m_bufferPackSize
 the size of the buffer pack we use this for the saving of bin vbo but it actually holds the size of the data (3 for just verts 5 verts norms etc) More...
 
GLenum m_vboDrawType
 which type of VBO are we going to draw More...
 
bool m_loaded
 flag to indicate if anything loaded for dtor More...
 
Vec3 m_sphereCenter
 the center of the bounding sphere More...
 
Real m_sphereRadius
 the radius of the bounding sphere More...
 

Friends

class NCCAPointBake
 

Detailed Description

an abstract base mesh used to build specific meshes such as Obj

Author
Jonathan Macey
Version
1.0
Date
24/09/09 Last Revision 16/06/10 added accessors for the mesh elements

Definition at line 105 of file AbstractMesh.h.

Constructor & Destructor Documentation

ngl::AbstractMesh::AbstractMesh ( )
inlinenoexcept

default ctor must be called from the child class so our dtor is called

Definition at line 118 of file AbstractMesh.h.

ngl::AbstractMesh::~AbstractMesh ( )
virtualnoexcept

destructor this will clear out all the vert data and the vbo if created

Definition at line 60 of file AbstractMesh.cpp.

References glDeleteBuffers, m_face, m_indices, m_loaded, m_norm, m_outIndices, m_tex, m_vbo, m_vboBuffers, and m_verts.

Member Function Documentation

void ngl::AbstractMesh::calcBoundingSphere ( )
noexcept

a method to caluculate the bounding Sphere will set m_sphereCenter and m_sphereRadius

modified from example in Rick Parent book Computer Animation Algorithms and Techniques Morgan Korfman Appendix B

Definition at line 501 of file AbstractMesh.cpp.

References m_sphereCenter, m_sphereRadius, m_verts, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

void ngl::AbstractMesh::calcDimensions ( )
noexcept

a method to set the BBox and center

Definition at line 387 of file AbstractMesh.cpp.

References m_center, m_ext, m_maxX, m_maxY, m_maxZ, m_minX, m_minY, m_minZ, m_nVerts, m_verts, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

+ Here is the caller graph for this function:

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

draw method to draw the obj as a VBO. The VBO first needs to be created using the CreateVBO method

Definition at line 336 of file AbstractMesh.cpp.

References GL_TEXTURE_2D, glBindTexture(), m_texture, m_textureID, m_vao, and m_vaoMesh.

+ Here is the call graph for this function:

void ngl::AbstractMesh::drawBBox ( ) const
noexcept

method to draw the bounding box

Definition at line 36 of file AbstractMesh.cpp.

References m_ext.

BBox& ngl::AbstractMesh::getBBox ( )
inlinenoexcept

a method to get the current bounding box of the mesh

Returns
the bounding box for the loaded mesh;

Definition at line 195 of file AbstractMesh.h.

Vec3 ngl::AbstractMesh::getCenter ( ) const
inlinenoexcept

accesor to get the center

Definition at line 254 of file AbstractMesh.h.

std::vector<Face> ngl::AbstractMesh::getFaceList ( )
inlinenoexcept

accessor for the Face data

Returns
a std::vector containing the face data

Definition at line 225 of file AbstractMesh.h.

+ Here is the caller graph for this function:

const std::vector<IndexRef>& ngl::AbstractMesh::getIndices ( )
inlinenoexcept

get a pointer to the indices used to represent the VBO data, this is used in the clip class when re-ordering the clip data values

Returns
the array of indices

Definition at line 183 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::getMeshSize ( ) const
inlinenoexcept

Definition at line 242 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::getNormalList ( )
inlinenoexcept

accessor for the normals data

Returns
a std::vector containing the normal data

Definition at line 215 of file AbstractMesh.h.

References ngl::Face::m_norm.

unsigned int ngl::AbstractMesh::getNumFaces ( ) const
inlinenoexcept

accessor to get the number of faces in the object

Definition at line 241 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::getNumNormals ( ) const
inlinenoexcept

accessor to get the number of normals in the object

Definition at line 233 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::getNumTexCords ( ) const
inlinenoexcept

accessor to get the number of texture co-ordinates in the object

Definition at line 237 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::getNumVerts ( ) const
inlinenoexcept

accessor to get the number of vertices in the object

Definition at line 229 of file AbstractMesh.h.

Vec3 ngl::AbstractMesh::getSphereCenter ( ) const
inlinenoexcept

accesor to get the bounding sphere center

Definition at line 246 of file AbstractMesh.h.

Real ngl::AbstractMesh::getSphereRadius ( ) const
inlinenoexcept

accesor to get the bounding sphere center

Definition at line 250 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::getTextureCordList ( )
inlinenoexcept

accessor for the texture co-ordinates data

Returns
a std::vector containing the texture cord data

Definition at line 220 of file AbstractMesh.h.

References ngl::Face::m_tex.

unsigned int ngl::AbstractMesh::getTextureID ( ) const
inlinenoexcept

get the texture id

Returns
the texture id

Definition at line 168 of file AbstractMesh.h.

Vec3 ngl::AbstractMesh::getVertexAtIndex ( uint32_t  _i) const
inlinenoexcept

accessor for the vertex data

Returns
a std::vector containing the vert data

Definition at line 205 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::getVertexList ( )
inlinenoexcept

accessor for the vertex data

Returns
a std::vector containing the vert data

Definition at line 200 of file AbstractMesh.h.

bool ngl::AbstractMesh::isTriangular ( )
noexcept

check to see if obj is triangulated as we only support tri or quad objs at the moment

Returns
true or false

Definition at line 186 of file AbstractMesh.cpp.

References m_face.

+ Here is the caller graph for this function:

virtual bool ngl::AbstractMesh::load ( const std::string _fname,
bool  _calcBB = true 
)
pure virtualnoexcept

Method to load the file in.

Parameters
[in]&_fnamethe name of the obj file to load

Implemented in ngl::HoudiniGeo, ngl::Obj, and ngl::NCCABinMesh.

void ngl::AbstractMesh::loadTexture ( const std::string _fname)
noexcept

load int a texture and set it as the active texture of the Obj

Parameters
[in]&_fnamethe name of the file to load

Definition at line 80 of file AbstractMesh.cpp.

References m_texture, m_textureID, and ngl::Texture::setTextureGL().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Real * ngl::AbstractMesh::mapVAOVerts ( )
noexcept

map the VBO vertex data

Returns
a pointer to the VBO vertex data

Definition at line 353 of file AbstractMesh.cpp.

References GL_ARRAY_BUFFER, GL_READ_WRITE, glBindBuffer, glMapBuffer, m_vaoMesh, and m_vboMapped.

+ Here is the caller graph for this function:

void ngl::AbstractMesh::saveNCCABinaryMesh ( const std::string _fname)
noexcept

save the mesh as NCCA Binary VBO format basically this format is the processed binary vbo mesh data as as packed by the CreateVBO() method is called.

The number of vertices in the object

The number of normals in the object

the number of texture co-ordinates in the object

the number of faces in the object

now we can dump the data from the vbo

Definition at line 431 of file AbstractMesh.cpp.

References m_bufferPackSize, m_center, m_dataPackType, m_indexSize, m_maxX, m_maxY, m_maxZ, m_minX, m_minY, m_minZ, m_nFaces, m_nNorm, m_nTex, m_nVerts, m_outIndices, m_texture, ngl::Vec3::m_x, ngl::Vec3::m_y, ngl::Vec3::m_z, mapVAOVerts(), and unMapVAO().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ngl::AbstractMesh::scale ( Real  _sx,
Real  _sy,
Real  _sz 
)
noexcept

scale the obj by multiplying the actual vertex values by sx,sy and sz

Parameters
[in]_sxthe scale value in x
[in]_sythe scale value in y
[in]_szthe scale value in z

Definition at line 41 of file AbstractMesh.cpp.

References calcDimensions(), m_center, m_nVerts, m_verts, and ngl::Vec3::m_x.

+ Here is the call graph for this function:

void ngl::AbstractMesh::unMapVAO ( )
noexcept

unmap the VBO based

Definition at line 375 of file AbstractMesh.cpp.

References GL_ARRAY_BUFFER, glUnmapBuffer, m_vaoMesh, and m_vboMapped.

+ Here is the caller graph for this function:

void ngl::AbstractMesh::writeToRibSubdiv ( RibExport _ribFile) const
noexcept

method to write out the obj mesh to a renderman sub div

Parameters
[in]_ribFilethe instance of the RibExport class
Todo:
correct the rib exporter and add Normal information to the export
/// The following code is adapted from an MSc project by
/// Authors: Elaine Kieran, Gavin Harrison, Luke Openshaw
/// Write the obj as a SubdivisionMesh package to the rib file
/// Renderman specification: SubdivisionMesh scheme nverts vertids tags nargs intargs floatargs parameterlist
/// 

Definition at line 98 of file AbstractMesh.cpp.

References FCompare, m_face, m_nVerts, and m_verts.

Friends And Related Function Documentation

friend class NCCAPointBake
friend

Definition at line 262 of file AbstractMesh.h.

Member Data Documentation

unsigned int ngl::AbstractMesh::m_bufferPackSize
protected

the size of the buffer pack we use this for the saving of bin vbo but it actually holds the size of the data (3 for just verts 5 verts norms etc)

Definition at line 375 of file AbstractMesh.h.

Vec3 ngl::AbstractMesh::m_center
protected

Center of the object.

Definition at line 297 of file AbstractMesh.h.

GLuint ngl::AbstractMesh::m_dataPackType
protected

determines if the data is Packed as either TRI or QUAD

Definition at line 370 of file AbstractMesh.h.

std::unique_ptr<BBox> ngl::AbstractMesh::m_ext
protected

Create a bounding box of the object to store it's extents.

Definition at line 366 of file AbstractMesh.h.

std::vector<Face> ngl::AbstractMesh::m_face
protected

Pointer to the Face list.

Definition at line 293 of file AbstractMesh.h.

size_t ngl::AbstractMesh::m_indexSize
protected

the size of the index array

Definition at line 309 of file AbstractMesh.h.

std::vector<IndexRef> ngl::AbstractMesh::m_indices
protected

a vector of indices used to pass the index into the Data arrays to the VBO

Definition at line 301 of file AbstractMesh.h.

bool ngl::AbstractMesh::m_loaded
protected

flag to indicate if anything loaded for dtor

Definition at line 384 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_maxX
protected

The Maximum X value in the obj file used to calculate the extents bbox.

Definition at line 342 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_maxY
protected

The Max Y value in the obj file used to calculate the extents bbox.

Definition at line 350 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_maxZ
protected

The Max Z value in the obj file used to calculate the extents bbox.

Definition at line 358 of file AbstractMesh.h.

size_t ngl::AbstractMesh::m_meshSize
protected

Definition at line 310 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_minX
protected

The Min X value in the obj file used to calculate the extents bbox.

Definition at line 346 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_minY
protected

The Min Y value in the obj file used to calculate the extents bbox.

Definition at line 354 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_minZ
protected

The Min Z value in the obj file used to calculate the extents bbox.

Definition at line 362 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::m_nFaces
protected

the number of faces in the object

Definition at line 277 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::m_nNorm
protected

The number of normals in the object.

Definition at line 269 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::m_norm
protected

Pointer to the Normal List.

Definition at line 285 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::m_nTex
protected

the number of texture co-ordinates in the object

Definition at line 273 of file AbstractMesh.h.

unsigned int ngl::AbstractMesh::m_nVerts
protected

The number of vertices in the object.

Definition at line 265 of file AbstractMesh.h.

std::vector<GLuint> ngl::AbstractMesh::m_outIndices
protected

a vectr of indices without duplicates which are actually passed to the VBO when creating

Definition at line 305 of file AbstractMesh.h.

Vec3 ngl::AbstractMesh::m_sphereCenter
protected

the center of the bounding sphere

Definition at line 388 of file AbstractMesh.h.

Real ngl::AbstractMesh::m_sphereRadius
protected

the radius of the bounding sphere

Definition at line 392 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::m_tex
protected

Pointer to the Texture co-ord list (note that only x and y are used)

Definition at line 289 of file AbstractMesh.h.

bool ngl::AbstractMesh::m_texture
protected

flag to indicate if texture assigned

Definition at line 334 of file AbstractMesh.h.

GLuint ngl::AbstractMesh::m_textureID
protected

The openGL id of the texture for the texture generation.

Definition at line 338 of file AbstractMesh.h.

bool ngl::AbstractMesh::m_vao
protected

flag to indicate if a VBO has been created

Definition at line 326 of file AbstractMesh.h.

std::unique_ptr<AbstractVAO> ngl::AbstractMesh::m_vaoMesh
protected

id for our vertexArray object

Definition at line 318 of file AbstractMesh.h.

bool ngl::AbstractMesh::m_vbo
protected

flag to indicate if a VBO has been created

Definition at line 322 of file AbstractMesh.h.

GLuint ngl::AbstractMesh::m_vboBuffers
protected

buffers for the VBO in order Vert, Tex, Norm

Definition at line 314 of file AbstractMesh.h.

GLenum ngl::AbstractMesh::m_vboDrawType
protected

which type of VBO are we going to draw

Definition at line 379 of file AbstractMesh.h.

bool ngl::AbstractMesh::m_vboMapped
protected

flag to indicate if the VBO vertex data has been mapped

Definition at line 330 of file AbstractMesh.h.

std::vector<Vec3> ngl::AbstractMesh::m_verts
protected

Pointer to the Vertex list.

Definition at line 281 of file AbstractMesh.h.


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