Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
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:

Public Member Functions

 Geometry ()
 Constructor. More...
 
virtual ~Geometry ()
 Destructor. More...
 
ref< GeometryshallowCopy () const
 Performs a shallow copy of a Geometry. More...
 
GeometryshallowCopyFrom (const Geometry &)
 Performs a shallow copy of the specified Geometry. More...
 
ref< GeometrydeepCopy () const
 Performs a deep copy of a Geometry. More...
 
GeometrydeepCopyFrom (const Geometry &)
 Performs a deep copy of the specified Geometry. More...
 
Collection< DrawCall > & drawCalls ()
 Returns the list of DrawCall objects bound to a Geometry. More...
 
const Collection< DrawCall > & drawCalls () const
 Returns the list of DrawCall objects bound to a Geometry. More...
 
void setColorArray (const fvec4 &color)
 Fills the color array with the given color. More...
 
virtual void clearArrays (bool clear_draw_calls=true)
 Removes all the previously installed arrays. More...
 
virtual void updateDirtyBufferObject (EBufferObjectUpdateMode mode)
 Updates all the vertex buffer objects of both vertex arrays and draw calls that are marked as dirty. More...
 
virtual void deleteBufferObject ()
 Deletes all the vertex buffer objects of both vertex arrays and draw calls. More...
 
void computeNormals (bool verbose=false)
 Computes the normals in a "smooth" way, i.e. More...
 
bool flipNormals ()
 Inverts the orientation of the normals. More...
 
void fixTriangleWinding ()
 Converts all draw calls to triangles and fixes their winding according to the Geometry's normals. More...
 
void transform (const mat4 &matr, bool normalize=true)
 Transforms vertices and normals belonging to this geometry. More...
 
void convertDrawCallToDrawArrays ()
 Converts all the DrawCall objects bound to a Geometry into DrawArrays. More...
 
DrawCallmergeTriangleStrips ()
 Merges all the PT_TRIANGLE_STRIP DrawElementsUInt objects into one single PT_TRIANGLE_STRIP DrawElementsUInt. More...
 
void mergeDrawCallsWithPrimitiveRestart (EPrimitiveType primitive_type)
 Merges all the draw calls that use the given primitive type into one single draw call using primitive restart. More...
 
void mergeDrawCallsWithMultiDrawElements (EPrimitiveType primitive_type)
 Merges all the draw calls that use the given primitive type into one single MultiDrawElements draw call. More...
 
void mergeDrawCallsWithTriangles (EPrimitiveType primitive_type)
 Merges all the draw calls that use the given primitive type or PT_TRIANGLES into one single PT_TRIANGLES draw call. More...
 
void triangulateDrawCalls ()
 Converts PT_QUADS, PT_QUADS_STRIP and PT_POLYGON into PT_TRIANGLE primitives. More...
 
DrawRangeElements *MultiDrawElements *to the best fitting of *UInt UShort UByte *taking into instancing and base vertex *note Primitive type can be any *void shrinkDrawCalls ()
 
void makeGLESFriendly ()
 Calls triangulateDrawCalls() and shrinkDrawCalls(). More...
 
bool sortVertices ()
 Sorts the vertices of the geometry (position, normals, textures, colors etc.) to maximize vertex-cache coherency. More...
 
void regenerateVertices (const std::vector< u32 > &map_new_to_old)
 Regenerates the vertex position and attributes using the given new-to-old map. More...
 
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. More...
 
void setVertexArray (ArrayAbstract *data)
 Conventional vertex array. More...
 
const ArrayAbstractvertexArray () const
 Conventional vertex array. More...
 
ArrayAbstractvertexArray ()
 Conventional vertex array. More...
 
void setNormalArray (ArrayAbstract *data)
 Conventional normal array. More...
 
const ArrayAbstractnormalArray () const
 Conventional normal array. More...
 
ArrayAbstractnormalArray ()
 Conventional normal array. More...
 
void setColorArray (ArrayAbstract *data)
 Conventional color array. More...
 
const ArrayAbstractcolorArray () const
 Conventional color array. More...
 
ArrayAbstractcolorArray ()
 Conventional color array. More...
 
void setSecondaryColorArray (ArrayAbstract *data)
 Conventional secondary color array. More...
 
const ArrayAbstractsecondaryColorArray () const
 Conventional secondary color array. More...
 
ArrayAbstractsecondaryColorArray ()
 Conventional secondary color array. More...
 
void setFogCoordArray (ArrayAbstract *data)
 Conventional fog array. More...
 
const ArrayAbstractfogCoordArray () const
 Conventional fog array. More...
 
ArrayAbstractfogCoordArray ()
 Conventional fog array. More...
 
void setTexCoordArray (int tex_unit, ArrayAbstract *data)
 Conventional texture coords arrays. More...
 
const ArrayAbstracttexCoordArray (int tex_unit) const
 Conventional texture coords arrays. More...
 
ArrayAbstracttexCoordArray (int tex_unit)
 Conventional texture coords arrays. More...
 
void setVertexAttribArray (int attrib_location, const ArrayAbstract *info)
 Binds a generic vertex attribute. More...
 
const ArrayAbstractvertexAttribArray (int attrib_location) const
 Returns a generic vertex attribute's info. More...
 
ArrayAbstractvertexAttribArray (int attrib_location)
 Returns a generic vertex attribute's info. More...
 
- Public Member Functions inherited from vl::Renderable
 Renderable ()
 Constructor. More...
 
virtual ~Renderable ()
 Destructor. More...
 
void render (const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context)
 Renders the Renderable and if necessary compiles the display list and updates the BufferObjects. More...
 
void computeBounds ()
 Recomputes the bounding box and bounding sphere of a Renderable. More...
 
long long boundsUpdateTick () const
 Returns the bounds-update-tick which is a counter incremented every time the bounding box or bounding sphere is updated. More...
 
void setBoundsDirty (bool dirty)
 Marks the bounding box and bounding sphere as dirty in order to be recomputed at the next rendering. More...
 
bool boundsDirty () const
 Returns whether the bounding sphere or bounding box are "dirty", that is, meant to be recomputed. More...
 
void setBoundingBox (const AABB &aabb)
 Sets the bounding box of a Renderable. More...
 
void setBoundingSphere (const Sphere &sphere)
 Sets the bounding sphere of a Renderable. More...
 
const AABBboundingBox () const
 Returns the bounding box of a Renderable without recomputing the bounds if dirty. More...
 
const SphereboundingSphere () const
 Returns the bounding sphere of a Renderable without recomputing the bounds if dirty. More...
 
const AABBboundingBox ()
 Returns the bounding box of a Renderable recomputing the bounds if dirty. More...
 
const SphereboundingSphere ()
 Returns the bounding sphere of a Renderable recomputing the bounds if dirty. More...
 
unsigned int displayList () const
 Returns the display list associated to a Renderable or 0 (zero) if no display list is associated. More...
 
void setDisplayList (unsigned int disp_list)
 Manually assciates a display list to a Renderable (to be used with care). More...
 
bool isDisplayListEnabled () const
 Returns true if display lists are enabled for a Renderable (disabled by default). More...
 
void setDisplayListEnabled (bool enabled)
 Enable/disable display lists (disabled by default). More...
 
bool displayListDirty () const
 Whether the display list associated to a Renderable should be recompiled at the next rendering. More...
 
void setDisplayListDirty (bool dirty)
 Whether the display list associated to a Renderable should be recompiled at the next rendering. More...
 
bool isBufferObjectEnabled () const
 Returns true if BufferObject (vertex buffer object) are enabled for a Renderable (enabled by default). More...
 
void setBufferObjectEnabled (bool enabled)
 Enable/disable BufferObject (vertex buffer object) (enabled by default). More...
 
bool isBufferObjectDirty () const
 Whether BufferObjects associated to a Renderable should be recomputed on the next rendering. More...
 
void setBufferObjectDirty (bool dirty=true)
 Whether BufferObjects associated to a Renderable should be recomputed on the next rendering. More...
 
void deleteDisplayList ()
 Deletes the display list currently associated to a Renderable. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Static Public Member Functions

static void computeTangentSpace (u32 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. More...
 

Public Attributes

DrawRangeElements *MultiDrawElements *to the best fitting of *UInt UShort UByte *taking into account: primitive restart
 Shrinks DrawElements. More...
 

Protected Member Functions

virtual void computeBounds_Implementation ()
 
virtual void render_Implementation (const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context) const
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

Collection< DrawCallmDrawCalls
 
ref< ArrayAbstractmVertexAttribArrays [VA_MaxAttribCount]
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

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

See also

Definition at line 66 of file Geometry.hpp.

Constructor & Destructor Documentation

◆ Geometry()

Geometry::Geometry ( )

Constructor.

Definition at line 45 of file Geometry.cpp.

References mDrawCalls.

Referenced by deepCopy(), and shallowCopy().

◆ ~Geometry()

Geometry::~Geometry ( )
virtual

Destructor.

Definition at line 51 of file Geometry.cpp.

Member Function Documentation

◆ clearArrays()

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

Removes all the previously installed arrays.

Definition at line 237 of file Geometry.cpp.

References mDrawCalls, mVertexAttribArrays, NULL, vl::Renderable::setBufferObjectDirty(), and vl::VA_MaxAttribCount.

◆ colorArray() [1/2]

const ArrayAbstract* vl::Geometry::colorArray ( ) const
inlinevirtual

Conventional color array.

Implements vl::IVertexAttribSet.

Definition at line 260 of file Geometry.hpp.

References vl::VA_Color.

Referenced by vlX::VLXClassWrapper_Geometry::exportGeometry().

◆ colorArray() [2/2]

ArrayAbstract* vl::Geometry::colorArray ( )
inlinevirtual

Conventional color array.

Implements vl::IVertexAttribSet.

Definition at line 262 of file Geometry.hpp.

References vl::VA_Color.

◆ colorizePrimitives()

void Geometry::colorizePrimitives ( )

◆ computeBounds_Implementation()

void Geometry::computeBounds_Implementation ( )
protectedvirtual

◆ computeNormals()

void Geometry::computeNormals ( bool  verbose = false)

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.

Definition at line 269 of file Geometry.cpp.

References vl::cross(), drawCalls(), vl::ref< T >::get(), vl::ArrayAbstract::getAsVec3(), vl::Vector3< T_Scalar >::length(), mDrawCalls, vl::Vector3< T_Scalar >::normalize(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), setNormalArray(), vl::ArrayAbstract::size(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size(), vertexArray(), VL_CHECK, and vl::Log::warning().

Referenced by vl::Extrusion::extrude(), vl::Extrusions::extrude(), vl::DaeLoader::load(), vl::loadMD2(), vl::MarchingCubes::run(), and vl::Tessellator::tessellateGeometry().

◆ computeTangentSpace()

void Geometry::computeTangentSpace ( u32  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.

Definition at line 1193 of file Geometry.cpp.

References vl::cross(), vl::dot(), vl::TriangleIterator::hasNext(), vl::normalize(), vl::DrawCall::triangleIterator(), VL_CHECK, vl::Vector3< T_Scalar >::x(), vl::Vector2< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), vl::Vector2< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().

◆ convertDrawCallToDrawArrays()

void Geometry::convertDrawCallToDrawArrays ( )

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

Definition at line 766 of file Geometry.cpp.

References drawCalls(), vl::ref< T >::get(), regenerateVertices(), vl::ArrayAbstract::size(), and vertexArray().

Referenced by vl::Extrusion::extrude(), and vl::Extrusions::extrude().

◆ deepCopy()

ref< Geometry > Geometry::deepCopy ( ) const

Performs a deep copy of a Geometry.

See also
shallowCopy()

Definition at line 96 of file Geometry.cpp.

References deepCopyFrom(), and Geometry().

◆ deepCopyFrom()

Geometry & Geometry::deepCopyFrom ( const Geometry other)

Performs a deep copy of the specified Geometry.

See also
shallowCopy()

Definition at line 103 of file Geometry.cpp.

References mDrawCalls, mVertexAttribArrays, NULL, and vl::VA_MaxAttribCount.

Referenced by deepCopy().

◆ deleteBufferObject()

void Geometry::deleteBufferObject ( )
virtual

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

Implements vl::Renderable.

Definition at line 346 of file Geometry.cpp.

References drawCalls(), vl::Has_BufferObject, mVertexAttribArrays, and vl::VA_MaxAttribCount.

◆ drawCalls() [1/2]

Collection<DrawCall>& vl::Geometry::drawCalls ( )
inline

Returns the list of DrawCall objects bound to a Geometry.

Definition at line 102 of file Geometry.hpp.

Referenced by colorizePrimitives(), computeBounds_Implementation(), computeNormals(), convertDrawCallToDrawArrays(), deleteBufferObject(), vl::VectorGraphics::drawLineLoop(), vl::VectorGraphics::drawLines(), vl::VectorGraphics::drawLineStrip(), vl::VectorGraphics::drawPoints(), vlX::VLXClassWrapper_Geometry::exportGeometry(), vl::AdjacencyExtractor::extract(), vl::EdgeExtractor::extractEdges(), vl::Extrusion::extrude(), vl::Extrusions::extrude(), vl::VectorGraphics::fillPolygon(), vl::VectorGraphics::fillQuad(), vl::VectorGraphics::fillQuads(), vl::VectorGraphics::fillQuadStrip(), vl::VectorGraphics::fillTriangleFan(), vl::VectorGraphics::fillTriangles(), vl::VectorGraphics::fillTriangleStrip(), fixTriangleWinding(), vl::EdgeExtractor::generateEdgeGeometry(), vl::Molecule::generateRings(), vlX::VLXClassWrapper_Geometry::importGeometry(), vl::RayIntersector::intersectGeometry(), vl::DaeLoader::load(), vl::load3DS(), vl::loadAC3D(), vl::STLLoader::loadAscii(), vl::STLLoader::loadBinary(), vl::loadMD2(), vl::ObjLoader::loadOBJ(), vl::PlyLoader::loadPly(), vl::makeBox(), vl::makeCapsule(), vl::makeCircle(), vl::makeCone(), vl::makeCylinder(), makeGLESFriendly(), vl::makeGrid(), vl::makeIcosahedron(), vl::makeIcosphere(), vl::makePoints(), vl::makePyramid(), makeScales(), vl::makeTorus(), vl::makeUVSphere(), mergeDrawCallsWithMultiDrawElements(), mergeDrawCallsWithPrimitiveRestart(), mergeDrawCallsWithTriangles(), mergeTriangleStrips(), vl::DepthSortCallback::onActorRenderStarted(), vl::DoubleVertexRemover::removeDoubles(), render_Implementation(), vl::SceneManagerPortals::renderPortal(), vl::MarchingCubes::run(), shrinkDrawCalls(), sortVertices(), vl::TriangleStripGenerator::stripfy(), vl::Tessellator::tessellateGeometry(), triangulateDrawCalls(), updateDirtyBufferObject(), and vl::Molecule::wireframeStyle().

◆ drawCalls() [2/2]

const Collection<DrawCall>& vl::Geometry::drawCalls ( ) const
inline

Returns the list of DrawCall objects bound to a Geometry.

Definition at line 105 of file Geometry.hpp.

◆ fixTriangleWinding()

void Geometry::fixTriangleWinding ( )

◆ flipNormals()

bool Geometry::flipNormals ( )

Inverts the orientation of the normals.

Returns true if the normals could be flipped. The function fails if the normals are defined in a format other than ArrayFloat3.

Definition at line 250 of file Geometry.cpp.

References vl::Object::as(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), normalArray(), and vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size().

◆ fogCoordArray() [1/2]

const ArrayAbstract* vl::Geometry::fogCoordArray ( ) const
inlinevirtual

Conventional fog array.

Implements vl::IVertexAttribSet.

Definition at line 272 of file Geometry.hpp.

References vl::VA_FogCoord.

Referenced by vlX::VLXClassWrapper_Geometry::exportGeometry().

◆ fogCoordArray() [2/2]

ArrayAbstract* vl::Geometry::fogCoordArray ( )
inlinevirtual

Conventional fog array.

Implements vl::IVertexAttribSet.

Definition at line 274 of file Geometry.hpp.

References vl::VA_FogCoord.

◆ makeGLESFriendly()

void Geometry::makeGLESFriendly ( )

◆ mergeDrawCallsWithMultiDrawElements()

void Geometry::mergeDrawCallsWithMultiDrawElements ( EPrimitiveType  primitive_type)

◆ mergeDrawCallsWithPrimitiveRestart()

void Geometry::mergeDrawCallsWithPrimitiveRestart ( EPrimitiveType  primitive_type)

◆ mergeDrawCallsWithTriangles()

void Geometry::mergeDrawCallsWithTriangles ( EPrimitiveType  primitive_type)

Merges all the draw calls that use the given primitive type or PT_TRIANGLES into one single PT_TRIANGLES draw call.

Use primitive_type = PT_UNKNOWN to merge all primitive types (with the obvious exclusion of lines, points and adjacency ones).

Definition at line 605 of file Geometry.cpp.

References vl::DrawCall::countTriangles(), drawCalls(), vl::ref< T >::get(), vl::DrawElements< arr_type >::indexBuffer(), vl::DrawCall::primitiveType(), vl::PT_POLYGON, vl::PT_QUAD_STRIP, vl::PT_QUADS, vl::PT_TRIANGLE_FAN, vl::PT_TRIANGLE_STRIP, vl::PT_TRIANGLES, vl::PT_UNKNOWN, vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size(), and VL_CHECK.

Referenced by vl::DaeLoader::load().

◆ mergeTriangleStrips()

DrawCall * Geometry::mergeTriangleStrips ( )

◆ normalArray() [1/2]

const ArrayAbstract* vl::Geometry::normalArray ( ) const
inlinevirtual

◆ normalArray() [2/2]

ArrayAbstract* vl::Geometry::normalArray ( )
inlinevirtual

Conventional normal array.

Implements vl::IVertexAttribSet.

Definition at line 256 of file Geometry.hpp.

References vl::VA_Normal.

◆ regenerateVertices()

void Geometry::regenerateVertices ( const std::vector< u32 > &  map_new_to_old)

Regenerates the vertex position and attributes using the given new-to-old map.

Where 'map_new_to_old[i] == j' means that the i-th new vertex attribute should take it's value from the old j-th vertex attribute.

Definition at line 757 of file Geometry.cpp.

References vl::VertexMapper::regenerate(), setVertexAttribArray(), vl::VA_MaxAttribCount, and vertexAttribArray().

Referenced by convertDrawCallToDrawArrays(), vl::DoubleVertexRemover::removeDoubles(), and sortVertices().

◆ render_Implementation()

void Geometry::render_Implementation ( const Actor actor,
const Shader shader,
const Camera camera,
OpenGLContext gl_context 
) const
protectedvirtual

◆ secondaryColorArray() [1/2]

const ArrayAbstract* vl::Geometry::secondaryColorArray ( ) const
inlinevirtual

Conventional secondary color array.

Implements vl::IVertexAttribSet.

Definition at line 266 of file Geometry.hpp.

References vl::VA_SecondaryColor.

Referenced by vlX::VLXClassWrapper_Geometry::exportGeometry().

◆ secondaryColorArray() [2/2]

ArrayAbstract* vl::Geometry::secondaryColorArray ( )
inlinevirtual

Conventional secondary color array.

Implements vl::IVertexAttribSet.

Definition at line 268 of file Geometry.hpp.

References vl::VA_SecondaryColor.

◆ setColorArray() [1/2]

void vl::Geometry::setColorArray ( const fvec4 color)
inline

◆ setColorArray() [2/2]

void Geometry::setColorArray ( ArrayAbstract data)
virtual

Conventional color array.

Implements vl::IVertexAttribSet.

Definition at line 178 of file Geometry.cpp.

References vl::ArrayAbstract::glSize(), vl::ArrayAbstract::glType(), mVertexAttribArrays, vl::VA_Color, and VL_CHECK.

◆ setFogCoordArray()

void Geometry::setFogCoordArray ( ArrayAbstract data)
virtual

◆ setNormalArray()

void Geometry::setNormalArray ( ArrayAbstract data)
virtual

◆ setSecondaryColorArray()

void Geometry::setSecondaryColorArray ( ArrayAbstract data)
virtual

◆ setTexCoordArray()

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

◆ setVertexArray()

void Geometry::setVertexArray ( ArrayAbstract data)
virtual

◆ setVertexAttribArray()

void Geometry::setVertexAttribArray ( int  attrib_location,
const ArrayAbstract info 
)
virtual

Binds a generic vertex attribute.

Implements vl::IVertexAttribSet.

Definition at line 415 of file Geometry.cpp.

References mVertexAttribArrays.

Referenced by vl::Extrusions::extrude(), and regenerateVertices().

◆ shallowCopy()

ref< Geometry > Geometry::shallowCopy ( ) const

Performs a shallow copy of a Geometry.

See also
deepCopy()

Definition at line 127 of file Geometry.cpp.

References Geometry(), and shallowCopyFrom().

◆ shallowCopyFrom()

Geometry & Geometry::shallowCopyFrom ( const Geometry other)

Performs a shallow copy of the specified Geometry.

See also
deepCopy()

Definition at line 134 of file Geometry.cpp.

References mDrawCalls, mVertexAttribArrays, NULL, and vl::VA_MaxAttribCount.

Referenced by shallowCopy().

◆ shrinkDrawCalls()

void Geometry::shrinkDrawCalls ( )

Definition at line 823 of file Geometry.cpp.

References vl::Object::as(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), vl::DrawElementsBase::baseVertex(), vl::DrawRangeElementsBase::baseVertex(), vl::MultiDrawElementsBase::baseVertices(), vl::MultiDrawElementsBase::countVector(), drawCalls(), vl::IndexIterator::hasNext(), vl::MultiDrawElements< arr_type >::indexBuffer(), vl::DrawElements< arr_type >::indexBuffer(), vl::DrawRangeElements< arr_type >::indexBuffer(), vl::DrawCall::indexIterator(), vl::DrawCall::instances(), vl::DrawElements< ArrayUShort1 >::primitive_restart_index, vl::DrawElements< ArrayUByte1 >::primitive_restart_index, vl::DrawRangeElements< ArrayUShort1 >::primitive_restart_index, vl::DrawRangeElements< ArrayUByte1 >::primitive_restart_index, vl::DrawCall::primitiveRestartEnabled(), vl::DrawCall::primitiveRestartIndex(), vl::DrawCall::primitiveType(), vl::DrawRangeElementsBase::rangeEnd(), vl::DrawRangeElementsBase::rangeStart(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::DrawElementsBase::setBaseVertex(), vl::DrawRangeElementsBase::setBaseVertex(), vl::MultiDrawElementsBase::setBaseVertices(), vl::MultiDrawElementsBase::setCountVector(), vl::MultiDrawElementsBase::setPrimitiveRestartEnabled(), vl::DrawElementsBase::setPrimitiveRestartEnabled(), vl::DrawRangeElementsBase::setPrimitiveRestartEnabled(), vl::DrawRangeElementsBase::setRangeEnd(), vl::DrawRangeElementsBase::setRangeStart(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size(), and VL_CHECK.

Referenced by makeGLESFriendly().

◆ sortVertices()

bool Geometry::sortVertices ( )

Sorts the vertices of the geometry (position, normals, textures, colors etc.) to maximize vertex-cache coherency.

This function will work only if all the DrawCalls are DrawElements* and will generate a new set of DrawElementsUInt. This function will fail if any of the DrawCalls is using primitive restart functionality.

Returns
true if all the DrawCall are DrawElements* and none of the DrawCalls is using primitive restart.

Definition at line 1057 of file Geometry.cpp.

References vl::Object::as(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), vl::DrawElementsBase::baseVertex(), drawCalls(), vl::Log::error(), vl::DrawElements< arr_type >::indexBuffer(), vl::DrawElementsBase::instances(), vl::DrawCall::primitiveRestartEnabled(), vl::DrawCall::primitiveType(), regenerateVertices(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::ArrayAbstract::size(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::size(), vertexArray(), and vl::Log::warning().

◆ texCoordArray() [1/2]

const ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit) const
inlinevirtual

Conventional texture coords arrays.

Implements vl::IVertexAttribSet.

Definition at line 278 of file Geometry.hpp.

References vl::VA_TexCoord0.

Referenced by vlX::VLXClassWrapper_Geometry::exportGeometry(), and vl::loadMD2().

◆ texCoordArray() [2/2]

ArrayAbstract* vl::Geometry::texCoordArray ( int  tex_unit)
inlinevirtual

Conventional texture coords arrays.

Implements vl::IVertexAttribSet.

Definition at line 280 of file Geometry.hpp.

References vl::VA_TexCoord0.

◆ transform()

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

Definition at line 399 of file Geometry.cpp.

References vl::Matrix4< T_Scalar >::as3x3(), vl::Matrix4< T_Scalar >::invert(), normalArray(), vl::ArrayAbstract::normalize(), vl::ArrayAbstract::transform(), vl::Matrix4< T_Scalar >::transpose(), and vertexArray().

Referenced by vl::loadAC3D(), vl::makeTeapot(), and vl::DaeLoader::setupLights().

◆ triangulateDrawCalls()

void Geometry::triangulateDrawCalls ( )

◆ updateDirtyBufferObject()

void Geometry::updateDirtyBufferObject ( EBufferObjectUpdateMode  mode)
virtual

Updates all the vertex buffer objects of both vertex arrays and draw calls that are marked as dirty.

Implements vl::Renderable.

Definition at line 362 of file Geometry.cpp.

References vl::BUF_ForceUpdate, drawCalls(), vl::Has_BufferObject, mVertexAttribArrays, and vl::VA_MaxAttribCount.

◆ vertexArray() [1/2]

const ArrayAbstract* vl::Geometry::vertexArray ( ) const
inlinevirtual

◆ vertexArray() [2/2]

ArrayAbstract* vl::Geometry::vertexArray ( )
inlinevirtual

Conventional vertex array.

Implements vl::IVertexAttribSet.

Definition at line 250 of file Geometry.hpp.

References vl::VA_Position.

◆ vertexAttribArray() [1/2]

const ArrayAbstract * Geometry::vertexAttribArray ( int  attrib_location) const
virtual

Returns a generic vertex attribute's info.

Implements vl::IVertexAttribSet.

Definition at line 420 of file Geometry.cpp.

References mVertexAttribArrays.

Referenced by regenerateVertices().

◆ vertexAttribArray() [2/2]

ArrayAbstract * Geometry::vertexAttribArray ( int  attrib_location)
virtual

Returns a generic vertex attribute's info.

Implements vl::IVertexAttribSet.

Definition at line 425 of file Geometry.cpp.

References mVertexAttribArrays.

Member Data Documentation

◆ account

DrawRangeElements* MultiDrawElements* to the best fitting of* UInt UShort UByte* taking into vl::Geometry::account

Shrinks DrawElements.

Definition at line 201 of file Geometry.hpp.

◆ mDrawCalls

Collection<DrawCall> vl::Geometry::mDrawCalls
protected

Definition at line 294 of file Geometry.hpp.

Referenced by clearArrays(), computeNormals(), deepCopyFrom(), Geometry(), and shallowCopyFrom().

◆ mVertexAttribArrays

ref<ArrayAbstract> vl::Geometry::mVertexAttribArrays[VA_MaxAttribCount]
protected

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