Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

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 ()
size_t triangleCount () const
size_t lineCount () const
size_t pointCount () const
void computeNormals ()
 Computes the normals in a "smooth" way, i.e.
virtual void render (const Actor *, const OpenGLContext *, 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< Primitives > * primitives ()
 Returns the list of Primitives objects bound to a Geometry.
const Collection< Primitives > * primitives () const
 Returns the list of Primitives 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 shrinkDrawElements ()
 Tries to convert DrawElementsUInt in DrawElementsUShort/UByte and DrawElementsUShort in DrawElementsUByte in order to use less memory.
void mergeTriangleStrips ()
 Merges the PT_TRIANGLE_STRIP Primitive objects into one single PT_TRIANGLE_STRIP DrawElements.
void convertPrimitivesToDrawArrays ()
 Converts all the Primitives objects bound to a Geometry into DrawArrays.
bool sortVertices ()
 Sorts the vertices of the geometry to maximize vertex-cache coherency.
void sortTriangles ()
 Calls DrawElements::sortTriangles().
void colorizePrimitives ()
 Assigns a random color to each vertex of each Primitives object. If a vertex is shared among more than one Primitives object its color is undefined.
void regenerateVertices (const std::vector< size_t > &map_new_to_old)
void updateVBOs ()
 Updates the vertex buffer objects.


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.

size_t Geometry::triangleCount (  )  const [virtual]

Reimplemented from vl::Renderable.

size_t Geometry::lineCount (  )  const [virtual]

Reimplemented from vl::Renderable.

size_t Geometry::pointCount (  )  const [virtual]

Reimplemented from 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 OpenGLContext ,
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<Primitives>* vl::Geometry::primitives (  )  [inline]

Returns the list of Primitives objects bound to a Geometry.

const Collection<Primitives>* vl::Geometry::primitives (  )  const [inline]

Returns the list of Primitives 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 Primitives 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 Primitives.

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::shrinkDrawElements (  ) 

Tries to convert DrawElementsUInt in DrawElementsUShort/UByte and DrawElementsUShort in DrawElementsUByte in order to use less memory.

void Geometry::mergeTriangleStrips (  ) 

Merges the PT_TRIANGLE_STRIP Primitive objects into one single PT_TRIANGLE_STRIP DrawElements.

void Geometry::convertPrimitivesToDrawArrays (  ) 

Converts all the Primitives 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 Primitives are DrawElements.

Returns:
true if all the Primitives are DrawElements and the sorting took place.

void Geometry::sortTriangles (  ) 

void Geometry::colorizePrimitives (  ) 

Assigns a random color to each vertex of each Primitives object. If a vertex is shared among more than one Primitives 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.


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

Visualization Library v2010.06 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Tue Jun 1 00:57:17 2010.
Permission is granted to use this page to write and publish articles regarding Visualization Library.