Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
AutoPolygon Class Reference

AutoPolygon is a helper Object AutoPolygon's purpose is to process an image into 2d polygon mesh in runtime It has functions for each step in the process, from tracing all the points, to triangulation the result can be then passed to Sprite::create() to create a Polygon Sprite. More...

Public Member Functions

 AutoPolygon (const std::string &filename)
 create an AutoPolygon and initialize it with an image file the image must be a 32bit PNG for current version 3.7 More...
 
 ~AutoPolygon ()
 Destructor of AutoPolygon.
 
std::vector< Vec2trace (const cocos2d::Rect &rect, float threshold=0.0f)
 trace all the points along the outline of the image, More...
 
var trace ( var rect, var 0f)
 trace all the points along the outline of the image, More...
 
local trace ( local rect, local 0f)
 trace all the points along the outline of the image, More...
 
std::vector< Vec2reduce (const std::vector< Vec2 > &points, const Rect &rect, float epsilon=2.0f)
 reduce the amount of points so its faster for GPU to process and draw based on Ramer-Douglas-Peucker algorithm More...
 
local reduce ( local points, local rect, local 0f)
 reduce the amount of points so its faster for GPU to process and draw based on Ramer-Douglas-Peucker algorithm More...
 
std::vector< Vec2expand (const std::vector< Vec2 > &points, const Rect &rect, float epsilon)
 expand the points along their edge, useful after you reduce the points that cuts into the sprite using ClipperLib More...
 
TrianglesCommand::Triangles triangulate (const std::vector< Vec2 > &points)
 Triangulate the input points into triangles for rendering using poly2tri. More...
 
void calculateUV (const Rect &rect, V3F_C4B_T2F *verts, ssize_t count)
 calculate the UV coordinates for each points based on a texture rect More...
 
PolygonInfo generateTriangles (const Rect &rect=Rect::ZERO, float epsilon=2.0f, float threshold=0.05f)
 a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function More...
 
local generateTriangles ( local ZERO, local 0f, local 05f)
 a helper function, packing trace, reduce, expand, triangulate and calculate uv in one function More...
 

Static Public Member Functions

static PolygonInfo generatePolygon (const std::string &filename, const Rect &rect=Rect::ZERO, float epsilon=2.0f, float threshold=0.05f)
 a helper function, packing autoPolygon creation, trace, reduce, expand, triangulate and calculate uv in one function More...
 

Detailed Description

AutoPolygon is a helper Object AutoPolygon's purpose is to process an image into 2d polygon mesh in runtime It has functions for each step in the process, from tracing all the points, to triangulation the result can be then passed to Sprite::create() to create a Polygon Sprite.


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