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 | Protected Member Functions | Protected Attributes

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::IVertexAttribSet 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.
void shallowCopy (Geometry *)
 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.
void deepCopy (Geometry *) 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 render (const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context) const
 Renders the Renderable.
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 setNormal (const fvec3 &normal)
 Geometry normal used when no normal array is defined.
const fvec3normal ()
 Geometry normal used when no normal array is defined.
void setColor (const fvec4 &color)
 Geometry color used when no color array is defined.
const fvec4color ()
 Geometry color used when no color array is defined.
void setSecondaryColor (const fvec4 &color)
 Geometry color used when no color array is defined.
const fvec4secondaryColor ()
 Geometry color used when no color array is defined.
void computeNormals ()
 Computes the normals in a "smooth" way, i.e.
void transform (const mat4 &matr, bool normalize=true)
 Transforms vertices and normals belonging to this geometry.
virtual void clearArrays (bool clear_draw_calls=true)
 Removes all the previously installed arrays.
void updateVBOs (bool discard_local_data=false, bool force_update=false)
 Updates all the vertex buffer objects of both vertex arrays and draw calls.
void deleteVBOs ()
 Deletes all the vertex buffer objects of both vertex arrays and draw calls.
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 setVertexArray (ArrayAbstract *data)
 Conventional vertex array.
const ArrayAbstractvertexArray () const
 Conventional vertex array.
ArrayAbstractvertexArray ()
 Conventional vertex array.
void setNormalArray (ArrayAbstract *data)
 Conventional normal array.
const ArrayAbstractnormalArray () const
 Conventional normal array.
ArrayAbstractnormalArray ()
 Conventional normal array.
void setColorArray (ArrayAbstract *data)
 Conventional color array.
const ArrayAbstractcolorArray () const
 Conventional color array.
ArrayAbstractcolorArray ()
 Conventional color array.
void setSecondaryColorArray (ArrayAbstract *data)
 Conventional secondary color array.
const ArrayAbstractsecondaryColorArray () const
 Conventional secondary color array.
ArrayAbstractsecondaryColorArray ()
 Conventional secondary color array.
void setFogCoordArray (ArrayAbstract *data)
 Conventional fog array.
const ArrayAbstractfogCoordArray () const
 Conventional fog array.
ArrayAbstractfogCoordArray ()
 Conventional fog array.
void setTexCoordArray (int tex_unit, ArrayAbstract *data)
 Conventional texture coords arrays.
const ArrayAbstracttexCoordArray (int tex_unit) const
 Conventional texture coords arrays.
ArrayAbstracttexCoordArray (int tex_unit)
 Conventional texture coords arrays.
int texCoordArrayCount () const
void getTexCoordArrayAt (int i, int &out_tex_unit, const ArrayAbstract *&tex_array) const
void setVertexAttribArray (unsigned int attrib_idx, bool normalize, bool pure_integer, ArrayAbstract *data)
void setVertexAttribArray (const VertexAttribInfo &info)
 Binds a generic vertex attribute.
const ArrayAbstractvertexAttrib (unsigned int attrib_idx) const
 Returns a generic vertex attribute.
ArrayAbstractvertexAttrib (unsigned int attrib_idx)
 Returns a generic vertex attribute.
const VertexAttribInfovertexAttribInfo (unsigned int attrib_idx) const
 Returns a generic vertex attribute's info.
VertexAttribInfovertexAttribInfo (unsigned int attrib_idx)
 Returns a generic vertex attribute's info.
ref< VertexAttribInfoeraseVertexAttrib (unsigned int attrib_idx)
int vertexAttribInfoCount () const
 Returns the number of generic vertex attribute arrays bound.
const VertexAttribInfogetVertexAttribInfoAt (int i) const
 Returns i-th VertexAttribInfo, where i is not out_attrib_info.attribIndex().
Collection< VertexAttribInfo > * vertexAttribArrays ()
 The list of VertexAttribInfo objects bound to a Geometry.
const Collection
< VertexAttribInfo > * 
vertexAttribArrays () const
 The list of VertexAttribInfo objects bound to a Geometry.

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.

Protected Member Functions

virtual void computeBounds_Implementation ()

Protected Attributes

Collection< DrawCallmDrawCalls
fvec4 mColor
fvec4 mSecondaryColor
fvec3 mNormal
ref< ArrayAbstractmVertexArray
ref< ArrayAbstractmNormalArray
ref< ArrayAbstractmColorArray
ref< ArrayAbstractmSecondaryColorArray
ref< ArrayAbstractmFogCoordArray
Collection< TextureArraymTexCoordArrays
Collection< VertexAttribInfomVertexAttribArrays

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()
void Geometry::shallowCopy ( Geometry geom )

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()
void Geometry::deepCopy ( Geometry geom ) 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::render ( const Actor actor,
const Shader shader,
const Camera camera,
OpenGLContext gl_context 
) const [virtual]

Renders the Renderable.

Implements vl::Renderable.

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 vl::Geometry::setNormal ( const fvec3 normal ) [inline]

Geometry normal used when no normal array is defined.

const fvec3& vl::Geometry::normal (  ) [inline]

Geometry normal used when no normal array is defined.

void vl::Geometry::setColor ( const fvec4 color ) [inline]

Geometry color used when no color array is defined.

const fvec4& vl::Geometry::color (  ) [inline]

Geometry color used when no color array is defined.

void vl::Geometry::setSecondaryColor ( const fvec4 color ) [inline]

Geometry color used when no color array is defined.

const fvec4& vl::Geometry::secondaryColor (  ) [inline]

Geometry color used when no color array is defined.

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::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::clearArrays ( bool  clear_draw_calls = true ) [virtual]

Removes all the previously installed arrays.

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

Updates all the vertex buffer objects of both vertex arrays and draw calls.

Implements vl::Renderable.

void Geometry::deleteVBOs (  ) [virtual]

Deletes all the vertex buffer objects of both vertex arrays and draw calls.

Reimplemented from vl::Renderable.

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 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.
void Geometry::setVertexArray ( ArrayAbstract data ) [virtual]

Conventional vertex array.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::vertexArray (  ) const [inline, virtual]

Conventional vertex array.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::vertexArray (  ) [inline, virtual]

Conventional vertex array.

Implements vl::IVertexAttribSet.

void Geometry::setNormalArray ( ArrayAbstract data ) [virtual]

Conventional normal array.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::normalArray (  ) const [inline, virtual]

Conventional normal array.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::normalArray (  ) [inline, virtual]

Conventional normal array.

Implements vl::IVertexAttribSet.

void Geometry::setColorArray ( ArrayAbstract data ) [virtual]

Conventional color array.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::colorArray (  ) const [inline, virtual]

Conventional color array.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::colorArray (  ) [inline, virtual]

Conventional color array.

Implements vl::IVertexAttribSet.

void Geometry::setSecondaryColorArray ( ArrayAbstract data ) [virtual]

Conventional secondary color array.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::secondaryColorArray (  ) const [inline, virtual]

Conventional secondary color array.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::secondaryColorArray (  ) [inline, virtual]

Conventional secondary color array.

Implements vl::IVertexAttribSet.

void Geometry::setFogCoordArray ( ArrayAbstract data ) [virtual]

Conventional fog array.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::fogCoordArray (  ) const [inline, virtual]

Conventional fog array.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::fogCoordArray (  ) [inline, virtual]

Conventional fog array.

Implements vl::IVertexAttribSet.

void Geometry::setTexCoordArray ( int  tex_unit,
ArrayAbstract data 
) [virtual]

Conventional texture coords arrays.

Implements vl::IVertexAttribSet.

const ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit ) const [inline, virtual]

Conventional texture coords arrays.

Implements vl::IVertexAttribSet.

ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit ) [inline, virtual]

Conventional texture coords arrays.

Implements vl::IVertexAttribSet.

int vl::Geometry::texCoordArrayCount (  ) const [inline, virtual]

Implements vl::IVertexAttribSet.

void vl::Geometry::getTexCoordArrayAt ( int  i,
int &  out_tex_unit,
const ArrayAbstract *&  tex_array 
) const [inline, virtual]

Implements vl::IVertexAttribSet.

void vl::Geometry::setVertexAttribArray ( unsigned int  attrib_idx,
bool  normalize,
bool  pure_integer,
ArrayAbstract data 
) [inline]
void Geometry::setVertexAttribArray ( const VertexAttribInfo info ) [virtual]

Binds a generic vertex attribute.

Implements vl::IVertexAttribSet.

const ArrayAbstract * Geometry::vertexAttrib ( unsigned int  attrib_idx ) const [virtual]

Returns a generic vertex attribute.

Implements vl::IVertexAttribSet.

ArrayAbstract * Geometry::vertexAttrib ( unsigned int  attrib_idx ) [virtual]

Returns a generic vertex attribute.

Implements vl::IVertexAttribSet.

const VertexAttribInfo * Geometry::vertexAttribInfo ( unsigned int  attrib_idx ) const [virtual]

Returns a generic vertex attribute's info.

Implements vl::IVertexAttribSet.

VertexAttribInfo * Geometry::vertexAttribInfo ( unsigned int  attrib_idx ) [virtual]

Returns a generic vertex attribute's info.

Implements vl::IVertexAttribSet.

ref< VertexAttribInfo > Geometry::eraseVertexAttrib ( unsigned int  attrib_idx ) [virtual]

Implements vl::IVertexAttribSet.

int vl::Geometry::vertexAttribInfoCount (  ) const [inline, virtual]

Returns the number of generic vertex attribute arrays bound.

Implements vl::IVertexAttribSet.

const VertexAttribInfo* vl::Geometry::getVertexAttribInfoAt ( int  i ) const [inline, virtual]

Returns i-th VertexAttribInfo, where i is not out_attrib_info.attribIndex().

Implements vl::IVertexAttribSet.

Collection<VertexAttribInfo>* vl::Geometry::vertexAttribArrays (  ) [inline]

The list of VertexAttribInfo objects bound to a Geometry.

const Collection<VertexAttribInfo>* vl::Geometry::vertexAttribArrays (  ) const [inline]

The list of VertexAttribInfo objects bound to a Geometry.

void Geometry::computeBounds_Implementation (  ) [protected, virtual]

Implements vl::Renderable.


Member Data Documentation


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

Visualization Library v2010.11.1125 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Fri Nov 26 2010 10:33:45.
Permission is granted to use this page to write and publish articles regarding Visualization Library.