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

a class to load in the ASCII houdini .geo files for poly data the spec for the format can be found here http://www.sidefx.com/docs/houdini9.5/io/formats/geo More...

#include <HoudiniGeo.h>

+ Inheritance diagram for ngl::HoudiniGeo:
+ Collaboration diagram for ngl::HoudiniGeo:

Public Member Functions

 HoudiniGeo ()
 default constructor More...
 
 HoudiniGeo (const std::string &_fName)
 ctor passing in the file name to load More...
 
 HoudiniGeo (const std::string &_fName, const std::string &_texName)
 ctor passing in the file name to load and a texture More...
 
void drawDebugPoints ()
 simple debug drawing of points will be removed once class finished More...
 
- Public Member Functions inherited from ngl::AbstractMesh
 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 Member Functions

bool loadHeader (std::ifstream &_stream)
 method to check the header and see if we have a valid geo file it also reads in the ammount of Points ammount of prims and the basic attribute counts More...
 
void loadPointAttribDictionary (std::ifstream &_stream)
 method to load the attribute dictionary from the geo file. At present we are only worried about Normals and UV but this class will be written to be extendable. The main problem is the dictionary can be in any order so we need to find the index into our data for each ones and store it. the dictionary format is as follows Name Size Type Default valid dictionary values are. N a normal uv a uv More...
 
bool load (const std::string &_fName, bool _calcBB=true)
 the main loader for the geo we will have other methods called from this More...
 
void loadPoints (std::ifstream &_stream)
 a method to load the points from the geo file More...
 

Protected Attributes

int m_nPointAttrib
 the number of point attributes More...
 
int m_nVertAttrib
 the number of vertex attributes More...
 
int m_normalTokenIndex
 normal token index used when parsing the geo file More...
 
int m_uvTokenIndex
 uv token index used when paring the geo file More...
 
std::map< std::string, HouDictionaryEntry * > m_dictionary
 map used when parsing the Attribute Data More...
 
- Protected Attributes inherited from ngl::AbstractMesh
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...
 

Detailed Description

a class to load in the ASCII houdini .geo files for poly data the spec for the format can be found here http://www.sidefx.com/docs/houdini9.5/io/formats/geo

Author
Jon Macey
Version
1.0
Date
Last Revision 12/10/09 First version

Definition at line 91 of file HoudiniGeo.h.

Constructor & Destructor Documentation

ngl::HoudiniGeo::HoudiniGeo ( )
inline

default constructor

Definition at line 99 of file HoudiniGeo.h.

ngl::HoudiniGeo::HoudiniGeo ( const std::string _fName)

ctor passing in the file name to load

Parameters
[in]_fNamethe name of the file to load

Definition at line 59 of file HoudiniGeo.cpp.

References load(), ngl::AbstractMesh::m_loaded, and ngl::AbstractMesh::m_vbo.

+ Here is the call graph for this function:

ngl::HoudiniGeo::HoudiniGeo ( const std::string _fName,
const std::string _texName 
)

ctor passing in the file name to load and a texture

Parameters
[in]_fNamethe name of the file to load
[in]_texNamethe name of the texture file to load

Definition at line 68 of file HoudiniGeo.cpp.

References load(), ngl::AbstractMesh::loadTexture(), ngl::AbstractMesh::m_loaded, and ngl::AbstractMesh::m_vbo.

+ Here is the call graph for this function:

Member Function Documentation

void ngl::HoudiniGeo::drawDebugPoints ( void  )

simple debug drawing of points will be removed once class finished

Todo:
write GL3.x code to do this

Definition at line 272 of file HoudiniGeo.cpp.

bool ngl::HoudiniGeo::load ( const std::string _fName,
bool  _calcBB = true 
)
protectedvirtual

the main loader for the geo we will have other methods called from this

Parameters
_fNamethe name of the file to load

Implements ngl::AbstractMesh.

Definition at line 28 of file HoudiniGeo.cpp.

References ngl::AbstractMesh::calcDimensions(), loadHeader(), loadPointAttribDictionary(), loadPoints(), and m_nPointAttrib.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ngl::HoudiniGeo::loadHeader ( std::ifstream &  _stream)
protected

method to check the header and see if we have a valid geo file it also reads in the ammount of Points ammount of prims and the basic attribute counts

Parameters
[in]theopen file stream from the Load method
Returns
true if a valid geo file

Load in the header as specified here Magic Number: PGEOMETRY Point/Prim Counts: NPoints # NPrims # Group Counts: NPointGroups # NPrimGroups # Attribute Counts: NPointAttrib # NVertexAttrib # NPrimAttrib # NAttrib # each of these cases, the # represents the number of the element described

Definition at line 86 of file HoudiniGeo.cpp.

References ngl::AbstractMesh::m_face, ngl::AbstractMesh::m_nFaces, m_normalTokenIndex, m_nPointAttrib, m_nVertAttrib, ngl::AbstractMesh::m_nVerts, m_uvTokenIndex, and ngl::AbstractMesh::m_verts.

+ Here is the caller graph for this function:

void ngl::HoudiniGeo::loadPointAttribDictionary ( std::ifstream &  _stream)
protected

method to load the attribute dictionary from the geo file. At present we are only worried about Normals and UV but this class will be written to be extendable. The main problem is the dictionary can be in any order so we need to find the index into our data for each ones and store it. the dictionary format is as follows Name Size Type Default valid dictionary values are. N a normal uv a uv

Definition at line 214 of file HoudiniGeo.cpp.

References m_dictionary, and m_nPointAttrib.

+ Here is the caller graph for this function:

void ngl::HoudiniGeo::loadPoints ( std::ifstream &  _stream)
protected

a method to load the points from the geo file

Parameters
_fNamethe name of the file to load

now we can actually load the Point data into our vert structure it is going to be formatted in the following way depending upon our dictionary PointAttrib Cd 3 float 0 0 0 # Color attrib., 3 floats, default 0 0 0 Alpha 1 float 1 # Alpha attribute, 1 float, default 1 N 3 float 0 0 0 # Normal attribute uv 2 float 0 0 # Texture coordinate

The data for the point might look like:

0 0 0 1 (1 0 0 1 0 0 1 .5 .5) ^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ Position Attributes

The point would have:

Cd = (1, 0, 0) Alpha = 1 N = (0 0 1) uv = (.5, .5) we already know how many points to load and we have re-sized the data to fit so should the first 4 values are the homogeneous point values

Definition at line 151 of file HoudiniGeo.cpp.

References ngl::AbstractMesh::m_nVerts, and ngl::AbstractMesh::m_verts.

+ Here is the caller graph for this function:

Member Data Documentation

std::map<std::string,HouDictionaryEntry *> ngl::HoudiniGeo::m_dictionary
protected

map used when parsing the Attribute Data

Definition at line 143 of file HoudiniGeo.h.

int ngl::HoudiniGeo::m_normalTokenIndex
protected

normal token index used when parsing the geo file

Definition at line 135 of file HoudiniGeo.h.

int ngl::HoudiniGeo::m_nPointAttrib
protected

the number of point attributes

Definition at line 127 of file HoudiniGeo.h.

int ngl::HoudiniGeo::m_nVertAttrib
protected

the number of vertex attributes

Definition at line 131 of file HoudiniGeo.h.

int ngl::HoudiniGeo::m_uvTokenIndex
protected

uv token index used when paring the geo file

Definition at line 139 of file HoudiniGeo.h.


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