GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
Glip::CorePipeline::GeometryPrimitives::CustomModel Class Reference

Geometry : build a model. More...

#include <Geometry.hpp>

Inheritance diagram for Glip::CorePipeline::GeometryPrimitives::CustomModel:
Inheritance graph

Public Member Functions

 CustomModel (int _dim, GLenum _primitiveGL, bool _hasNormals, bool _hasTexCoords)
 CustomModel constructor. More...
 
void increaseVerticesReservation (size_t nNewVertices)
 Prepare the memory to receive a new number of vertices. More...
 
void reserveElements (size_t nVertices)
 Prepare the memory to receive a number of elements. More...
 
void increaseElementsReservation (size_t nNewVertices)
 Prepare the memory to receive a new number of elements. More...
 
void newVertices2DInterleaved (const size_t N, const GLfloat *interleavedXY, const GLfloat *interleavedNormalsXY=NULL, const GLfloat *interleavedUV=NULL)
 Add multiple vertives in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void newVertices2D (const size_t N, const GLfloat *x, const GLfloat *y, const GLfloat *nx=NULL, const GLfloat *ny=NULL, const GLfloat *u=NULL, const GLfloat *v=NULL)
 Add multiple vertices in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
GLuint newVertex2D (const GLfloat &x, const GLfloat &y, const GLfloat &nx=0.0f, const GLfloat &ny=0.0f, const GLfloat &u=0.0f, const GLfloat &v=0.0f)
 Add a vertex in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void newVertices3DInterleaved (const size_t N, const GLfloat *interleavedXYZ, const GLfloat *interleavedNormalsXYZ=NULL, const GLfloat *interleavedUV=NULL)
 Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void newVertices3D (const size_t N, const GLfloat *x, const GLfloat *y, const GLfloat *z, const GLfloat *nx=NULL, const GLfloat *ny=NULL, const GLfloat *nz=NULL, const GLfloat *u=NULL, const GLfloat *v=NULL)
 Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
GLuint newVertex3D (const GLfloat &x, const GLfloat &y, const GLfloat &z, const GLfloat &nx=0.0f, const GLfloat &ny=0.0f, const GLfloat &nz=0.0f, const GLfloat &u=0.0f, const GLfloat &v=0.0f)
 Add a vertex in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void newElementsInterleaved (const size_t N, GLuint *interleavedIndices)
 Add primitive elements to the model. More...
 
void newElements (const size_t N, GLuint *a, GLuint *b=NULL, GLuint *c=NULL, GLuint *d=NULL)
 Add primitive elements to the model. More...
 
GLuint newElement (GLuint a)
 Add a primitive element to the model. More...
 
GLuint newElement (GLuint a, GLuint b)
 Add a primitive element to the model. More...
 
GLuint newElement (GLuint a, GLuint b, GLuint c)
 Add a primitive element to the model. More...
 
GLuint newElement (GLuint a, GLuint b, GLuint c, GLuint d)
 Add a primitive element to the model. More...
 
GLuint newElement (const std::vector< GLuint > &indices)
 Add a primitive element to the model. More...
 
void generateNormals (void)
 Automatically generate the normals.
 
- Public Member Functions inherited from Glip::CorePipeline::GeometryModel
 GeometryModel (const GeometryModel &mdl)
 GeometryModel copy constructor. More...
 
unsigned int getNumVertices (void) const
 Get the number of vertices. More...
 
unsigned int getNumElements (void) const
 Get the number of GL primitives (elements). More...
 
const GLfloat & x (GLuint i) const
 Read the X coordinate of the vertex at given index. More...
 
const GLfloat & y (GLuint i) const
 Read the Y coordinate of the vertex at given index. More...
 
const GLfloat & z (GLuint i) const
 Read the Z coordinate of the vertex at given index. More...
 
const GLfloat & ny (GLuint i) const
 Access the Y coordinate of the normal at given index. More...
 
const GLfloat & u (GLuint i) const
 Access the U coordinate of the texel at given index. More...
 
const GLfloat & v (GLuint i) const
 Access the V coordinate of the texel at given index. More...
 
const GLuint & a (GLuint i) const
 Access the index of the first vertex of the element at given index. More...
 
const GLuint & b (GLuint i) const
 Access the index of the second vertex of the element at given index. More...
 
const GLuint & c (GLuint i) const
 Access the index of the third vertex of the element at given index. More...
 
bool testIndices (void) const
 Test if all the indices are valid. More...
 
bool operator== (const GeometryModel &mdl) const
 Test if two models are identical. More...
 
HdlVBOgetVBO (GLenum freq) const
 Get the VBO corresponding to this model. It is not recommended to use directly the VBO but, instead, use a GeometryInstance object. More...
 

Additional Inherited Members

- Public Types inherited from Glip::CorePipeline::GeometryModel
enum  GeometryType {
  CustomModel,
  StandardQuad,
  ReversedQuad,
  PointsGrid2D,
  PointsGrid3D,
  Unknown
}
 Description of the type of geometry (automatic). More...
 
- Static Public Member Functions inherited from Glip::CorePipeline::GeometryModel
static int getNumVerticesInPrimitive (const GLenum &_primitiveGL)
 Get the number of vertices per element for the given primitive. More...
 
static int getPrimitiveStride (const GLenum &_primitiveGL)
 Get the stride between elements of the given primitive. More...
 
- Public Attributes inherited from Glip::CorePipeline::GeometryModel
const GeometryType type
 Geometry Type.
 
const bool hasNormals
 True if it has texture coordinates attached.
 
const bool hasTexCoords
 Dimension of the geometry (either 2 or 3).
 
const int dim
 True if it has normals data attached.
 
const int numVerticesPerElement
 Number of vertices per elements of the geometry.
 
const int elementStride
 Stride between the elements.
 
const GLenum primitiveGL
 ID of the primitive for GL.
 
- Protected Member Functions inherited from Glip::CorePipeline::GeometryModel
 GeometryModel (GeometryType _type, int _dim, GLenum _primitiveGL, bool _hasNormals, bool _hasTexCoords)
 Geometry model constructor. More...
 
void reserveVertices (size_t nVertices)
 Prepare the memory to receive a number of vertices. More...
 
void increaseVerticesReservation (size_t nNewVertices)
 Prepare the memory to receive a new number of vertices. More...
 
void reserveElements (size_t nVertices)
 Prepare the memory to receive a number of elements. More...
 
void increaseElementsReservation (size_t nNewVertices)
 Prepare the memory to receive a new number of elements. More...
 
void addVertices2DInterleaved (const size_t N, const GLfloat *interleavedXY, const GLfloat *interleavedNormalsXY=NULL, const GLfloat *interleavedUV=NULL)
 Add multiple vertives in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void addVertices2D (const size_t N, const GLfloat *x, const GLfloat *y, const GLfloat *nx=NULL, const GLfloat *ny=NULL, const GLfloat *u=NULL, const GLfloat *v=NULL)
 Add multiple vertices in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
GLuint addVertex2D (const GLfloat &x, const GLfloat &y, const GLfloat &nx=0.0f, const GLfloat &ny=0.0f, const GLfloat &u=0.0f, const GLfloat &v=0.0f)
 Add a vertex in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void addVertices3DInterleaved (const size_t N, const GLfloat *interleavedXYZ, const GLfloat *interleavedNormalsXYZ=NULL, const GLfloat *interleavedUV=NULL)
 Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void addVertices3D (const size_t N, const GLfloat *x, const GLfloat *y, const GLfloat *z, const GLfloat *nx=NULL, const GLfloat *ny=NULL, const GLfloat *nz=NULL, const GLfloat *u=NULL, const GLfloat *v=NULL)
 Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
GLuint addVertex3D (const GLfloat &x, const GLfloat &y, const GLfloat &z, const GLfloat &nx=0.0f, const GLfloat &ny=0.0f, const GLfloat &nz=0.0f, const GLfloat &u=0.0f, const GLfloat &v=0.0f)
 Add a vertex in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate. More...
 
void addElementsInterleaved (const size_t N, GLuint *interleavedIndices)
 Add primitive elements to the model. More...
 
void addElements (const size_t N, GLuint *a, GLuint *b=NULL, GLuint *c=NULL, GLuint *d=NULL)
 Add primitive elements to the model. More...
 
GLuint addElement (GLuint a)
 Add a primitive element to the model. More...
 
GLuint addElement (GLuint a, GLuint b)
 Add a primitive element to the model. More...
 
GLuint addElement (GLuint a, GLuint b, GLuint c)
 Add a primitive element to the model. More...
 
GLuint addElement (GLuint a, GLuint b, GLuint c, GLuint d)
 Add a primitive element to the model. More...
 
GLuint addElement (const std::vector< GLuint > &indices)
 Add (a) primitive element(s) to the model. More...
 
GLfloat & x (GLuint i)
 Access the X coordinate of the vertex at given index. More...
 
GLfloat & y (GLuint i)
 Access the Y coordinate of the vertex at given index. More...
 
GLfloat & z (GLuint i)
 Access the Z coordinate of the vertex at given index. More...
 
GLfloat & nx (GLuint i)
 Access the X coordinate of the normal at given index. More...
 
GLfloat & ny (GLuint i)
 Access the Y coordinate of the normal at given index. More...
 
GLfloat & u (GLuint i)
 Access the U coordinate of the texel at given index. More...
 
GLfloat & v (GLuint i)
 Access the V coordinate of the texel at given index. More...
 
GLuint & a (GLuint i)
 Access the index of the first vertex of the element at given index. More...
 
GLuint & b (GLuint i)
 Access the index of the second vertex of the element at given index. More...
 
GLuint & c (GLuint i)
 Access the index of the third vertex of the element at given index. More...
 
void generateNormals (void)
 Automatically generate the normals. More...
 

Detailed Description

Geometry : build a model.

Constructor & Destructor Documentation

CustomModel::CustomModel ( int  _dim,
GLenum  _primitiveGL,
bool  _hasNormals,
bool  _hasTexCoords 
)

CustomModel constructor.

Parameters
_dimThe minimum number of spatial dimensions needed to describe the geometry (either 2 or 3).
_primitiveGLThe GL ID of the element primitive (eg. GL_POINTS, GL_LINES, GL_TRIANGLES, etc.)
_hasNormalsSet to true if the geometry has normals data attached.
_hasTexCoordsSet to true if the geometry has texel coordinates attached.

Member Function Documentation

void CustomModel::increaseElementsReservation ( size_t  nNewElements)

Prepare the memory to receive a new number of elements.

Parameters
nNewElementsThe number of elements to be added.
void CustomModel::increaseVerticesReservation ( size_t  nNewVertices)

Prepare the memory to receive a new number of vertices.

Parameters
nNewVerticesThe number of vertices to be added.
GLuint CustomModel::newElement ( GLuint  a)

Add a primitive element to the model.

Parameters
aIndex of the first vertex.
Returns
The index of the newly created element.
GLuint CustomModel::newElement ( GLuint  a,
GLuint  b 
)

Add a primitive element to the model.

Parameters
aIndex of the first vertex.
bIndex of the second vertex.
Returns
The index of the newly created element.
GLuint CustomModel::newElement ( GLuint  a,
GLuint  b,
GLuint  c 
)

Add a primitive element to the model.

Parameters
aIndex of the first vertex.
bIndex of the second vertex.
cIndex of the third vertex.
Returns
The index of the newly created element.
GLuint CustomModel::newElement ( GLuint  a,
GLuint  b,
GLuint  c,
GLuint  d 
)

Add a primitive element to the model.

Parameters
aIndex of the first vertex.
bIndex of the second vertex.
cIndex of the third vertex.
dIndex of the fourth vertex.
Returns
The index of the newly created element.
GLuint CustomModel::newElement ( const std::vector< GLuint > &  indices)

Add a primitive element to the model.

Parameters
indicesA vector containing the indices of all the vertices used.
Returns
The index of the newly created element.
void CustomModel::newElements ( const size_t  N,
GLuint *  a,
GLuint *  b = NULL,
GLuint *  c = NULL,
GLuint *  d = NULL 
)

Add primitive elements to the model.

Parameters
NNumber of primitive elements.
aFirst vertices indices.
bSecond vertices indices.
cThird vertices indices.
dFourth vertices indices.

All arrays must contain N indices.

void CustomModel::newElementsInterleaved ( const size_t  N,
GLuint *  interleavedIndices 
)

Add primitive elements to the model.

Parameters
NNumber of primitive elements.
interleavedIndicesArray of vertices indices. Must contain N*numVerticesPerElement indices.
GLuint CustomModel::newVertex2D ( const GLfloat &  x,
const GLfloat &  y,
const GLfloat &  nx = 0.0f,
const GLfloat &  ny = 0.0f,
const GLfloat &  u = 0.0f,
const GLfloat &  v = 0.0f 
)

Add a vertex in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
xThe X coordinate.
yThe Y coordinate.
nxThe X component of the normal.
nyThe Y component of the normal.
uThe U coordinate for the texel (ignored if GeometryModel::hasTexCoords is set to false).
vThe V coordinate for the texel (ignored if GeometryModel::hasTexCoords is set to false).
Returns
The index of the newly created vertex.
GLuint CustomModel::newVertex3D ( const GLfloat &  x,
const GLfloat &  y,
const GLfloat &  z,
const GLfloat &  nx = 0.0f,
const GLfloat &  ny = 0.0f,
const GLfloat &  nz = 0.0f,
const GLfloat &  u = 0.0f,
const GLfloat &  v = 0.0f 
)

Add a vertex in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
xThe X coordinate.
yThe Y coordinate.
zThe Z coordinate.
nxThe X component of the normal.
nyThe Y component of the normal.
nzThe Z component of the normal.
uThe U coordinate for the texel (ignored if GeometryModel::hasTexCoords is set to false).
vThe V coordinate for the texel (ignored if GeometryModel::hasTexCoords is set to false).
Returns
The index of the newly created vertex.
void CustomModel::newVertices2D ( const size_t  N,
const GLfloat *  x,
const GLfloat *  y,
const GLfloat *  nx = NULL,
const GLfloat *  ny = NULL,
const GLfloat *  u = NULL,
const GLfloat *  v = NULL 
)

Add multiple vertices in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
NThe number of vertices to be added.
xThe array of spatial X coordinates.
yThe array of spatial Y coordinates.
nxThe array of normal components along X.
nyThe array of normal components along Y.
uThe array of texture U coordinates.
vThe array of texture V coordinates.

All arrays must contain N indices.

void CustomModel::newVertices2DInterleaved ( const size_t  N,
const GLfloat *  interleavedXY,
const GLfloat *  interleavedNormalsXY = NULL,
const GLfloat *  interleavedUV = NULL 
)

Add multiple vertives in a two dimensions space (GeometryModel::dim must be equal to 2). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
NThe number of vertices to be added.
interleavedXYThe interleaved array of the spatial coordinates.
interleavedNormalsXYThe interleaved array of the normals data.
interleavedUVThe interleaved array of the texture coordinates.

The vertices coordinates array must contain N*dim elements. The texture coordinates array must contain 2*N elements.

void CustomModel::newVertices3D ( const size_t  N,
const GLfloat *  x,
const GLfloat *  y,
const GLfloat *  z,
const GLfloat *  nx = NULL,
const GLfloat *  ny = NULL,
const GLfloat *  nz = NULL,
const GLfloat *  u = NULL,
const GLfloat *  v = NULL 
)

Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
NThe number of vertices to be added.
xThe array of spatial X coordinates.
yThe array of spatial Y coordinates.
zThe array of spatial Z coordinates.
nxThe array of normal components along X.
nyThe array of normal components along Y.
nzThe array of normal components along Z.
uThe array of texture U coordinates.
vThe array of texture V coordinates.

All arrays must contain N indices.

void CustomModel::newVertices3DInterleaved ( const size_t  N,
const GLfloat *  interleavedXYZ,
const GLfloat *  interleavedNormalsXYZ = NULL,
const GLfloat *  interleavedUV = NULL 
)

Add multiple vertices in a three dimensions space (GeometryModel::dim must be equal to 3). If GeometryModel::hasTexCoords is true, then it will also use u and v to create a texel coordinate.

Parameters
NThe number of vertices to be added.
interleavedXYZThe interleaved array of the spatial coordinates.
interleavedNormalsXYZThe interleaved array of the normals data.
interleavedUVThe interleaved array of the texture coordinates.

The vertices coordinates array must contain N*dim elements. The texture coordinates array must contain 2*N elements.

void CustomModel::reserveElements ( size_t  nElements)

Prepare the memory to receive a number of elements.

Parameters
nElementsThe total number of elements to contain.

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