/// <summary> /// create a body, and set its shape and position immediately /// </summary> /// <param name="w">world to add this body to (done automatically)</param> /// <param name="shape">closed shape for this body</param> /// <param name="massPerPoint">mass for each PointMass to be created</param> /// <param name="position">global position of the body</param> /// <param name="angleInRadians">global angle of the body</param> /// <param name="scale">local scale of the body</param> /// <param name="kinematic">whether this body is kinematically controlled</param> public void Setup(World w, ClosedShape shape, float massPerPoint, Vector2 position, float angleInRadians, Vector2 scale, bool kinematic) { mAABB = new AABB(); DerivedPos = position; DerivedAngle = angleInRadians; mLastAngle = DerivedAngle; mScale = scale; mMaterial = 0; mIsStatic = float.IsPositiveInfinity(massPerPoint); mKinematic = kinematic; mPointMasses = new List <PointMass>(); setShape(shape); for (int i = 0; i < mPointMasses.Count; i++) { mPointMasses [i].Mass = massPerPoint; } updateAABB(0f, true); w.addBody(this); List <Vector2> points = new List <Vector2>(); foreach (PointMass m in mPointMasses) { points.Add(m.Position); } }
/// <summary> /// default constructor. /// </summary> /// <param name="w">world to add this body to (done automatically)</param> public void Setup(World w) { mAABB = new AABB(); mBaseShape = null; mGlobalShape = null; mPointMasses = new List <PointMass>(); mScale = Vector2.one; mIsStatic = false; mKinematic = false; mMaterial = 0; w.addBody(this); }
/// <summary> /// default constructor. /// </summary> /// <param name="w">world to add this body to (done automatically)</param> public Body(World w) { mAABB = new AABB(); mBaseShape = null; mGlobalShape = null; mPointMasses = new List<PointMass>(); mScale = Vector2.One; mIsStatic = false; mKinematic = false; mMaterial = 0; w.addBody(this); }
/// <summary> /// create a body, and set its shape and position immediately - with individual masses for each PointMass. /// </summary> /// <param name="w">world to add this body to (done automatically)</param> /// <param name="shape">closed shape for this body</param> /// <param name="pointMasses">list of masses for each PointMass</param> /// <param name="position">global position of the body</param> /// <param name="angleInRadians">global angle of the body</param> /// <param name="scale">local scale of the body</param> /// <param name="kinematic">whether this body is kinematically controlled.</param> public void Setup(World w, ClosedShape shape, List <float> pointMasses, Vector2 position, float angleInRadians, Vector2 scale, bool kinematic) { mAABB = new AABB(); DerivedPos = position; DerivedAngle = angleInRadians; mLastAngle = DerivedAngle; mScale = scale; mMaterial = 0; mIsStatic = false; mKinematic = kinematic; mPointMasses = new List <PointMass>(); setShape(shape); for (int i = 0; i < mPointMasses.Count; i++) { mPointMasses [i].Mass = pointMasses [i]; } updateAABB(0f, true); w.addBody(this); }
/// <summary> /// create a body, and set its shape and position immediately - with individual masses for each PointMass. /// </summary> /// <param name="w">world to add this body to (done automatically)</param> /// <param name="shape">closed shape for this body</param> /// <param name="pointMasses">list of masses for each PointMass</param> /// <param name="position">global position of the body</param> /// <param name="angleInRadians">global angle of the body</param> /// <param name="scale">local scale of the body</param> /// <param name="kinematic">whether this body is kinematically controlled.</param> public void Setup(World w, ClosedShape shape, List<float> pointMasses, Vector2 position, float angleInRadians, Vector2 scale, bool kinematic) { mAABB = new AABB(); DerivedPos = position; DerivedAngle = angleInRadians; mLastAngle = DerivedAngle; mScale = scale; mMaterial = 0; mIsStatic = false; mKinematic = kinematic; mPointMasses = new List<PointMass>(); setShape(shape); for (int i = 0; i < mPointMasses.Count; i++) mPointMasses [i].Mass = pointMasses [i]; updateAABB(0f, true); w.addBody(this); }
/// <summary> /// create a body, and set its shape and position immediately /// </summary> /// <param name="w">world to add this body to (done automatically)</param> /// <param name="shape">closed shape for this body</param> /// <param name="massPerPoint">mass for each PointMass to be created</param> /// <param name="position">global position of the body</param> /// <param name="angleInRadians">global angle of the body</param> /// <param name="scale">local scale of the body</param> /// <param name="kinematic">whether this body is kinematically controlled</param> public void Setup(World w, ClosedShape shape, float massPerPoint, Vector2 position, float angleInRadians, Vector2 scale, bool kinematic) { mAABB = new AABB(); DerivedPos = position; DerivedAngle = angleInRadians; mLastAngle = DerivedAngle; mScale = scale; mMaterial = 0; mIsStatic = float.IsPositiveInfinity(massPerPoint); mKinematic = kinematic; mPointMasses = new List<PointMass>(); setShape(shape); for (int i = 0; i < mPointMasses.Count; i++) mPointMasses [i].Mass = massPerPoint; updateAABB(0f, true); w.addBody(this); List<Vector2> points = new List<Vector2>(); foreach (PointMass m in mPointMasses) { points.Add(m.Position); } }