chai3d::cVertexArray Class Reference

This class implements array of 3D vertices. More...

#include <CVertexArray.h>

Public Member Functions

 cVertexArray (const cVertexArrayOptions &a_options)
 
 ~cVertexArray ()
 
void clear ()
 
cVertexArrayPtr copy ()
 
int newVertex ()
 
int newVertices (unsigned int a_numberOfVertices)
 
void setLocalPos (const unsigned int a_vertexIndex, const double &a_x, const double &a_y, const double &a_z)
 
void setLocalPos (const unsigned int a_vertexIndex, const cVector3d &a_pos)
 
void translate (const unsigned int a_vertexIndex, const cVector3d &a_translation)
 
cVector3d getLocalPos (const unsigned int a_vertexIndex) const
 
cVector3d getGlobalPos (const unsigned int a_vertexIndex) const
 
void setNormal (const unsigned int a_vertexIndex, const cVector3d &a_normal)
 
void setNormal (const unsigned int a_vertexIndex, const double &a_x, const double &a_y, const double &a_z)
 
cVector3d getNormal (const unsigned int a_vertexIndex) const
 
void setTexCoord (const unsigned int a_vertexIndex, const cVector3d &a_texCoord)
 
void setTexCoord (const unsigned int a_vertexIndex, const double &a_tx, const double &a_ty=0.0, const double &a_tz=0.0)
 
cVector3d getTexCoord (const unsigned int a_vertexIndex) const
 
void setColor (const unsigned int a_vertexIndex, const cColorf &a_color)
 
void setColor (const unsigned int a_vertexIndex, const float &a_red, const float &a_green, const float &a_blue, const float &a_alpha=1.0)
 
void setColor (const unsigned int a_vertexIndex, const cColorb &a_color)
 
cColorf getColor (const unsigned int a_vertexIndex) const
 
void setTangent (const unsigned int a_vertexIndex, const cVector3d &a_tangent)
 
void setTangent (const unsigned int a_vertexIndex, const double &a_x, const double &a_y, const double &a_z)
 
cVector3d getTangent (const unsigned int a_vertexIndex) const
 
void setBitangent (const unsigned int a_vertexIndex, const cVector3d &a_bitangent)
 
void setBitangent (const unsigned int a_vertexIndex, const double &a_x, const double &a_y, const double &a_z)
 
cVector3d getBitangent (const unsigned int a_vertexIndex) const
 
void setUserData (const unsigned int a_vertexIndex, const int a_userData)
 
int getUserData (const unsigned int a_vertexIndex) const
 
void computeGlobalPosition (const unsigned int a_vertexIndex, const cVector3d &a_globalPos, const cMatrix3d &a_globalRot)
 
unsigned int getNumElements () const
 
bool getUseNormalData () const
 
bool getUseTexCoordData () const
 
bool getUseColorData () const
 
bool getUseTangentData () const
 
bool getUseBitangentData () const
 
bool getUseUserData () const
 
void renderInitialize ()
 
void renderFinalize ()
 
void allocateData (const int a_numberOfVertices, const bool a_useNormalData, const bool a_useTexCoordData, const bool a_useColorData, const bool a_useTangentData, const bool a_useBitangentData, const bool a_useUserData)
 

Static Public Member Functions

static cVertexArrayPtr create (const bool a_useNormalData, const bool a_useTexCoordData, const bool a_useColorData, const bool a_useTangentData, const bool a_useBitangentData, const bool a_useUserData)
 

Public Attributes

std::vector< cVector3dm_localPos
 Local position of vertices. More...
 
std::vector< cVector3dm_globalPos
 Global position of vertices in world coordinates. More...
 
std::vector< cVector3dm_normal
 Surface normal of vertices. More...
 
std::vector< cVector3dm_texCoord
 Texture coordinate (U,V,W) of vertices. More...
 
std::vector< cColorfm_color
 Color of vertices. More...
 
std::vector< cVector3dm_tangent
 Surface tangent of vertices. More...
 
std::vector< cVector3dm_bitangent
 Surface bitangent of vertices. More...
 
std::vector< int > m_userData
 User data of vertices. More...
 
bool m_flagPositionData
 If true then position data has been modified. More...
 
bool m_flagNormalData
 If true then normal data has been modified. More...
 
bool m_flagTexCoordData
 If true then texture coordinate data has been modified. More...
 
bool m_flagColorData
 If true then vertex color data has been modified. More...
 
bool m_flagTangentData
 If true then surface tangent data has been modified. More...
 
bool m_flagBitangentData
 If true then surface bitangent data has been modified. More...
 
bool m_flagUserData
 If true then user data has been modified. More...
 
bool m_flagBufferResize
 If true, then data buffer need to be updated in size. More...
 
GLuint m_positionBuffer
 OpenGL Buffer for storing triangle indices. More...
 
GLuint m_normalBuffer
 OpenGL Buffer for storing triangle indices. More...
 
GLuint m_texCoordBuffer
 OpenGL Buffer for storing triangle indices. More...
 
GLuint m_colorBuffer
 OpenGL Buffer for storing triangle indices. More...
 
GLuint m_tangentBuffer
 OpenGL Buffer for storing triangle indices. More...
 
GLuint m_bitangentBuffer
 OpenGL Buffer for storing triangle indices. More...
 

Protected Attributes

unsigned int m_numVertices
 Number of vertices. More...
 
bool m_useNormalData
 If true then normal data will be allocated for each new vertex. More...
 
bool m_useTexCoordData
 If true then texture coordinate data will be allocated for each new vertex. More...
 
bool m_useColorData
 If true then vertex color data will be allocated for each new vertex. More...
 
bool m_useTangentData
 If true then surface tangent data will be allocated for each new vertex. More...
 
bool m_useBitangentData
 If true then surface bitangent data will be allocated for each new vertex. More...
 
bool m_useUserData
 If true then surface bitangent data will be allocated for each new vertex. More...
 

Detailed Description

cVertexArray defines a an array of 3D vertices (points) that can include properties such as position, color, texture coordinate, and surface normals.
New vertices can be added to the array by calling newVertex() or newVertices(). Once points have been allocated, they cannot be removed, unless the entire array is cleared by calling clear().
The properties of each vertex can be modified by calling the appropriate methods and by passing the vertex index as argument with the associated data.

Constructor & Destructor Documentation

chai3d::cVertexArray::cVertexArray ( const cVertexArrayOptions a_options)
inline

Constructor of cVertexArray. You may define which type of data this vertex array will store. By setting the flag, every time a new vertex is created, the associated data will be allocated and initialized.

Parameters
a_optionsData allocation options.
chai3d::cVertexArray::~cVertexArray ( )
inline

Destructor of cVertexArray.

Member Function Documentation

static cVertexArrayPtr chai3d::cVertexArray::create ( const bool  a_useNormalData,
const bool  a_useTexCoordData,
const bool  a_useColorData,
const bool  a_useTangentData,
const bool  a_useBitangentData,
const bool  a_useUserData 
)
inlinestatic

This method create an instance of cVertexArrayPtr. You may define which type of data this vertex array will store. By setting the flag, every time a new vertex is created, the associated data will be allocated and initialized.

Parameters
a_useNormalDataIf true then normal data is allocated.
a_useTexCoordDataIf true then texture coordinate data is allocated.
a_useColorDataIf true then vertex color data is allocated.
a_useTangentDataIf true then surface tangent data is allocated.
a_useBitangentDataIf true then surface bitangent data is allocated.
a_useUserDataIf true then user data is allocated.
void chai3d::cVertexArray::clear ( )
inline

This method clears all vertex data.

cVertexArrayPtr chai3d::cVertexArray::copy ( )
inline

This method creates copy of this vertex array.

int chai3d::cVertexArray::newVertex ( )
inline

This method creates a new vertex.

Returns
Index number of the new allocated vertex.
int chai3d::cVertexArray::newVertices ( unsigned int  a_numberOfVertices)
inline

This method creates a number of new vertices.

Parameters
a_numberOfVerticesNumber of vertices to create.
Returns
Index number of the first new allocated vertex.
void chai3d::cVertexArray::setLocalPos ( const unsigned int  a_vertexIndex,
const double &  a_x,
const double &  a_y,
const double &  a_z 
)
inline

This method sets the local position data for selected vertex.

Parameters
a_vertexIndexVertex index number.
a_xX position value.
a_yY position value.
a_zZ position value.
void chai3d::cVertexArray::setLocalPos ( const unsigned int  a_vertexIndex,
const cVector3d a_pos 
)
inline

This method sets the local position value for selected vertex.

Parameters
a_vertexIndexVertex index number.
a_posLocal position of vertex.
void chai3d::cVertexArray::translate ( const unsigned int  a_vertexIndex,
const cVector3d a_translation 
)
inline

This method translates a selected vertex by defining a translation offset passed as argument.

Parameters
a_vertexIndexVertex index number.
a_translationTranslation offset.
cVector3d chai3d::cVertexArray::getLocalPos ( const unsigned int  a_vertexIndex) const
inline

This method returns the local position for a selected vertex.

Parameters
a_vertexIndexVertex index number.
Returns
Position of vertex.
cVector3d chai3d::cVertexArray::getGlobalPos ( const unsigned int  a_vertexIndex) const
inline

This method returns the global position of a selected vertex. This value is only correct if the computeGlobalPositions() method has been called previously.

Parameters
a_vertexIndexVertex index number.
Returns
Global position of vertex in world coordinates.
void chai3d::cVertexArray::setNormal ( const unsigned int  a_vertexIndex,
const cVector3d a_normal 
)
inline

This method sets the surface normal vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_normalNormal vector.
void chai3d::cVertexArray::setNormal ( const unsigned int  a_vertexIndex,
const double &  a_x,
const double &  a_y,
const double &  a_z 
)
inline

This method sets the surface normal vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_xX component of normal.
a_yY component of normal.
a_zZ component of normal.
cVector3d chai3d::cVertexArray::getNormal ( const unsigned int  a_vertexIndex) const
inline

This method returns the surface normal vector for selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
Normal vector.
void chai3d::cVertexArray::setTexCoord ( const unsigned int  a_vertexIndex,
const cVector3d a_texCoord 
)
inline

This method sets the texture coordinate for selected vertex.

Parameters
a_vertexIndexVertex index.
a_texCoordTexture coordinate.
void chai3d::cVertexArray::setTexCoord ( const unsigned int  a_vertexIndex,
const double &  a_tx,
const double &  a_ty = 0.0,
const double &  a_tz = 0.0 
)
inline

This method sets the texture coordinate for selected vertex by passing its coordinates as parameters.

Parameters
a_vertexIndexVertex index.
a_txX component of texture coordinate.
a_tyY component of texture coordinate.
a_tzZ component of texture coordinate.
cVector3d chai3d::cVertexArray::getTexCoord ( const unsigned int  a_vertexIndex) const
inline

This method returns the texture coordinate for a selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
Texture coordinate.
void chai3d::cVertexArray::setColor ( const unsigned int  a_vertexIndex,
const cColorf a_color 
)
inline

This method set the color for a selected vertex.

Parameters
a_vertexIndexVertex index.
a_colorColor.
void chai3d::cVertexArray::setColor ( const unsigned int  a_vertexIndex,
const float &  a_red,
const float &  a_green,
const float &  a_blue,
const float &  a_alpha = 1.0 
)
inline

This method set the color of a selected vertex by passing as argument the individual color components.

Parameters
a_vertexIndexVertex index.
a_redRed component.
a_greenGreen component.
a_blueBlue component.
a_alphaAlpha component.
void chai3d::cVertexArray::setColor ( const unsigned int  a_vertexIndex,
const cColorb a_color 
)
inline

This method set color for selected vertex.

Parameters
a_vertexIndexVertex index.
a_colorColor.
cColorf chai3d::cVertexArray::getColor ( const unsigned int  a_vertexIndex) const
inline

This method returns the color for a selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
Color of vertex.
void chai3d::cVertexArray::setTangent ( const unsigned int  a_vertexIndex,
const cVector3d a_tangent 
)
inline

This method sets the tangent vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_tangentTangent vector.
void chai3d::cVertexArray::setTangent ( const unsigned int  a_vertexIndex,
const double &  a_x,
const double &  a_y,
const double &  a_z 
)
inline

This method sets the tangent vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_xX component of tangent.
a_yY component of tangent.
a_zZ component of tangent.
cVector3d chai3d::cVertexArray::getTangent ( const unsigned int  a_vertexIndex) const
inline

This method returns the surface tangent for a selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
Tangent vector.
void chai3d::cVertexArray::setBitangent ( const unsigned int  a_vertexIndex,
const cVector3d a_bitangent 
)
inline

This method sets the bi-tangent vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_bitangentBi-tangent vector.
void chai3d::cVertexArray::setBitangent ( const unsigned int  a_vertexIndex,
const double &  a_x,
const double &  a_y,
const double &  a_z 
)
inline

This method sets the bi-tangent vector for selected vertex.

Parameters
a_vertexIndexVertex index.
a_xX component of bi-tangent.
a_yY component of bi-tangent.
a_zZ component of bi-tangent.
cVector3d chai3d::cVertexArray::getBitangent ( const unsigned int  a_vertexIndex) const
inline

This method returns the surface bitangent for selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
Bitangent vector.
void chai3d::cVertexArray::setUserData ( const unsigned int  a_vertexIndex,
const int  a_userData 
)
inline

This method sets the user data field for selected vertex.

Parameters
a_vertexIndexVertex index.
a_userDataUser data.
int chai3d::cVertexArray::getUserData ( const unsigned int  a_vertexIndex) const
inline

This method returns the user data value for a selected vertex.

Parameters
a_vertexIndexVertex index.
Returns
User data.
void chai3d::cVertexArray::computeGlobalPosition ( const unsigned int  a_vertexIndex,
const cVector3d a_globalPos,
const cMatrix3d a_globalRot 
)
inline

This method computes the global position of vertex given the global position and global rotation matrix of the parent object.

Parameters
a_vertexIndexIndex number of vertex.
a_globalPosGlobal position vector of parent.
a_globalRotGlobal rotation matrix of parent.
unsigned int chai3d::cVertexArray::getNumElements ( ) const
inline

This method returns the number of vertices allocated in this array.

Returns
Number of vertices.
bool chai3d::cVertexArray::getUseNormalData ( ) const
inline

This method checks if normal data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
bool chai3d::cVertexArray::getUseTexCoordData ( ) const
inline

This method check if texture coordinate data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
bool chai3d::cVertexArray::getUseColorData ( ) const
inline

This method checks if color data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
bool chai3d::cVertexArray::getUseTangentData ( ) const
inline

This method checks if tangent data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
bool chai3d::cVertexArray::getUseBitangentData ( ) const
inline

This method checks if bitangent data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
bool chai3d::cVertexArray::getUseUserData ( ) const
inline

This method checks if user data is allocated for each vertex in this array.

Returns
true if data is allocated, false otherwise.
void chai3d::cVertexArray::renderInitialize ( )
inline

This method allocates or updates all OpenGL buffers.

void chai3d::cVertexArray::renderFinalize ( )
inline

This method finalizes rendering by disabling all OpenGL buffers.

void chai3d::cVertexArray::allocateData ( const int  a_numberOfVertices,
const bool  a_useNormalData,
const bool  a_useTexCoordData,
const bool  a_useColorData,
const bool  a_useTangentData,
const bool  a_useBitangentData,
const bool  a_useUserData 
)
inline

This method allocate data for vertex array.

Parameters
a_numberOfVerticesNumber of new vertices to be allocated
a_useNormalDataIf true then normal data is allocated.
a_useTexCoordDataIf__true__ then texture coordinate data is allocated.
a_useColorDataIf true then vertex color data is allocated.
a_useTangentDataIf true then surface tangent data is allocated.
a_useBitangentDataIf true then surface bitangent data is allocated.
a_useUserDataIf true then user data data is allocated.

Member Data Documentation

std::vector<cVector3d> chai3d::cVertexArray::m_localPos
std::vector<cVector3d> chai3d::cVertexArray::m_globalPos
std::vector<cVector3d> chai3d::cVertexArray::m_normal
std::vector<cVector3d> chai3d::cVertexArray::m_texCoord
std::vector<cColorf> chai3d::cVertexArray::m_color
std::vector<cVector3d> chai3d::cVertexArray::m_tangent
std::vector<cVector3d> chai3d::cVertexArray::m_bitangent
std::vector<int> chai3d::cVertexArray::m_userData
unsigned int chai3d::cVertexArray::m_numVertices
protected
bool chai3d::cVertexArray::m_useNormalData
protected
bool chai3d::cVertexArray::m_useTexCoordData
protected
bool chai3d::cVertexArray::m_useColorData
protected
bool chai3d::cVertexArray::m_useTangentData
protected
bool chai3d::cVertexArray::m_useBitangentData
protected
bool chai3d::cVertexArray::m_useUserData
protected
bool chai3d::cVertexArray::m_flagPositionData
bool chai3d::cVertexArray::m_flagNormalData
bool chai3d::cVertexArray::m_flagTexCoordData
bool chai3d::cVertexArray::m_flagColorData
bool chai3d::cVertexArray::m_flagTangentData
bool chai3d::cVertexArray::m_flagBitangentData
bool chai3d::cVertexArray::m_flagUserData
bool chai3d::cVertexArray::m_flagBufferResize
GLuint chai3d::cVertexArray::m_positionBuffer
GLuint chai3d::cVertexArray::m_normalBuffer
GLuint chai3d::cVertexArray::m_texCoordBuffer
GLuint chai3d::cVertexArray::m_colorBuffer
GLuint chai3d::cVertexArray::m_tangentBuffer
GLuint chai3d::cVertexArray::m_bitangentBuffer

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