48 #ifndef __CU_OBSTACLE_SELECTOR_H__
49 #define __CU_OBSTACLE_SELECTOR_H__
51 #include <Box2D/Dynamics/Joints/b2MouseJoint.h>
52 #include <Box2D/Dynamics/b2Fixture.h>
56 #define DEFAULT_MSIZE 0.2f
58 #define DEFAULT_FREQUENCY 10.0f
60 #define DEFAULT_DAMPING 0.7f
62 #define DEFAULT_FORCE 1000.0f
70 #pragma mark Obstacle Selector
120 #pragma mark Scene Graph Internals
157 #pragma mark Constructors
168 _controller(nullptr), _selection(nullptr), _ground(nullptr),
169 _mouseJoint(nullptr), _scene(nullptr), _hatch(nullptr),
196 bool init(
const std::shared_ptr<ObstacleWorld>& world) {
197 return init(world,
Size(DEFAULT_MSIZE, DEFAULT_MSIZE));
212 bool init(
const std::shared_ptr<ObstacleWorld>& world,
const Size& mouseSize);
215 #pragma mark Static Constructors
228 static std::shared_ptr<ObstacleSelector>
alloc(
const std::shared_ptr<ObstacleWorld>& world) {
229 std::shared_ptr<ObstacleSelector> result = std::make_shared<ObstacleSelector>();
230 return (result->init(world) ? result :
nullptr);
245 static std::shared_ptr<ObstacleSelector>
alloc(
const std::shared_ptr<ObstacleWorld>& world,
246 const Size& mouseSize) {
247 std::shared_ptr<ObstacleSelector> result = std::make_shared<ObstacleSelector>();
248 return (result->init(world,mouseSize) ? result :
nullptr);
251 #pragma mark Positional Methods
276 #pragma mark Selection Methods
323 bool onQuery(b2Fixture* fixture);
326 #pragma mark Attribute Properties
365 void setDamping(
float ratio) { _jointDef.dampingRatio = ratio; }
413 #pragma mark Scene Graph Methods
434 if (_hatch) { _hatch->setColor(color); }
435 if (_connect) { _connect->setColor(color); }
493 if (_hatch) { _hatch->setVisible(flag); }
494 if (_connect) { _connect->setVisible(flag); }
Color4 _dcolor
Definition: CUObstacleSelector.h:117
float x
Definition: CUVec2.h:66
float y
Definition: CUVec2.h:68
Definition: CUPoly2.h:115
void setDebugColor(Color4 color)
Definition: CUObstacleSelector.h:432
Size _size
Definition: CUObstacleSelector.h:92
b2Fixture * _selection
Definition: CUObstacleSelector.h:97
std::shared_ptr< WireNode > _connect
Definition: CUObstacleSelector.h:111
static std::shared_ptr< ObstacleSelector > alloc(const std::shared_ptr< ObstacleWorld > &world)
Definition: CUObstacleSelector.h:228
void setForce(float force)
Definition: CUObstacleSelector.h:385
static std::shared_ptr< ObstacleSelector > alloc(const std::shared_ptr< ObstacleWorld > &world, const Size &mouseSize)
Definition: CUObstacleSelector.h:245
b2Body * _ground
Definition: CUObstacleSelector.h:99
float _force
Definition: CUObstacleSelector.h:94
b2MouseJoint * _mouseJoint
Definition: CUObstacleSelector.h:104
std::shared_ptr< ObstacleWorld > _controller
Definition: CUObstacleSelector.h:87
bool _dvisible
Definition: CUObstacleSelector.h:115
Color4 getDebugColor() const
Definition: CUObstacleSelector.h:422
bool isVisible()
Definition: CUObstacleSelector.h:505
void setVisible(bool flag)
Definition: CUObstacleSelector.h:491
void setFrequency(float speed)
Definition: CUObstacleSelector.h:345
std::shared_ptr< Node > _scene
Definition: CUObstacleSelector.h:107
Vec2 _position
Definition: CUObstacleSelector.h:90
bool onQuery(b2Fixture *fixture)
bool init(const std::shared_ptr< ObstacleWorld > &world)
Definition: CUObstacleSelector.h:196
float getDamping() const
Definition: CUObstacleSelector.h:355
Definition: CUObstacleSelector.h:84
float getForce() const
Definition: CUObstacleSelector.h:375
Node * getDebugScene() const
Definition: CUObstacleSelector.h:458
b2MouseJointDef _jointDef
Definition: CUObstacleSelector.h:102
void updateTarget(Obstacle *obstacle)
Definition: CUObstacle.h:76
bool hasDebug()
Definition: CUObstacleSelector.h:515
void setPosition(float x, float y)
std::shared_ptr< WireNode > _hatch
Definition: CUObstacleSelector.h:109
void setMouseSize(const Size &size)
Definition: CUObstacleSelector.h:409
Definition: CUColor4.h:1104
ObstacleSelector()
Definition: CUObstacleSelector.h:167
void setPosition(const Vec2 &pos)
Definition: CUObstacleSelector.h:272
float getFrequency() const
Definition: CUObstacleSelector.h:335
Definition: CUAnimationNode.h:52
const Vec2 & getPosition()
Definition: CUObstacleSelector.h:257
void setDebugScene(const std::shared_ptr< Node > &node)
void setDamping(float ratio)
Definition: CUObstacleSelector.h:365
bool isSelected() const
Definition: CUObstacleSelector.h:282
const Size & getMouseSize() const
Definition: CUObstacleSelector.h:397
~ObstacleSelector()
Definition: CUObstacleSelector.h:175