42 #ifndef __CU_POLYGON_NODE_H__
43 #define __CU_POLYGON_NODE_H__
46 #include "CUTexturedNode.h"
47 #include "../math/polygon/CUSimpleTriangulator.h"
87 #pragma mark Constructor
98 _name =
"PolygonNode";
111 #pragma mark Static Constructors
121 static std::shared_ptr<PolygonNode>
alloc() {
122 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
123 return (node->init() ? node :
nullptr);
141 static std::shared_ptr<PolygonNode>
alloc(
const std::vector<Vec2>& vertices) {
142 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
143 return (node->init(vertices) ? node :
nullptr);
157 static std::shared_ptr<PolygonNode>
alloc(
const Poly2& poly) {
158 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
159 return (node->init(poly) ? node :
nullptr);
176 static std::shared_ptr<PolygonNode>
alloc(
const Rect& rect) {
177 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
178 return (node->init(rect) ? node :
nullptr);
191 static std::shared_ptr<PolygonNode>
allocWithFile(
const std::string& filename) {
192 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
193 return (node->initWithFile(filename) ? node :
nullptr);
208 static std::shared_ptr<PolygonNode>
allocWithFile(
const std::string& filename,
209 const std::vector<Vec2>& vertices) {
210 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
211 return (node->initWithFile(filename,vertices) ? node :
nullptr);
223 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
224 return (node->initWithFile(filename,poly) ? node :
nullptr);
238 static std::shared_ptr<PolygonNode>
allocWithFile(
const std::string& filename,
const Rect& rect) {
239 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
240 return (node->initWithFile(filename,rect) ? node :
nullptr);
253 static std::shared_ptr<PolygonNode>
allocWithTexture(
const std::shared_ptr<Texture>& texture) {
254 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
255 return (node->initWithTexture(texture) ? node :
nullptr);
270 static std::shared_ptr<PolygonNode>
allocWithTexture(
const std::shared_ptr<Texture>& texture,
271 const std::vector<Vec2>& vertices) {
272 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
273 return (node->initWithTexture(texture,vertices) ? node :
nullptr);
283 static std::shared_ptr<PolygonNode>
allocWithTexture(
const std::shared_ptr<Texture>& texture,
285 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
286 return (node->initWithTexture(texture,poly) ? node :
nullptr);
300 static std::shared_ptr<PolygonNode>
allocWithTexture(
const std::shared_ptr<Texture>& texture,
302 std::shared_ptr<PolygonNode> node = std::make_shared<PolygonNode>();
303 return (node->initWithTexture(texture,rect) ? node :
nullptr);
307 #pragma mark Attributes
317 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
339 #pragma mark Rendering
363 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
367 #pragma mark Internal Helpers
static std::shared_ptr< PolygonNode > alloc(const Rect &rect)
Definition: CUPolygonNode.h:176
Definition: CUTexturedNode.h:83
static std::shared_ptr< PolygonNode > allocWithTexture(const std::shared_ptr< Texture > &texture, const Rect &rect)
Definition: CUPolygonNode.h:300
Definition: CUSimpleTriangulator.h:66
Definition: CUPoly2.h:115
static std::shared_ptr< PolygonNode > alloc()
Definition: CUPolygonNode.h:121
static std::shared_ptr< PolygonNode > allocWithTexture(const std::shared_ptr< Texture > &texture)
Definition: CUPolygonNode.h:253
static std::shared_ptr< PolygonNode > alloc(const Poly2 &poly)
Definition: CUPolygonNode.h:157
static std::shared_ptr< PolygonNode > allocWithFile(const std::string &filename, const std::vector< Vec2 > &vertices)
Definition: CUPolygonNode.h:208
std::string _classname
Definition: CUTexturedNode.h:87
PolygonNode()
Definition: CUPolygonNode.h:96
static std::shared_ptr< PolygonNode > allocWithFile(const std::string &filename)
Definition: CUPolygonNode.h:191
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
Definition: CUPolygonNode.h:79
static std::shared_ptr< PolygonNode > allocWithTexture(const std::shared_ptr< Texture > &texture, const std::vector< Vec2 > &vertices)
Definition: CUPolygonNode.h:270
static std::shared_ptr< PolygonNode > allocWithFile(const std::string &filename, const Rect &rect)
Definition: CUPolygonNode.h:238
static std::shared_ptr< PolygonNode > allocWithFile(const std::string &filename, const Poly2 &poly)
Definition: CUPolygonNode.h:222
static SimpleTriangulator _triangulator
Definition: CUPolygonNode.h:83
static std::shared_ptr< PolygonNode > alloc(const std::vector< Vec2 > &vertices)
Definition: CUPolygonNode.h:141
std::string _name
Definition: CUNode.h:187
Definition: CUColor4.h:1104
Definition: CUAnimationNode.h:52
virtual ~PolygonNode()
Definition: CUPolygonNode.h:108
virtual void setPolygon(const std::vector< Vec2 > &vertices) override
static std::shared_ptr< PolygonNode > allocWithTexture(const std::shared_ptr< Texture > &texture, const Poly2 &poly)
Definition: CUPolygonNode.h:283