Пример #1
0
 /// <summary>
 /// Default constructor, with shape-matching ON.
 /// </summary>
 /// <param name="w">World object to add this body to</param>
 /// <param name="s">ClosedShape for this body</param>
 /// <param name="massPerPoint">mass per PointMass</param>
 /// <param name="gasPressure">amount of gas inside the body</param>
 /// <param name="shapeSpringK">shape-matching spring constant</param>
 /// <param name="shapeSpringDamp">shape-matching spring damping</param>
 /// <param name="edgeSpringK">spring constant for edges</param>
 /// <param name="edgeSpringDamp">spring damping for edges</param>
 /// <param name="pos">global position</param>
 /// <param name="angleInRadians">global angle</param>
 /// <param name="scale">scale</param>
 /// <param name="kinematic">kinematic control boolean</param>
 public void Setup(World w, ClosedShape s, float massPerPoint, float gasPressure, float shapeSpringK, float shapeSpringDamp, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angleInRadians, Vector2 scale, bool kinematic)
 {
     base.Setup(w, s, massPerPoint, shapeSpringK, shapeSpringDamp, edgeSpringK, edgeSpringDamp, pos, angleInRadians, scale, kinematic);
     mGasAmount      = gasPressure;
     mNormalList     = new Vector2[mPointMasses.Count];
     mEdgeLengthList = new float[mPointMasses.Count];
 }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
 /// <summary>
 /// Default constructor, with shape-matching ON.
 /// </summary>
 /// <param name="w">World object to add this body to</param>
 /// <param name="s">ClosedShape for this body</param>
 /// <param name="massPerPoint">mass per PointMass</param>
 /// <param name="gasPressure">amount of gas inside the body</param>
 /// <param name="shapeSpringK">shape-matching spring constant</param>
 /// <param name="shapeSpringDamp">shape-matching spring damping</param>
 /// <param name="edgeSpringK">spring constant for edges</param>
 /// <param name="edgeSpringDamp">spring damping for edges</param>
 /// <param name="pos">global position</param>
 /// <param name="angleInRadians">global angle</param>
 /// <param name="scale">scale</param>
 /// <param name="kinematic">kinematic control boolean</param>
 public PressureBody(World w, ClosedShape s, float massPerPoint, float gasPressure, float shapeSpringK, float shapeSpringDamp, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angleInRadians, Vector2 scale, bool kinematic)
     : base(w, s, massPerPoint, shapeSpringK, shapeSpringDamp, edgeSpringK, edgeSpringDamp, pos, angleInRadians, scale, kinematic)
 {
     mGasAmount = gasPressure;
     mNormalList = new Vector2[mPointMasses.Count];
     mEdgeLengthList = new float[mPointMasses.Count];
 }
        private void AddPressureBody(ClosedShape shape)
        {
            DraggablePressureBody body = new DraggablePressureBody();
            body.Setup(JellyWorldManager.World, shape, 1.0f, 40.0f, 10.0f, 1.0f, 300.0f, 20.0f, transform.position, transform.rotation.eulerAngles.z, Vector2.one);
            body.Gravity = GravityModifier;

            body.addInternalSpring(0, 2, 400f, 12f);
            body.addInternalSpring(1, 3, 400f, 12f);
            _body = body;
        }
Пример #5
0
        private void AddPressureBody(ClosedShape shape)
        {
            DraggablePressureBody body = new DraggablePressureBody();

            body.Setup(JellyWorldManager.World, shape, 1.0f, 40.0f, 10.0f, 1.0f, 300.0f, 20.0f, transform.position, transform.rotation.eulerAngles.z, Vector2.one);
            body.Gravity = GravityModifier;

            body.addInternalSpring(0, 2, 400f, 12f);
            body.addInternalSpring(1, 3, 400f, 12f);
            _body = body;
        }
Пример #6
0
        /// <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);
        }
Пример #7
0
        /// <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);
        }
        private void CreateFloor()
        {
            // static ground object.
            GameObject ground = new GameObject ();
            ClosedShape groundShape = new ClosedShape ();
            groundShape.begin();
            groundShape.addVertex(new Vector2(-10f, -2f));
            groundShape.addVertex(new Vector2(-10f, 2f));
            groundShape.addVertex(new Vector2(10f, 2f));
            groundShape.addVertex(new Vector2(10f, -2f));
            groundShape.finish();

            // make the body.
            Body groundBody = new Body();
            groundBody.Setup(_world, groundShape, float.PositiveInfinity, new Vector2(0f, -5f), 0f, Vector2.one, false);
        }
Пример #9
0
        /// <summary>
        /// Create a Springbody with shape matching set to OFF.
        /// </summary>
        /// <param name="w">World to add this body to.</param>
        /// <param name="shape">ClosedShape shape for this body</param>
        /// <param name="massPerPoint">mass per PointMass.</param>
        /// <param name="edgeSpringK">spring constant for edges.</param>
        /// <param name="edgeSpringDamp">spring damping for edges</param>
        /// <param name="pos">global position of the body</param>
        /// <param name="angleinRadians">global angle of the body</param>
        /// <param name="scale">scale</param>
        /// <param name="kinematic">kinematic control boolean</param>
        public SpringBody(World w, ClosedShape shape, float massPerPoint, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angleinRadians, Vector2 scale, bool kinematic)
            : base(w, shape, massPerPoint, pos, angleinRadians, scale, kinematic)
        {
            mShapeMatchingOn = false;
            mSprings = new List<InternalSpring>();

            base.setPositionAngle(pos, angleinRadians, scale);

            mEdgeSpringK = edgeSpringK;
            mEdgeSpringDamp = edgeSpringDamp;
            mShapeSpringK = 0.0f;
            mShapeSpringDamp = 0.0f;

            // build default springs.
            _buildDefaultSprings();
        }
Пример #10
0
        /// <summary>
        /// Create a SpringBody with shape matching turned ON.
        /// </summary>
        /// <param name="w"></param>
        /// <param name="shape">ClosedShape shape for this body</param>
        /// <param name="massPerPoint">mass per PointMass.</param>
        /// <param name="shapeSpringK">shape-matching spring constant</param>
        /// <param name="shapeSpringDamp">shape-matching spring damping</param>
        /// <param name="edgeSpringK">spring constant for edges.</param>
        /// <param name="edgeSpringDamp">spring damping for edges</param>
        /// <param name="pos">global position</param>
        /// <param name="angleinRadians">global angle</param>
        /// <param name="scale">scale</param>
        /// <param name="kinematic">kinematic control boolean</param>
        public void Setup(World w, ClosedShape shape, float massPerPoint, float shapeSpringK, float shapeSpringDamp, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angleinRadians, Vector2 scale, bool kinematic)
        {
            base.Setup(w, shape, massPerPoint, pos, angleinRadians, scale, kinematic);
            mSprings = new List <InternalSpring>();

            base.setPositionAngle(pos, angleinRadians, scale);


            mShapeMatchingOn = true;
            mShapeSpringK    = shapeSpringK;
            mShapeSpringDamp = shapeSpringDamp;
            mEdgeSpringK     = edgeSpringK;
            mEdgeSpringDamp  = edgeSpringDamp;

            // build default springs.
            _buildDefaultSprings();
        }
Пример #11
0
        private void CreateFloor()
        {
            // static ground object.
            GameObject  ground      = new GameObject();
            ClosedShape groundShape = new ClosedShape();

            groundShape.begin();
            groundShape.addVertex(new Vector2(-10f, -2f));
            groundShape.addVertex(new Vector2(-10f, 2f));
            groundShape.addVertex(new Vector2(10f, 2f));
            groundShape.addVertex(new Vector2(10f, -2f));
            groundShape.finish();

            // make the body.
            Body groundBody = new Body();

            groundBody.Setup(_world, groundShape, float.PositiveInfinity, new Vector2(0f, -5f), 0f, Vector2.one, false);
        }
Пример #12
0
        /// <summary>
        /// set the shape of this body to a new ClosedShape object.  This function
        /// will remove any existing PointMass objects, and replace them with new ones IF
        /// the new shape has a different vertex count than the previous one.  In this case
        /// the mass for each newly added point mass will be set zero.  Otherwise the shape is just
        /// updated, not affecting the existing PointMasses.
        /// </summary>
        /// <param name="shape">new closed shape</param>
        public void setShape(ClosedShape shape)
        {
            mBaseShape = shape;

            if (mBaseShape.Vertices.Count != mPointMasses.Count)
            {
                mPointMasses.Clear();
                mGlobalShape = new Vector2[mBaseShape.Vertices.Count];

                Vector2 p = DerivedPos;
                mBaseShape.transformVertices(ref p, DerivedAngle, ref mScale, ref mGlobalShape);
                DerivedPos = p;

                for (int i = 0; i < mBaseShape.Vertices.Count; i++)
                {
                    mPointMasses.Add(new PointMass(0.0f, mGlobalShape [i]));
                }
            }
        }
Пример #13
0
        private void Start()
        {
            this.shape = GetComponent <Shape> ();

            SpriteRenderer    sprite = gameObject.GetComponent <SpriteRenderer>();
            PolygonCollider2D col    = gameObject.AddComponent <PolygonCollider2D>();

            Vector2[] points = col.points;

            Destroy(col);

            ClosedShape shape = new ClosedShape();

            shape.begin();

            int i = this.shape.Points.Length - 1, l = 0;

            for (; i > l; i -= detail)
            {
                shape.addVertex(this.shape.Points[i]);
            }

            if (i != l)
            {
                shape.addVertex(this.shape.Points[0]);
            }

            shape.finish();

            switch (type)
            {
            case JellyType.Spring:
                AddSpringBody(shape);
                break;

            case JellyType.Pressure:
                AddPressureBody(shape);
                break;
            }

            _spriteTexture = sprite.sprite.texture;
            sprite.enabled = false;
        }
Пример #14
0
        private void AddSpringBody(ClosedShape shape)
        {
            DraggableSpringBody body = new DraggableSpringBody();
            body.Setup(JellyWorldManager.World, shape, 1f, SpringK, Damping, SpringK, Damping, transform.position, transform.rotation.eulerAngles.z, Vector2.one);
            body.Gravity = GravityModifier;

            int i = springs.Count-1, l = -1;
            for(;i>l;i-=detail)
            {
                Vector2 v = springs[i];
                try{
                    //TODO: check if triangle is already added, if so, flip triangle.
                    body.addInternalSpring((int)v.x, (int)v.y,SpringK,Damping);
                }
                catch{
            //                  Debug.Log("couldnt add spring at " +i);
                }
            }
            _body = body;
        }
Пример #15
0
        /// <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);
        }
Пример #16
0
        private void AddSpringBody(ClosedShape shape)
        {
            DraggableSpringBody body = new DraggableSpringBody();

            body.Setup(JellyWorldManager.World, shape, 1f, SpringK, Damping, SpringK, Damping, transform.position, transform.rotation.eulerAngles.z, Vector2.one);
            body.Gravity = GravityModifier;

            int i = springs.Count - 1, l = -1;

            for (; i > l; i -= detail)
            {
                Vector2 v = springs[i];
                try{
                    //TODO: check if triangle is already added, if so, flip triangle.
                    body.addInternalSpring((int)v.x, (int)v.y, SpringK, Damping);
                }
                catch {
//                  Debug.Log("couldnt add spring at " +i);
                }
            }
            _body = body;
        }
Пример #17
0
        private void Start()
        {
            this.shape = GetComponent<Shape> ();

            SpriteRenderer sprite = gameObject.GetComponent<SpriteRenderer>();
            PolygonCollider2D col = gameObject.AddComponent<PolygonCollider2D>();

            Vector2[] points = col.points;

            Destroy(col);

            ClosedShape shape = new ClosedShape();

            shape.begin();

            int i = this.shape.Points.Length-1, l = 0;
            for(;i>l;i-=detail)
            {
                shape.addVertex( this.shape.Points[i]);
            }

            if(i!=l)
            {
                shape.addVertex(this.shape.Points[0]);
            }

            shape.finish();

            switch (type)
            {
            case JellyType.Spring:
                AddSpringBody(shape);
                break;
            case JellyType.Pressure:
                    AddPressureBody(shape);
                    break;
            }

            _spriteTexture = sprite.sprite.texture;
            sprite.enabled = false;
        }
Пример #18
0
        /// <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);
        }
Пример #19
0
        /// <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);
            }
        }
Пример #20
0
        /// <summary>
        /// set the shape of this body to a new ClosedShape object.  This function 
        /// will remove any existing PointMass objects, and replace them with new ones IF
        /// the new shape has a different vertex count than the previous one.  In this case
        /// the mass for each newly added point mass will be set zero.  Otherwise the shape is just
        /// updated, not affecting the existing PointMasses.
        /// </summary>
        /// <param name="shape">new closed shape</param>
        public void setShape(ClosedShape shape)
        {
            mBaseShape = shape;

            if (mBaseShape.Vertices.Count != mPointMasses.Count)
            {
                mPointMasses.Clear();
                mGlobalShape = new Vector2[mBaseShape.Vertices.Count];

                Vector2 p = DerivedPos;
                mBaseShape.transformVertices(ref p, DerivedAngle, ref mScale, ref mGlobalShape);
                DerivedPos = p;

                for (int i = 0; i < mBaseShape.Vertices.Count; i++)
                    mPointMasses.Add(new PointMass(0.0f, mGlobalShape [i]));
            }
        }
Пример #21
0
        /// <summary>
        /// Create a SpringBody with shape matching turned ON.
        /// </summary>
        /// <param name="w"></param>
        /// <param name="shape">ClosedShape shape for this body</param>
        /// <param name="massPerPoint">mass per PointMass.</param>
        /// <param name="shapeSpringK">shape-matching spring constant</param>
        /// <param name="shapeSpringDamp">shape-matching spring damping</param>
        /// <param name="edgeSpringK">spring constant for edges.</param>
        /// <param name="edgeSpringDamp">spring damping for edges</param>
        /// <param name="pos">global position</param>
        /// <param name="angleinRadians">global angle</param>
        /// <param name="scale">scale</param>
        /// <param name="kinematic">kinematic control boolean</param>
        public void Setup(World w, ClosedShape shape, float massPerPoint, float shapeSpringK, float shapeSpringDamp, float edgeSpringK, float edgeSpringDamp, Vector2 pos, float angleinRadians, Vector2 scale, bool kinematic)
        {
            base.Setup (w, shape, massPerPoint, pos, angleinRadians, scale, kinematic);
            mSprings = new List<InternalSpring>();

            base.setPositionAngle(pos, angleinRadians, scale);

            mShapeMatchingOn = true;
            mShapeSpringK = shapeSpringK;
            mShapeSpringDamp = shapeSpringDamp;
            mEdgeSpringK = edgeSpringK;
            mEdgeSpringDamp = edgeSpringDamp;

            // build default springs.
            _buildDefaultSprings();
        }
Пример #22
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            #if XBOX360
            graphics.PreferredBackBufferWidth = this.Window.ClientBounds.Width;
            graphics.PreferredBackBufferHeight = this.Window.ClientBounds.Height;
            graphics.PreferMultiSampling = true;
            #else
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;
            #endif
            graphics.ApplyChanges();

            screenWidth = graphics.GraphicsDevice.Viewport.Width;
            screenHeight = graphics.GraphicsDevice.Viewport.Height;

            // setup camera
            cameraPos = new Vector3(-2f, -15f, 25f);
            cameraLookVector = Vector3.Forward;

            // basic effect used for drawing all objects, based on vertexcolor.
            lineEffect = new BasicEffect(graphics.GraphicsDevice, null);
            lineEffect.LightingEnabled = false;
            lineEffect.VertexColorEnabled = true;
            lineEffect.Alpha = 1.0f;

            // initialize physics world
            mWorld = new World();

            // lists to keep track of bodies.
            mSpringBodies = new List<DraggableSpringBody>();
            mPressureBodies = new List<DraggablePressureBody>();
            mStaticBodies = new List<Body>();

            // STATIC COLLISION SHAPE
            // all Closed Shape objects are assumed to be a list of lines going from point to point, with the last point
            // connecting back to the first point to close the shape.  This is a simple rectangle to represent the ground for this demo.
            // ClosedShape objects are automatically "centered" when you call finish(), and that center becomes the center when
            // setting the position of the object.
            ClosedShape stat = new ClosedShape();
            stat.begin();
            stat.addVertex(new Vector2(-20f,-1f));
            stat.addVertex(new Vector2(-20f, 1f));
            stat.addVertex(new Vector2(20f, 1f));
            stat.addVertex(new Vector2(20f, -1f));
            stat.finish();

            // creating the body.  Since this is a static body, we can use the base class Body.
            // setting the mass per point to PositiveInfinity makes it immobile / static.
            Body b = new Body(mWorld, stat, float.PositiveInfinity, new Vector2(0f, -19f), 0, Vector2.One, false);
            mStaticBodies.Add(b);

            // this is a more complex body, in the shape of a capital "I", and connected with many internal springs.
            ClosedShape shape = new ClosedShape();
            shape.begin();
            shape.addVertex(new Vector2(-1.5f, 2.0f));
            shape.addVertex(new Vector2(-0.5f, 2.0f));
            shape.addVertex(new Vector2(0.5f, 2.0f));
            shape.addVertex(new Vector2(1.5f, 2.0f));
            shape.addVertex(new Vector2(1.5f, 1.0f));
            shape.addVertex(new Vector2(0.5f, 1.0f));
            shape.addVertex(new Vector2(0.5f, -1.0f));
            shape.addVertex(new Vector2(1.5f, -1.0f));
            shape.addVertex(new Vector2(1.5f, -2.0f));
            shape.addVertex(new Vector2(0.5f, -2.0f));
            shape.addVertex(new Vector2(-0.5f, -2.0f));
            shape.addVertex(new Vector2(-1.5f, -2.0f));
            shape.addVertex(new Vector2(-1.5f, -1.0f));
            shape.addVertex(new Vector2(-0.5f, -1.0f));
            shape.addVertex(new Vector2(-0.5f, 1.0f));
            shape.addVertex(new Vector2(-1.5f, 1.0f));
            shape.finish();

            // draggablespringbody is an inherited version of SpringBody that includes polygons for visualization, and the
            // ability to drag the body around the screen with the cursor.
            for (int x = -8; x <= 8; x += 4)
            {
                DraggableSpringBody body = new DraggableSpringBody(mWorld, shape, 1f, 150.0f, 5.0f, 300.0f, 15.0f, new Vector2(x, 0), 0.0f, Vector2.One);
                body.addInternalSpring(0, 14, 300.0f, 10.0f);
                body.addInternalSpring(1, 14, 300.0f, 10.0f);
                body.addInternalSpring(1, 15, 300.0f, 10.0f);
                body.addInternalSpring(1, 5, 300.0f, 10.0f);
                body.addInternalSpring(2, 14, 300.0f, 10.0f);
                body.addInternalSpring(2, 5, 300.0f, 10.0f);
                body.addInternalSpring(1, 5, 300.0f, 10.0f);
                body.addInternalSpring(14, 5, 300.0f, 10.0f);
                body.addInternalSpring(2, 4, 300.0f, 10.0f);
                body.addInternalSpring(3, 5, 300.0f, 10.0f);
                body.addInternalSpring(14, 6, 300.0f, 10.0f);
                body.addInternalSpring(5, 13, 300.0f, 10.0f);
                body.addInternalSpring(13, 6, 300.0f, 10.0f);
                body.addInternalSpring(12, 10, 300.0f, 10.0f);
                body.addInternalSpring(13, 11, 300.0f, 10.0f);
                body.addInternalSpring(13, 10, 300.0f, 10.0f);
                body.addInternalSpring(13, 9, 300.0f, 10.0f);
                body.addInternalSpring(6, 10, 300.0f, 10.0f);
                body.addInternalSpring(6, 9, 300.0f, 10.0f);
                body.addInternalSpring(6, 8, 300.0f, 10.0f);
                body.addInternalSpring(7, 9, 300.0f, 10.0f);

                // polygons!
                body.addTriangle(0, 15, 1);
                body.addTriangle(1, 15, 14);
                body.addTriangle(1, 14, 5);
                body.addTriangle(1, 5, 2);
                body.addTriangle(2, 5, 4);
                body.addTriangle(2, 4, 3);
                body.addTriangle(14, 13, 6);
                body.addTriangle(14, 6, 5);
                body.addTriangle(12, 11, 10);
                body.addTriangle(12, 10, 13);
                body.addTriangle(13, 10, 9);
                body.addTriangle(13, 9, 6);
                body.addTriangle(6, 9, 8);
                body.addTriangle(6, 8, 7);
                body.finalizeTriangles(Color.SpringGreen, Color.Navy);

                mSpringBodies.Add(body);
            }

            // pressure body. similar to a SpringBody, but with internal pressurized gas to help maintain shape.
            JelloPhysics.ClosedShape ball = new ClosedShape();
            ball.begin();
            for (int i = 0; i < 360; i += 20)
            {
                ball.addVertex(new Vector2((float)Math.Cos(MathHelper.ToRadians((float)-i)), (float)Math.Sin(MathHelper.ToRadians((float)-i))));
            }
            ball.finish();

            // make many of these.
            for (int x = -10; x <= 10; x+=5)
            {
                DraggablePressureBody pb = new DraggablePressureBody(mWorld, ball, 1.0f, 40.0f, 10.0f, 1.0f, 300.0f, 20.0f, new Vector2(x, -12), 0, Vector2.One);
                pb.addTriangle(0, 10, 9);
                pb.addTriangle(0, 9, 1);
                pb.addTriangle(1, 9, 8);
                pb.addTriangle(1, 8, 2);
                pb.addTriangle(2, 8, 7);
                pb.addTriangle(2, 7, 3);
                pb.addTriangle(3, 7, 6);
                pb.addTriangle(3, 6, 4);
                pb.addTriangle(4, 6, 5);
                pb.addTriangle(17, 10, 0);
                pb.addTriangle(17, 11, 10);
                pb.addTriangle(16, 11, 17);
                pb.addTriangle(16, 12, 11);
                pb.addTriangle(15, 12, 16);
                pb.addTriangle(15, 13, 12);
                pb.addTriangle(14, 12, 15);
                pb.addTriangle(14, 13, 12);
                pb.finalizeTriangles((x==-10) ? Color.Teal : Color.Maroon);
                mPressureBodies.Add(pb);
            }

            // default cursor position, etc.
            mCursorPos = new Vector2(cameraPos.X, cameraPos.Y);

            base.Initialize();
        }