I decided to zip the whole package in case anyone had trouble compiling.
NEW FILES:
- RagDoll.h
- Biped.cpp
- Biped.h
- BipedDef.cpp
- BipedDef.h
MODIFIED:
- VC8 solution and project files
- TestEntries.cpp
Available for download here:
http://www.sfu.ca/~mnb2/Box2D.zipHOW TO USE:
To create a new biped (ragdoll) only requires two lines of code:
BipedDef bd;
Biped(m_world,&bd); // creates a new biped at (0,0) in m_world
You may want to keep a reference to your biped object so that you can modify its parameters later:
Biped bip* = new Biped(m_world, &bd);
Don't forget to delete it.
You can modify all the body parts at once by making these calls to BipedDef:
void SetMotorTorque(float);
void SetMotorSpeed(float);
void SetDensity(float);
void SetFriction(float);
void SetRestitution(float);
void SetLinearDamping(float);
void SetAngularDamping(float);
void EnableLimit();
void DisableLimit();
void SetLimit(bool);
void EnableMotor();
void DisableMotor();
void SetMotor(bool);
void SetGroupIndex(int16);
void SetPosition(float, float);
void SetPosition(b2Vec2);
void IsFast(bool); // this function has been commented out for earlier versions of Box2D
Also for your convenience (in Biped) are:
float GetMass(); // get the mass of the entire Biped (default is about 60 kg = 130 density)
b2Vec2 GetCenterPosition(); // get the center position of the entire biped
Or you can modify them individually by calling
bd.<BodyPart>Def to modify the body definitions
bd.<BodyPart>Poly to modify the poly definitions, with the exception of Head, which is HeadCirc
bd.<Joint>Def to modify the joint definitions
Body parts: LFoot, RFoot, LCalf, RCalf, LThigh, RThigh, Pelvis, Stomach, Chest, Neck, Head, LUpperArm, RUpperArm, LForearm, RForearm, LHand, RHand
Joints: LAnkle, RAnkle, LKnee, RKnee, LHip, RHip, LowerAbs, UpperAbs, LowerNeck, UpperNeck, LShoulder, RShoulder, LElbow, RElbow, LWrist, RWrist
Questions, comments and critique are welcome. Let me know if I have any memory leaks, that's not really my specialty.
Also, I would much appreciate anyone's help trying to get one of these things walking on their own.