# 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:

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< Geometry > | shallowCopy ()
| Performs a shallow copy (as opposed to a deep copy) of the specified Geometry.
ref< Geometry > | deepCopy () const
| Performs a deep copy (as opposed to a shallow copy) of the specified Geometry.
Geometry & | operator= (const Geometry &other)
| Performs a shallowCopy() of the Geometry.
virtual void | computeBounds_Implementation ()
int | triangleCount () const
int | lineCount () const
int | 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 (unsigned char tex_unit, ArrayAbstract *data)
const ArrayAbstract * | vertexArray () const
ArrayAbstract * | vertexArray ()
const ArrayAbstract * | normalArray () const
ArrayAbstract * | normalArray ()
const ArrayAbstract * | colorArray () const
ArrayAbstract * | colorArray ()
const ArrayAbstract * | secondaryColorArray () const
ArrayAbstract * | secondaryColorArray ()
const ArrayAbstract * | fogCoordArray () const
ArrayAbstract * | fogCoordArray ()
const ArrayAbstract * | texCoordArray (unsigned char tex_unit) const
ArrayAbstract * | texCoordArray (unsigned char tex_unit)
std::vector< ref< ArrayAbstract > > | texCoordArrays ()
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 VertexAttributeArray * | findVertexAttribute (unsigned int name) const
VertexAttributeArray * | findVertexAttribute (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< unsigned int > &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:
  - ArrayAbstract
  - Renderable
  - Actor
  - Transform
  - Effect

## 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.

int Geometry::triangleCount | ( |  | ) | const`[virtual]`

Reimplemented from vl::Renderable.

int Geometry::lineCount | ( |  | ) | const`[virtual]`

Reimplemented from vl::Renderable.

int 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 | ( | unsigned char | 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 | ( | unsigned char | tex_unit | ) | const`[inline]`

ArrayAbstract* vl::Geometry::texCoordArray | ( | unsigned char | tex_unit | ) | `[inline]`

std::vector< ref<ArrayAbstract> > vl::Geometry::texCoordArrays | ( |  | ) | `[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 | discard_local_data = `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:
  - ArrayAbstract::transform()
  - ArrayAbstract::normalize()
  - ArrayAbstract::computeBoundingSphere()
  - ArrayAbstract::computeBoundingBox()

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

Calls DrawElements::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< unsigned int > & | map_new_to_old | ) |

void vl::Geometry::updateVBOs | ( |  | ) |

Updates the vertex buffer objects.

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

- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/Geometry.hpp
- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/Geometry.cpp

Visualization Library v2009.07 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Mon Aug 10 21:41:35 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.