 |
CUGL 1.3
Cornell University Game Library
|
45 #ifndef __CU_PATH_NODE_H__
46 #define __CU_PATH_NODE_H__
49 #include <cugl/2d/CUTexturedNode.h>
50 #include <cugl/math/CUPoly2.h>
51 #include <cugl/math/polygon/CUPathExtruder.h>
52 #include <cugl/math/polygon/CUPathOutliner.h>
55 #define PATH_SEGMENTS 8
134 #pragma mark Constructors
176 PathJoint joint = PathJoint::NONE, PathCap cap = PathCap::NONE,
200 PathJoint joint = PathJoint::NONE, PathCap cap = PathCap::NONE);
231 #pragma mark Static Constructors
239 static std::shared_ptr<PathNode>
alloc() {
240 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
241 return (node->init() ? node :
nullptr);
261 static std::shared_ptr<PathNode>
allocWithVertices(
const std::vector<Vec2>& vertices,
float stroke,
262 PathJoint joint = PathJoint::NONE,
263 PathCap cap = PathCap::NONE,
bool closed =
true) {
264 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
265 return (node->initWithVertices(vertices,stroke,joint,cap,closed) ? node :
nullptr);
285 PathJoint joint = PathJoint::NONE,
286 PathCap cap = PathCap::NONE) {
287 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
288 return (node->initWithPoly(poly,stroke,joint,cap) ? node :
nullptr);
307 PathJoint joint = PathJoint::NONE,
308 PathCap cap = PathCap::NONE) {
309 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
310 return (node->initWithPoly(
Poly2(rect,
false),stroke,joint,cap) ? node :
nullptr);
328 PathJoint joint = PathJoint::NONE,
329 PathCap cap = PathCap::NONE) {
330 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
331 return (node->initWithPoly(
Poly2::createLine(origin, dest),stroke,joint,cap) ? node :
nullptr);
351 unsigned int segments = PATH_SEGMENTS,
352 PathJoint joint = PathJoint::NONE,
353 PathCap cap = PathCap::NONE) {
354 std::shared_ptr<PathNode> node = std::make_shared<PathNode>();
385 const std::shared_ptr<JsonValue>& data) {
386 std::shared_ptr<PathNode> result = std::make_shared<PathNode>();
387 if (!result->initWithData(loader,data)) { result =
nullptr; }
388 return std::dynamic_pointer_cast<Node>(result);
393 #pragma mark Attributes
463 #pragma mark Polygons
474 virtual void setPolygon(
const std::vector<Vec2>& vertices)
override;
552 #pragma mark Rendering
576 virtual void draw(
const std::shared_ptr<SpriteBatch>& batch,
const Mat4& transform,
Color4 tint)
override;
580 #pragma mark Internal Helpers
585 virtual void generateRenderData()
override;
590 void updateExtrusion();
593 CU_DISALLOW_COPY_AND_ASSIGN(
PathNode);
Definition: CUPathOutliner.h:79
static std::shared_ptr< PathNode > allocWithLine(const Vec2 &origin, const Vec2 &dest, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:327
void setStroke(float stroke)
bool getClosed() const
Definition: CUPathNode.h:426
virtual void setPolygon(const std::vector< Vec2 > &vertices) override
void setClosed(bool closed)
static std::shared_ptr< Node > allocWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data)
Definition: CUPathNode.h:384
const Size & getExtrudedContentSize() const
Definition: CUPathNode.h:534
PathCap getCap() const
Definition: CUPathNode.h:460
static Poly2 createEllipse(const Vec2 ¢er, const Size &size, unsigned int segments, bool solid=true)
Definition: CUColor4.h:1084
float width
Definition: CUSize.h:61
static PathOutliner _outliner
Definition: CUPathNode.h:116
PathJoint getJoint() const
Definition: CUPathNode.h:443
float getExtrudedContentHeight() const
Definition: CUPathNode.h:522
virtual void dispose() override
Definition: CUPathNode.h:110
static std::shared_ptr< PathNode > allocWithVertices(const std::vector< Vec2 > &vertices, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE, bool closed=true)
Definition: CUPathNode.h:261
Definition: CUPathExtruder.h:129
float getStroke() const
Definition: CUPathNode.h:409
Definition: CUSceneLoader.h:77
Poly2 _extrusion
Definition: CUPathNode.h:119
Rect _extrbounds
Definition: CUPathNode.h:121
bool initWithPoly(const Poly2 &poly, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
void setJoint(PathJoint joint)
PathCap _endcap
Definition: CUPathNode.h:130
static std::shared_ptr< PathNode > alloc()
Definition: CUPathNode.h:239
PathJoint _joint
Definition: CUPathNode.h:128
Definition: CUPoly2.h:109
static Poly2 createLine(const Vec2 &origin, const Vec2 &dest)
float _stroke
Definition: CUPathNode.h:126
virtual bool initWithData(const SceneLoader *loader, const std::shared_ptr< JsonValue > &data) override
static std::shared_ptr< PathNode > allocWithPoly(const Poly2 &poly, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:284
float getExtrudedContentWidth() const
Definition: CUPathNode.h:510
Size size
Definition: CURect.h:51
static PathExtruder _extruder
Definition: CUPathNode.h:114
bool _closed
Definition: CUPathNode.h:124
~PathNode()
Definition: CUPathNode.h:152
Definition: CUTexturedNode.h:84
static std::shared_ptr< PathNode > allocWithRect(const Rect &rect, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:306
virtual void draw(const std::shared_ptr< SpriteBatch > &batch, const Mat4 &transform, Color4 tint) override
bool initWithVertices(const std::vector< Vec2 > &vertices, float stroke, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE, bool closed=true)
static std::shared_ptr< PathNode > allocWithEllipse(const Vec2 ¢er, const Size &size, float stroke, unsigned int segments=PATH_SEGMENTS, PathJoint joint=PathJoint::NONE, PathCap cap=PathCap::NONE)
Definition: CUPathNode.h:350
float height
Definition: CUSize.h:63
const Rect & getExtrudedContentBounds() const
Definition: CUPathNode.h:549