WELD JOINT

21
Jun
2012



The weld joint attempts to constrain all relative motion between two bodies.
Make sure the following codes are at the beginning.

var    b2Vec2 = Box2D.Common.Math.b2Vec2
,      b2BodyDef = Box2D.Dynamics.b2BodyDef
,      b2Body = Box2D.Dynamics.b2Body
,      b2FixtureDef = Box2D.Dynamics.b2FixtureDef
,      b2World = Box2D.Dynamics.b2World
,      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
,      b2CircleShape = Box2D.Collision.Shapes.b2CircleShape
,      b2MouseJointDef =  Box2D.Dynamics.Joints.b2MouseJointDef
,	   b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef
,      b2DebugDraw = Box2D.Dynamics.b2DebugDraw
,      b2Fixture = Box2D.Dynamics.b2Fixture
,      b2AABB = Box2D.Collision.b2AABB;
Line 9 should be present.

Weld Joint Definition

var weldJointDef = new b2WeldJointDef();
weldJointDef.Initialize(box1, box2, new b2Vec2(12,2)); // (BodyA, BodyB, Anchor Point)
weldJointDef.referenceAngle = 0; // The bodyB angle minus bodyA angle in the reference state (radians).
weldJointDef.frequencyHz = 1.0; // The mass-spring-damper frequency in Hertz. Rotation only.
weldJointDef.dampingRatio = 0.5; // The damping ratio. 0 = no damping, 1 = critical damping.
var weld_joint = world.CreateJoint(weldJointDef);
It is not important that anchor point lies on the two bodies.

By administrator at 09:38:49 PM 0 Comment(s)

Comments

There are no comments yet. Be the first one to add a comment!

Add a Comment

Please enter the email address.Invalid format. (Won't be Displayed)
Notify me of followup comments
Enter the displayed Code: captcha