44 #ifndef __CU_WIRE_NODE_H__
45 #define __CU_WIRE_NODE_H__
48 #include <cugl/2d/CUTexturedNode.h>
49 #include <cugl/math/CUPoly2.h>
50 #include <cugl/math/polygon/CUPathOutliner.h>
53 #define WIRE_SEGMENTS 8
118 #pragma mark Constructors
157 bool initWithVertices(
const std::vector<Vec2>& vertices, PathTraversal traversal);
209 #pragma mark Static Constructors
217 static std::shared_ptr<WireNode>
alloc() {
218 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
219 return (node->init() ? node :
nullptr);
235 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
236 return (node->init(vertices) ? node :
nullptr);
252 PathTraversal traversal) {
253 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
254 return (node->initWithVertices(vertices,traversal) ? node :
nullptr);
269 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
270 return (node->init(poly) ? node :
nullptr);
283 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
284 return (node->init(rect) ? node :
nullptr);
296 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
297 return (node->initWithLine(origin,dest) ? node :
nullptr);
312 unsigned int segments = WIRE_SEGMENTS) {
313 std::shared_ptr<WireNode> node = std::make_shared<WireNode>();
314 return (node->initWithEllipse(center,size,segments) ? node :
nullptr);
341 const std::shared_ptr<JsonValue>& data) {
342 std::shared_ptr<WireNode> result = std::make_shared<WireNode>();
343 if (!result->initWithData(loader,data)) { result =
nullptr; }
344 return std::dynamic_pointer_cast<
Node>(result);
348 #pragma mark Attributes
380 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
391 void setPolygon(
const std::vector<Vec2>& vertices, PathTraversal traversal);
434 void setEllipse(
const Vec2& center,
const Size& size,
unsigned int segments = WIRE_SEGMENTS);
437 #pragma mark Rendering
461 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
466 CU_DISALLOW_COPY_AND_ASSIGN(
WireNode);
bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data) override
Definition: CUWireNode.h:107
static std::shared_ptr< WireNode > allocWithRect(const Rect &rect)
Definition: CUWireNode.h:282
bool initWithEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
Definition: CUTexturedNode.h:84
void setLine(const Vec2 &origin, const Vec2 &dest)
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
Definition: CUPoly2.h:115
std::string _classname
Definition: CUTexturedNode.h:88
static std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data)
Definition: CUWireNode.h:340
static std::shared_ptr< WireNode > allocWithVertices(const std::vector< Vec2 > &vertices, PathTraversal traversal)
Definition: CUWireNode.h:251
~WireNode()
Definition: CUWireNode.h:139
PathTraversal getTraversal() const
Definition: CUWireNode.h:368
void setTraversal(PathTraversal traversal)
static PathOutliner _outliner
Definition: CUWireNode.h:111
void setEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
virtual void dispose() override
static std::shared_ptr< WireNode > allocWithEllipse(const Vec2 ¢er, const Size &size, unsigned int segments=WIRE_SEGMENTS)
Definition: CUWireNode.h:311
PathTraversal _traversal
Definition: CUWireNode.h:114
Definition: CUSceneLoader.h:77
static std::shared_ptr< WireNode > allocWithLine(const Vec2 &origin, const Vec2 &dest)
Definition: CUWireNode.h:295
WireNode()
Definition: CUWireNode.h:127
static std::shared_ptr< WireNode > alloc()
Definition: CUWireNode.h:217
bool initWithLine(const Vec2 &origin, const Vec2 &dest)
std::string _name
Definition: CUNode.h:189
virtual void setPolygon(const std::vector< Vec2 > &vertices) override
Definition: CUColor4.h:1084
Definition: CUPathOutliner.h:79
static std::shared_ptr< WireNode > allocWithPoly(const Poly2 &poly)
Definition: CUWireNode.h:268
Definition: CUAction.h:51
static std::shared_ptr< WireNode > allocWithVertices(const std::vector< Vec2 > &vertices)
Definition: CUWireNode.h:234
bool initWithVertices(const std::vector< Vec2 > &vertices, PathTraversal traversal)