27 enum class Kind { Distance, Revolute, Prismatic, Weld, Wheel, Motor, Gear };
38 int getId()
const {
return id_; }
42 std::string getKind()
const;
44 int getBodyAId()
const;
46 int getBodyBId()
const;
55 void setCollideConnected(
bool collide);
57 bool getCollideConnected()
const;
60 void setDistanceLength(
float lengthPixels);
62 float getDistanceLength()
const;
64 void setDistanceSpring(
float frequencyHz,
float dampingRatio);
66 float getDistanceFrequency()
const;
68 float getDistanceDampingRatio()
const;
71 void setRevoluteLimits(
bool enabled,
float lower,
float upper);
73 void setRevoluteMotor(
bool enabled,
float speed,
float maxTorque);
75 float getRevoluteAngle()
const;
77 float getRevoluteSpeed()
const;
79 float getRevoluteMotorTorque()
const;
82 void setPrismaticLimits(
bool enabled,
float lowerPixels,
float upperPixels);
84 void setPrismaticMotor(
bool enabled,
float speedPixels,
float maxForcePixels);
86 float getPrismaticTranslation()
const;
88 float getPrismaticSpeed()
const;
91 void setWeldSpring(
float frequencyHz,
float dampingRatio);
93 float getWeldFrequency()
const;
95 float getWeldDampingRatio()
const;
98 void setWheelSpring(
float frequencyHz,
float dampingRatio);
100 void setWheelMotor(
bool enabled,
float speed,
float maxTorque);
102 float getWheelTranslation()
const;
104 float getWheelSpeed()
const;
107 void setMotorLinearOffset(
float xPixels,
float yPixels);
109 void setMotorAngularOffset(
float radians);
111 void setMotorLimits(
float maxForcePixels,
float maxTorque);
113 float getMotorLinearOffsetX()
const;
115 float getMotorLinearOffsetY()
const;
117 float getMotorAngularOffset()
const;
120 void setGearRatio(
float ratio);
122 float getGearRatio()
const;
141 bool isValid()
const;
145 b2Joint *
raw()
const {
return joint_; }
151 void requireKind(
Kind expected,
const char *
operation)
const;
154 World *world_ =
nullptr;
155 Body *bodyA_ =
nullptr;
156 Body *bodyB_ =
nullptr;
157 b2Joint *joint_ =
nullptr;
159 Kind kind_ = Kind::Distance;
161 Joint2D *gearJoint1_ =
nullptr;
162 Joint2D *gearJoint2_ =
nullptr;
2D rigid body (Box2D) in pixel-space coordinates. Owned by a World; create shapes with newRectangleFi...