CUGL
Cornell University Game Library
|
#include <CUPathOutliner.h>
Public Member Functions | |
PathOutliner () | |
PathOutliner (const std::vector< Vec2 > &points) | |
PathOutliner (const Poly2 &poly) | |
~PathOutliner () | |
void | set (const Poly2 &poly) |
void | set (const std::vector< Vec2 > &points) |
void | reset () |
void | clear () |
void | calculate (PathTraversal traversal) |
std::vector< unsigned short > | getPath () |
size_t | getPath (std::vector< unsigned short > &buffer) |
Poly2 | getPolygon () |
Poly2 * | getPolygon (Poly2 *buffer) |
This class is a factory for producing wireframe Poly2 objects from a set of vertices.
This class provides three types of traversals: open, closed, and interior. An interior traversal first triangulates the polygon, and then creates a wireframe traversal of that triangulation.
As with all factories, the methods are broken up into three phases: initialization, calculation, and materialization. To use the factory, you first set the data (in this case a set of vertices or another Poly2) with the initialization methods. You then call the calculation method. Finally, you use the materialization methods to access the data in several different ways.
This division allows us to support multithreaded calculation if the data generation takes too long. However, note that this factory is not thread safe in that you cannot access data while it is still in mid-calculation.
|
inline |
Creates an outliner with no vertex data.
|
inline |
Creates an outliner with the given vertex data.
The vertex data is copied. The outliner does not retain any references to the original data.
points | The vertices to outline |
|
inline |
Creates an outliner with the given vertex data.
The outline only uses the vertex data from the polygon. It ignores any existing indices.
The vertex data is copied. The outliner does not retain any references to the original data.
poly | The vertices to outline |
|
inline |
Deletes this outliner, releasing all resources.
void cugl::PathOutliner::calculate | ( | PathTraversal | traversal | ) |
Performs a path calculation of the current vertex data.
The path takes the provided traversal. See Traversal for more information.
traversal | The traversal type. |
|
inline |
Clears all internal data, the initial vertex data.
When this method is called, you will need to set a new vertices before calling calculate.
std::vector<unsigned short> cugl::PathOutliner::getPath | ( | ) |
Returns a list of indices representing the path outline.
The indices represent positions in the original vertex list. If you have modified that list, these indices may no longer be valid.
The outliner does not retain a reference to the returned list; it is safe to modify it.
If the calculation is not yet performed, this method will return the empty list.
size_t cugl::PathOutliner::getPath | ( | std::vector< unsigned short > & | buffer | ) |
Stores the path outline indices in the given buffer.
The indices represent positions in the original vertex list. If you have modified that list, these indices may no longer be valid.
The indices will be appended to the provided vector. You should clear the vector first if you do not want to preserve the original data.
If the calculation is not yet performed, this method will do nothing.
Poly2 cugl::PathOutliner::getPolygon | ( | ) |
Returns a polygon representing the path outline.
The polygon contains the original vertices together with the new indices defining the wireframe path. The outliner does not maintain references to this polygon and it is safe to modify it.
If the calculation is not yet performed, this method will return the empty polygon.
Stores the path outline in the given buffer.
This method will add both the original vertices, and the corresponding indices to the new 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.
If the calculation is not yet performed, this method will do nothing.
buffer | The buffer to store the outlined polygon |
|
inline |
Clears all internal data, but still maintains the initial vertex data.
|
inline |
Sets the vertex data for this outliner.
The outline only uses the vertex data from the polygon. It ignores any existing indices.
The vertex data is copied. The outliner does not retain any references to the original data.
This method resets all interal data. You will need to reperform the calculation before accessing data.
poly | The vertices to outline |
|
inline |
Sets the vertex data for this outliner.
The vertex data is copied. The outliner does not retain any references to the original data.
This method resets all interal data. You will need to reperform the calculation before accessing data.
points | The vertices to outline |