Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. this.createWeld = function (bodyA, bodyB, anchorA, anchorB, noCollide, normalA, normalB) {
  2.  
  3. var obj = {
  4. jointDef: null,
  5. joint: null
  6. };
  7.  
  8. obj.jointDef = new b2WeldJointDef();
  9. obj.jointDef.bodyA = bodyA;
  10. obj.jointDef.bodyB = bodyB;
  11. obj.jointDef.localAnchorA = new b2Vec2( anchorA.x, anchorA.y );
  12. obj.jointDef.localAnchorB = new b2Vec2( anchorB.x, anchorB.y );
  13. obj.jointDef.collideConnected = !noCollide;
  14.  
  15. var dp = (normalA.x*normalB.x + normalA.y*normalB.y);
  16. var angle = Math.acos(Math.sqrt(normalA.x*normalA.x+normalA.y*normalA.y) * Math.sqrt(normalB.x*normalB.x+normalB.y*normalB.y));
  17.  
  18. obj.jointDef.referenceAngle = angle;
  19. obj.joint = this.world.CreateJoint( obj.jointDef );
  20.  
  21. return obj;
  22.  
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement