Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]
Classes | Public Member Functions | Static Public Member Functions

vl::Geometry Class Reference

The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points. More...

#include <Geometry.hpp>

Inheritance diagram for vl::Geometry:
vl::Renderable vl::Object vl::BezierSurface

List of all members.

Classes

class  TextureArray

Public Member Functions

virtual const char * className ()
 Returns the name of the class.
 Geometry ()
 Constructor.
virtual ~Geometry ()
 Destructor.
ref< GeometryshallowCopy ()
 Performs a shallow copy (as opposed to a deep copy) of the specified Geometry.
ref< GeometrydeepCopy () const
 Performs a deep copy (as opposed to a shallow copy) of the specified Geometry.
Geometryoperator= (const Geometry &other)
 Performs a shallowCopy() of the Geometry.
virtual void computeBounds_Implementation ()
void computeNormals ()
 Computes the normals in a "smooth" way, i.e.
virtual void render (const Actor *, const Camera *) const
 Renders the Renderable.
virtual void clearArrays (bool clear_draw_calls=true)
 Removes all the previously installed arrays.
void setColorArray (const fvec4 &col)
 Filles the color array with a single color.
void setVertexArray (ArrayAbstract *data)
void setNormalArray (ArrayAbstract *data)
void setColorArray (ArrayAbstract *data)
void setSecondaryColorArray (ArrayAbstract *data)
void setFogCoordArray (ArrayAbstract *data)
void setTexCoordArray (int tex_unit, ArrayAbstract *data)
const ArrayAbstractvertexArray () const
ArrayAbstractvertexArray ()
const ArrayAbstractnormalArray () const
ArrayAbstractnormalArray ()
const ArrayAbstractcolorArray () const
ArrayAbstractcolorArray ()
const ArrayAbstractsecondaryColorArray () const
ArrayAbstractsecondaryColorArray ()
const ArrayAbstractfogCoordArray () const
ArrayAbstractfogCoordArray ()
const ArrayAbstracttexCoordArray (int tex_unit) const
ArrayAbstracttexCoordArray (int tex_unit)
Collection
< VertexAttributeArray > * 
vertexAttributeArrays ()
 Returns the list of VertexAttributeArray objects bound to a Geometry.
const Collection
< VertexAttributeArray > * 
vertexAttributeArrays () const
 Returns the list of VertexAttributeArray objects bound to a Geometry.
void setVertexAttributeArray (unsigned int name, bool normalize, bool pure_integer, ArrayAbstract *data)
void setVertexAttributeArray (const VertexAttributeArray &info)
const VertexAttributeArrayfindVertexAttribute (unsigned int name) const
VertexAttributeArrayfindVertexAttribute (unsigned int name)
void eraseVertexAttributeByName (unsigned int name)
Collection< DrawCall > * drawCalls ()
 Returns the list of DrawCall objects bound to a Geometry.
const Collection< DrawCall > * drawCalls () const
 Returns the list of DrawCall objects bound to a Geometry.
void updateVBOs (bool discard_local_data=false)
 Uploads the data stored in the local buffers on the GPU memory.
void deleteVBOs ()
 Destroyes the VBO (VertexBufferObjects) associated to this Geometry attributes.
void transform (const mat4 &matr, bool normalize=true)
 Transforms vertices and normals belonging to this geometry.
void mergeTriangleStrips ()
 Merges all the PT_TRIANGLE_STRIP DrawElementsUInt objects into one single PT_TRIANGLE_STRIP DrawElementsUInt.
void convertDrawCallToDrawArrays ()
 Converts all the DrawCall objects bound to a Geometry into DrawArrays.
bool sortVertices ()
 Sorts the vertices of the geometry to maximize vertex-cache coherency.
void colorizePrimitives ()
 Assigns a random color to each vertex of each DrawCall object. If a vertex is shared among more than one DrawCall object its color is undefined.
void regenerateVertices (const std::vector< size_t > &map_new_to_old)
void updateVBOs ()
 Updates the vertex buffer objects.

Static Public Member Functions

static void computeTangentSpace (size_t vert_count, const vl::fvec3 *vertex, const vl::fvec3 *normal, const vl::fvec2 *texcoord, const vl::DrawCall *primitives, vl::fvec3 *tangent, vl::fvec3 *bitangent)
 Computes the tangent (and optionally bitangent) vectors used to form a TBN matrix to be used for bumpmapping.

Detailed Description

The Geometry class is a Renderable that implements a polygonal mesh made of polygons, lines and points.

See also:

Constructor & Destructor Documentation

Geometry::Geometry (  )

Constructor.

Geometry::~Geometry (  ) [virtual]

Destructor.


Member Function Documentation

virtual const char* vl::Geometry::className (  ) [inline, virtual]

Returns the name of the class.

Reimplemented from vl::Renderable.

Reimplemented in vl::BezierSurface.

ref< Geometry > Geometry::shallowCopy (  )

Performs a shallow copy (as opposed to a deep copy) of the specified Geometry.

See also:
deepCopy()
ref< Geometry > Geometry::deepCopy (  ) const

Performs a deep copy (as opposed to a shallow copy) of the specified Geometry.

See also:
shallowCopy()
Geometry & Geometry::operator= ( const Geometry other )

Performs a shallowCopy() of the Geometry.

void Geometry::computeBounds_Implementation (  ) [virtual]

Implements vl::Renderable.

void Geometry::computeNormals (  )

Computes the normals in a "smooth" way, i.e.

averaging the normals of those polygons that share one or more vertices.

This function computes smoothed normals for triangle primitives and leaves unchanged the normals of line and point primitives when possible, i.e. when they don't share vertices with the polygonal primitives.

Note:
This function modifies the local buffers. After calling this you might want to update the buffers allocated on the GPU.
void Geometry::render ( const Actor actor,
const Camera camera 
) const [virtual]

Renders the Renderable.

Implements vl::Renderable.

void Geometry::clearArrays ( bool  clear_draw_calls = true ) [virtual]

Removes all the previously installed arrays.

void Geometry::setColorArray ( const fvec4 col )

Filles the color array with a single color.

If the color array has been already defined it must be of one of the following types: ArrayFVec3, ArrayFVec4, ArrayUByte3, ArrayUBVec4 If no color array has been defined a new ArrayUBVec4 is installed and filled.

Remarks:
Since the color array element count will be set to the number elements in the position array this function must be called after the position array has been defined.
void Geometry::setVertexArray ( ArrayAbstract data )
void Geometry::setNormalArray ( ArrayAbstract data )
void Geometry::setColorArray ( ArrayAbstract data )
void Geometry::setSecondaryColorArray ( ArrayAbstract data )
void Geometry::setFogCoordArray ( ArrayAbstract data )
void Geometry::setTexCoordArray ( int  tex_unit,
ArrayAbstract data 
)
const ArrayAbstract* vl::Geometry::vertexArray (  ) const [inline]
ArrayAbstract* vl::Geometry::vertexArray (  ) [inline]
const ArrayAbstract* vl::Geometry::normalArray (  ) const [inline]
ArrayAbstract* vl::Geometry::normalArray (  ) [inline]
const ArrayAbstract* vl::Geometry::colorArray (  ) const [inline]
ArrayAbstract* vl::Geometry::colorArray (  ) [inline]
const ArrayAbstract* vl::Geometry::secondaryColorArray (  ) const [inline]
ArrayAbstract* vl::Geometry::secondaryColorArray (  ) [inline]
const ArrayAbstract* vl::Geometry::fogCoordArray (  ) const [inline]
ArrayAbstract* vl::Geometry::fogCoordArray (  ) [inline]
const ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit ) const [inline]
ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit ) [inline]
Collection<VertexAttributeArray>* vl::Geometry::vertexAttributeArrays (  ) [inline]

Returns the list of VertexAttributeArray objects bound to a Geometry.

const Collection<VertexAttributeArray>* vl::Geometry::vertexAttributeArrays (  ) const [inline]

Returns the list of VertexAttributeArray objects bound to a Geometry.

void vl::Geometry::setVertexAttributeArray ( unsigned int  name,
bool  normalize,
bool  pure_integer,
ArrayAbstract data 
) [inline]
void Geometry::setVertexAttributeArray ( const VertexAttributeArray info )
const VertexAttributeArray * Geometry::findVertexAttribute ( unsigned int  name ) const
VertexAttributeArray * Geometry::findVertexAttribute ( unsigned int  name )
void Geometry::eraseVertexAttributeByName ( unsigned int  name )
Collection<DrawCall>* vl::Geometry::drawCalls (  ) [inline]

Returns the list of DrawCall objects bound to a Geometry.

const Collection<DrawCall>* vl::Geometry::drawCalls (  ) const [inline]

Returns the list of DrawCall objects bound to a Geometry.

void Geometry::updateVBOs ( bool  = false ) [virtual]

Uploads the data stored in the local buffers on the GPU memory.

If 'discard_local_data' is set to true the memory used by the local buffers is released.

Reimplemented from vl::Renderable.

void Geometry::deleteVBOs (  ) [virtual]

Destroyes the VBO (VertexBufferObjects) associated to this Geometry attributes.

If 'clear_primitives' all the VBOs associated the DrawCall objects are also deleted.

Note:
This function does not touch the local (non GPU) data stored in the buffers associated to the vertex attributes and DrawCall.

Reimplemented from vl::Renderable.

void Geometry::transform ( const mat4 matr,
bool  normalize = true 
)

Transforms vertices and normals belonging to this geometry.

If 'normalize' == true the normals are normalized after being transformed

Note:
This functions supports every possible vertex format, type and layout.
See also:
void Geometry::mergeTriangleStrips (  )

Merges all the PT_TRIANGLE_STRIP DrawElementsUInt objects into one single PT_TRIANGLE_STRIP DrawElementsUInt.

void Geometry::convertDrawCallToDrawArrays (  )

Converts all the DrawCall objects bound to a Geometry into DrawArrays.

bool Geometry::sortVertices (  )

Sorts the vertices of the geometry to maximize vertex-cache coherency.

This function will work only if all the DrawCall are DrawElements.

Returns:
true if all the DrawCall are DrawElements and the sorting took place.
void Geometry::colorizePrimitives (  )

Assigns a random color to each vertex of each DrawCall object. If a vertex is shared among more than one DrawCall object its color is undefined.

void Geometry::regenerateVertices ( const std::vector< size_t > &  map_new_to_old )
void vl::Geometry::updateVBOs (  )

Updates the vertex buffer objects.

void Geometry::computeTangentSpace ( size_t  vert_count,
const vl::fvec3 vertex,
const vl::fvec3 normal,
const vl::fvec2 texcoord,
const vl::DrawCall primitives,
vl::fvec3 tangent,
vl::fvec3 bitangent 
) [static]

Computes the tangent (and optionally bitangent) vectors used to form a TBN matrix to be used for bumpmapping.

Parameters:
vert_countThe number of elements stored in vertex, normal, texcoord, tangent and bitangent.
vertexArray containing the vertex positions.
normalArray containing the normals of the vertices.
texcoordArray containing the 2d texture coordinates of the bumpmap.
primitivesThe triangles, quads etc. defining the geometry of the object.
tangent[out] Returns the tangent vector of the vertices. This parameter is mandatory.
bitangent[out] Returns the bitangent vector of the vertics. This parameter can be NULL.

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

Visualization Library v2010.11.1123 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Thu Nov 18 2010 02:08:02.
Permission is granted to use this page to write and publish articles regarding Visualization Library.