CUGL 3.0
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | List of all members
cugl::graphics::MeshExtruder Class Reference

#include <CUMeshExtruder.h>

Inheritance diagram for cugl::graphics::MeshExtruder:
cugl::SimpleExtruder

Public Member Functions

 MeshExtruder ()
 
 MeshExtruder (const std::vector< Vec2 > &points, bool closed)
 
 MeshExtruder (const Path2 &path)
 
 ~MeshExtruder ()
 
Mesh< SpriteVertexgetMesh (Color4 color) const
 
Mesh< SpriteVertex > * getMesh (Mesh< SpriteVertex > *mesh, Color4 color) const
 
Mesh< SpriteVertexgetMesh (Color4 inner, Color4 outer) const
 
Mesh< SpriteVertex > * getMesh (Mesh< SpriteVertex > *mesh, Color4 inner, Color4 outer) const
 
- Public Member Functions inherited from cugl::SimpleExtruder
 SimpleExtruder ()
 
 SimpleExtruder (const std::vector< Vec2 > &points, bool closed)
 
 SimpleExtruder (const Path2 &path)
 
 ~SimpleExtruder ()
 
void setJoint (poly2::Joint joint)
 
poly2::Joint getJoint () const
 
void setEndCap (poly2::EndCap endcap)
 
poly2::EndCap getEndCap () const
 
void setTolerance (float tolerance)
 
float getTolerance () const
 
void setMitreLimit (float limit)
 
float getMitreLimit () const
 
void set (const std::vector< Vec2 > &points, bool closed)
 
void set (const Vec2 *points, size_t size, bool closed)
 
void set (const Path2 &path)
 
void reset ()
 
void clear ()
 
void calculate (float width)
 
void calculate (float lwidth, float rwidth)
 
Poly2 getPolygon () const
 
Poly2getPolygon (Poly2 *buffer) const
 
std::vector< Path2getBorder () const
 
size_t getBorder (std::vector< Path2 > &buffer) const
 
Vec2 getSide (Uint32 index) const
 

Additional Inherited Members

- Protected Attributes inherited from cugl::SimpleExtruder
poly2::Joint _joint
 
poly2::EndCap _endcap
 
float _tolerance
 
float _mitrelimit
 
bool _closed
 
bool _convex
 
bool _calculated
 
Point * _points
 
size_t _plimit
 
size_t _psize
 
float * _verts
 
float * _sides
 
float * _lefts
 
float * _rghts
 
size_t _vlimit
 
size_t _vsize
 
size_t _lsize
 
size_t _rsize
 
Uint32 * _indxs
 
size_t _ilimit
 
size_t _isize
 
Uint32 _iback2
 
Uint32 _iback1
 

Detailed Description

This class is a factory for extruding paths into a sprite mesh.

The class SimpleExtruder actually stores enough information to aid with texturing. However, texture information is not part of Poly2. If we want texture information, we need instead a mesh of SpriteVertex values. That is the purpose of this extruder.

This functionality was originally part of the base class SimpleExtruder. However, upon our decision to factor out graphics as its own package, we needed to separate the behavior.

Constructor & Destructor Documentation

◆ MeshExtruder() [1/3]

cugl::graphics::MeshExtruder::MeshExtruder ( )
inline

Creates an extruder with no vertex data.

◆ MeshExtruder() [2/3]

cugl::graphics::MeshExtruder::MeshExtruder ( const std::vector< Vec2 > &  points,
bool  closed 
)

Creates an extruder with the given path.

The path data is copied. The extruder does not retain any references to the original data.

Parameters
pointsThe path to extrude
closedWhether the path is closed

◆ MeshExtruder() [3/3]

cugl::graphics::MeshExtruder::MeshExtruder ( const Path2 path)

Creates an extruder with the given path.

The path data is copied. The extruder does not retain any references to the original data.

Parameters
pathThe path to extrude

◆ ~MeshExtruder()

cugl::graphics::MeshExtruder::~MeshExtruder ( )
inline

Deletes this extruder, releasing all resources.

Member Function Documentation

◆ getMesh() [1/4]

Mesh< SpriteVertex > cugl::graphics::MeshExtruder::getMesh ( Color4  color) const

Returns a mesh representing the path extrusion.

This method creates a triangular mesh with the vertices of the extrusion, coloring each vertex white. However, if fringe is set to true, then each vertex will instead be colored clear (transparent), unless that vertex is on a zero-width side. This effect can be used to produce border "fringes" around a polygon for anti-aliasing.

If the calculation is not yet performed, this method will return the empty mesh.

Parameters
colorThe default mesh color
Returns
a mesh representing the path extrusion.

◆ getMesh() [2/4]

Mesh< SpriteVertex > cugl::graphics::MeshExtruder::getMesh ( Color4  inner,
Color4  outer 
) const

Returns a mesh representing the path extrusion.

This method creates a triangular mesh with the vertices of the extrusion, coloring each vertex white. However, if fringe is set to true, then each vertex will instead be colored clear (transparent), unless that vertex is on a zero-width side. This effect can be used to produce border "fringes" around a polygon for anti-aliasing.

If the calculation is not yet performed, this method will return the empty mesh.

Parameters
innerThe interior mesh color
outerThe exterior mesh color
Returns
a mesh representing the path extrusion.

◆ getMesh() [3/4]

Mesh< SpriteVertex > * cugl::graphics::MeshExtruder::getMesh ( Mesh< SpriteVertex > *  mesh,
Color4  color 
) const

Stores a mesh representing the path extrusion in the given buffer

This method will add both the new vertices, and the corresponding indices to the buffer. If the buffer is not empty, the indices will be adjusted accordingly. You should clear the buffer first if you do not want to preserve the original data.

The vertices in this mesh will be colored white by default. However, if fringe is set to true, then each vertex will instead be colored clear (transparent), unless that vertex is on a zero-width side. This effect can be used to produce border "fringes" around a polygon for anti-aliasing.

If the calculation is not yet performed, this method will do nothing.

Parameters
meshThe buffer to store the extruded path mesh
colorThe default mesh color
Returns
a reference to the buffer for chaining.

◆ getMesh() [4/4]

Mesh< SpriteVertex > * cugl::graphics::MeshExtruder::getMesh ( Mesh< SpriteVertex > *  mesh,
Color4  inner,
Color4  outer 
) const

Stores a mesh representing the path extrusion in the given buffer

This method will add both the new vertices, and the corresponding indices to the buffer. If the buffer is not empty, the indices will be adjusted accordingly. You should clear the buffer first if you do not want to preserve the original data.

The vertices in this mesh will be colored white by default. However, if fringe is set to true, then each vertex will instead be colored clear (transparent), unless that vertex is on a zero-width side. This effect can be used to produce border "fringes" around a polygon for anti-aliasing.

If the calculation is not yet performed, this method will do nothing.

Parameters
meshThe buffer to store the extruded path mesh
innerThe interior mesh color
outerThe exterior mesh color
Returns
a reference to the buffer for chaining.

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