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 | Protected Attributes | List of all members
vl::BezierSurface Class Reference

The BezierSurface class implements a Geometry that is capable of visualizing multiple bicubic Bézier patches (see BezierPatch). More...

#include <BezierSurface.hpp>

+ Inheritance diagram for vl::BezierSurface:

Public Member Functions

 BezierSurface ()
 Constructor. More...
 
std::vector< ref< BezierPatch > > & patches ()
 Returns the Bézier patches that are part of this Bézier surface. More...
 
const std::vector< ref< BezierPatch > > & patches () const
 Returns the Bézier patches that are part of this Bézier surface. More...
 
void setDetail (unsigned i)
 The sampling level of the patch, must not be less than 2. The higher the sampling level, the more detailed the patch will be. More...
 
unsigned detail () const
 The sampling level of the patch, must not be less than 2. The higher the sampling level, the more detailed the patch will be. More...
 
void updateBezierSurface (bool gen_tex_coords=true)
 Generates the Bézier surface geometry based on the current patches and detail. More...
 
- Public Member Functions inherited from vl::Geometry
 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...
 

Protected Attributes

std::vector< ref< BezierPatch > > mPatches
 
unsigned mDetail
 
- Protected Attributes inherited from vl::Geometry
Collection< DrawCallmDrawCalls
 
ref< ArrayAbstractmVertexAttribArrays [VA_MaxAttribCount]
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Static Public Member Functions inherited from vl::Geometry
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 inherited from vl::Geometry
DrawRangeElements *MultiDrawElements *to the best fitting of *UInt UShort UByte *taking into account: primitive restart
 Shrinks DrawElements. More...
 
- Protected Member Functions inherited from vl::Geometry
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 ()
 

Detailed Description

The BezierSurface class implements a Geometry that is capable of visualizing multiple bicubic Bézier patches (see BezierPatch).

From Wikipedia [http://en.wikipedia.org/wiki/Bézier_surface]:

"Bézier surfaces are a species of mathematical spline used in computer graphics, computer-aided design, and finite element modelling. As with the Bézier curve, a Bézier surface is defined by a set of control points. Similar to interpolation in many respects, a key difference is that the surface does not, in general, pass through the central control points; rather, it is "stretched" toward them as though each were an attractive force. They are visually intuitive, and for many applications, mathematically convenient."

"Bézier surfaces were first described in 1972 by the French engineer Pierre Bézier who used them to design automobile bodies. Bézier surfaces can be of any degree, but bicubic Bézier surfaces generally provide enough degrees of freedom for most applications."

See also:

Definition at line 94 of file BezierSurface.hpp.

Constructor & Destructor Documentation

◆ BezierSurface()

vl::BezierSurface::BezierSurface ( )
inline

Constructor.

Definition at line 100 of file BezierSurface.hpp.

Member Function Documentation

◆ detail()

unsigned vl::BezierSurface::detail ( ) const
inline

The sampling level of the patch, must not be less than 2. The higher the sampling level, the more detailed the patch will be.

Definition at line 114 of file BezierSurface.hpp.

◆ patches() [1/2]

std::vector< ref<BezierPatch> >& vl::BezierSurface::patches ( )
inline

Returns the Bézier patches that are part of this Bézier surface.

Definition at line 106 of file BezierSurface.hpp.

Referenced by vl::makeTeapot().

◆ patches() [2/2]

const std::vector< ref<BezierPatch> >& vl::BezierSurface::patches ( ) const
inline

Returns the Bézier patches that are part of this Bézier surface.

Definition at line 108 of file BezierSurface.hpp.

◆ setDetail()

void vl::BezierSurface::setDetail ( unsigned  i)
inline

The sampling level of the patch, must not be less than 2. The higher the sampling level, the more detailed the patch will be.

Definition at line 111 of file BezierSurface.hpp.

Referenced by vl::makeTeapot().

◆ updateBezierSurface()

void BezierSurface::updateBezierSurface ( bool  gen_tex_coords = true)

Generates the Bézier surface geometry based on the current patches and detail.

Note that this method does not recompte the normals of the mesh, this means that if you are using the OpenGL lighting or other techniques requiring vertex normals you should call computeNormals() right after calling this function.

Parameters
gen_tex_coordsIf set to true the function will also generate normalized (0..1) texture coordinates.

Definition at line 87 of file BezierSurface.cpp.

References vl::BezierPatch::at(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), vl::ref< T >::get(), vl::DrawElements< arr_type >::indexBuffer(), NULL, vl::PT_QUADS, vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::ArrayAbstract::setBufferObjectDirty(), vl::BezierPatch::x(), vl::Vector2< T_Scalar >::x(), vl::BezierPatch::y(), and vl::Vector2< T_Scalar >::y().

Referenced by vl::makeTeapot().

Member Data Documentation

◆ mDetail

unsigned vl::BezierSurface::mDetail
protected

Definition at line 124 of file BezierSurface.hpp.

◆ mPatches

std::vector< ref<BezierPatch> > vl::BezierSurface::mPatches
protected

Definition at line 123 of file BezierSurface.hpp.


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