Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.createWeld = function (bodyA, bodyB, anchorA, anchorB, noCollide, normalA, normalB) {
- var obj = {
- jointDef: null,
- joint: null
- };
- obj.jointDef = new b2WeldJointDef();
- obj.jointDef.bodyA = bodyA;
- obj.jointDef.bodyB = bodyB;
- obj.jointDef.localAnchorA = new b2Vec2( anchorA.x, anchorA.y );
- obj.jointDef.localAnchorB = new b2Vec2( anchorB.x, anchorB.y );
- obj.jointDef.collideConnected = !noCollide;
- var dp = (normalA.x*normalB.x + normalA.y*normalB.y);
- var angle = Math.acos(Math.sqrt(normalA.x*normalA.x+normalA.y*normalA.y) * Math.sqrt(normalB.x*normalB.x+normalB.y*normalB.y));
- obj.jointDef.referenceAngle = angle;
- obj.joint = this.world.CreateJoint( obj.jointDef );
- return obj;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement