1. //Here is the code i use for calling the rope into existance...
  2.  
  3. LeftRopeLinks = ComplexFactory.Instance.CreateChain(g_Game.GET.physicsSimulator, Body.Position, TargetPos, 30, 10, 0.5f, true, false, LinkType.RevoluteJoint, Body, true, 3f);
  4. LeftRopeLinks.CreateGeoms(CollisionCategory.Cat10, CollisionCategory.Cat1, g_Game.GET.physicsSimulator);
  5.  
  6.  
  7. //Here is the modified Createchain class (im using revolute joints) it creates the chain and then shoots it out like a grappiling hook
  8.  
  9. public Path CreateChain(PhysicsSimulator physicsSimulator, Vector2 start, Vector2 end, float width, float height, float mass, bool pinStart,
  10. bool pinEnd, LinkType type, Body FirstObject, bool SpitOut, float PullUpPower)
  11. {
  12. float PullPowerMulti = 180000;
  13. float LinkBias = 0.1f;
  14. float LinkSoftness = 2.5f;
  15. Path path;
  16.  
  17. if (type == LinkType.PinJoint)
  18. {
  19. PullPowerMulti = 600000;
  20. LinkBias = 0.2f;
  21. LinkSoftness = 0.4f;
  22. path = new Path(width, height, width / PullUpPower * 2, mass, false);
  23. }
  24. else if (type == LinkType.SliderJoint)
  25. {
  26. PullPowerMulti = 300000;
  27. LinkBias = 0.05f;
  28. LinkSoftness = 0.4f;
  29. path = new Path(width, height, width / PullUpPower, mass, false);
  30. }
  31. else
  32. {
  33. path = new Path(width, height, width / PullUpPower, mass, false);
  34. }
  35.  
  36. path.Add(start);
  37. path.Add(Path.FindMidpoint(start, end));
  38. path.Add(end);
  39. path.Update();
  40. path.LinkBodies(type, Min, Max, SpringConstant, DampingConstant);
  41.  
  42. Vector2 Offset = start - end;
  43. float Angle = (float)Math.Atan2(Offset.Y, Offset.X);
  44.  
  45. for (int i = 0; i < path.Bodies.Count; i++)
  46. {
  47. path.Bodies[i].position = start;
  48. path.Bodies[i].ApplyForce(GetOffset(Angle + MathHelper.PiOver2, (i * i * i * (PullPowerMulti / (path.Bodies.Count * path.Bodies.Count * path.Bodies.Count))) + 1));
  49. }
  50.  
  51. if (pinStart)
  52. path.Add(JointFactory.Instance.CreateRevoluteJoint(path.Bodies[0], FirstObject, start - new Vector2(0, -0)));
  53. if (pinEnd)
  54. path.Add(JointFactory.Instance.CreateFixedRevoluteJoint(path.Bodies[path.Bodies.Count - 1], path.ControlPoints[2]));
  55.  
  56. foreach (Joint j in path.Joints)
  57. {
  58. j.BiasFactor = LinkBias;
  59. j.Softness = LinkSoftness;
  60. }
  61.  
  62. path.AddToPhysicsSimulator(physicsSimulator);
  63. return (path);
  64. }
  65.  
  66. // Here is my create geom function
  67.  
  68. public void CreateGeoms(CollisionCategory collisionCategory, CollisionCategory collidesWith, PhysicsSimulator physicsSimulator)
  69. {
  70. _BodyLength = _bodies.Count;
  71. for (int i = 0; i < _BodyLength; i++)
  72. {
  73. //TODO: Cache this value.
  74. RopeLinkVerts = Vertices.CreateSimpleRectangle(_width, _height);
  75. _geoms.Add(new Geom(_bodies[i], RopeLinkVerts, Vector2.Zero, 0, 0));
  76. _geoms[i].CollisionCategories = collisionCategory;
  77. _geoms[i].CollidesWith = collidesWith;
  78. physicsSimulator.Add(_geoms[i]);
  79. }
  80. }