private void InitClothScene()
        {
            //cloth attributes
            int length = 10;
            int width = 5;
            int lengthSegments = 20;
            int widthSegments = 15;

            //load in a plane
            clothPlane = new TexturedPlane(this, length, width, lengthSegments, widthSegments, @"checkerboard");
            clothPlane.Initialize();

            //create a cloth sim
            float clothMass = 2.0f;
            float structStiffness = 2.0f;
            float structDamping = 0.02f;
            float shearStiffness = 2.0f;
            float shearDamping = 0.02f;
            float bendStiffness = 2.0f;
            float bendDamping = 0.02f;
            clothSim = new ClothSim(this, clothPlane, clothMass, structStiffness, structDamping, shearStiffness, shearDamping, bendStiffness, bendDamping);
            clothSim.ConstraintIterations = 10;

            //add in a global forceGenerators: gravity
            Gravity gravity = new Gravity(new Vector3(0, -9.81f, 0));
            clothSim.AddGlobalForceGenerator(gravity);

            //constrain the two top corners of the cloth so that we can control it
            topLeftCorner = new PointConstraint(clothSim.SimVertices[0].CurrPosition, clothSim.SimVertices[0]);
            clothSim.Constraints.Add(topLeftCorner);
            topRightCorner = new PointConstraint(clothSim.SimVertices[lengthSegments].CurrPosition, clothSim.SimVertices[lengthSegments]);
            clothSim.Constraints.Add(topRightCorner);

            //create an integrator and assign it to the sim
            float drag = 0.01f;
            Integrator integrator = new VerletNoVelocityIntegrator(this, drag);
            clothSim.Integrator = integrator;
        }
        private void InitSpringScene()
        {
            //load in a cube and a sphere
            GameModel stationaryCube = modelComponent.LoadGameModel(@"cube");
            stationaryCube.TranslateY = 5;
            GameModel movingSphere = modelComponent.LoadGameModel(@"sphere");

            //create a spring sim
            springSim = new Simulation(this);

            //create sim objects from the loaded models
            float sphereMass = 1.0f;
            movingSphereSimObj = new SimModel(movingSphere, sphereMass, SimObjectType.ACTIVE);
            springSim.AddSimObject(movingSphereSimObj);
            stationaryCubeSimObj = new SimModel(stationaryCube, 1000.0f, SimObjectType.PASSIVE);
            springSim.AddSimObject(stationaryCubeSimObj);

            //add in a global force generator: gravity
            Gravity gravity = new Gravity(new Vector3(0, -9.81f, 0));
            springSim.AddGlobalForceGenerator(gravity);

            //add in a global force generator: air
            float dragCoefficient = 0.5f;
            Medium air = new Medium(dragCoefficient);
            springSim.AddGlobalForceGenerator(air);

            //attach a spring between the sim objects
            float stiffness = 8.0f;
            float damping = 0.1f;
            springSim.AddSpring(stiffness, damping, stationaryCubeSimObj, movingSphereSimObj);

            //create an integrator and assign it to the sim
            ForwardEulerIntegrator integrator = new ForwardEulerIntegrator(this);
            springSim.Integrator = integrator;

            //init the line from cube to sphere that represents the spring
            line3DComponent.StartPosition = stationaryCube.Translate;
            line3DComponent.EndPosition = movingSphere.Translate;
            line3DComponent.Color = Color.White;
        }
        private void InitChainScene()
        {
            //chain attributes
            int numSegments = 30;
            float separation = 0.65f;

            //load in segments
            GameModel[] segments = new GameModel[numSegments];
            for (int i = 0; i < numSegments; i++)
            {
                segments[i] = modelComponent.LoadGameModel("chainSegment");

                //reduce the size of each segment
                segments[i].Scale = 0.3f * Vector3.One;

                //position each segment downwards incrementally to form the chain
                segments[i].TranslateY = -i * separation;

                //rotate the even segments by 90 degrees in Y axis
                segments[i].RotateY = (i % 2) * 90.0f;
            }

            //create a chain sim
            float totalMass = 1.0f;
            float stiffness = 0.3f;
            float damping = 0.01f;
            chainSim = new ChainSim(this, segments, totalMass, stiffness, damping);

            //add in a global force generator: gravity
            Gravity gravity = new Gravity(new Vector3(0, -9.81f * 5, 0));
            chainSim.AddGlobalForceGenerator(gravity);

            //constrain the head point so that we can control it
            chainHeadPoint = new PointConstraint(Vector3.Zero, chainSim.SimObjects[0]);
            chainSim.Constraints.Add(chainHeadPoint);

            //create a integrator and assign it to the sim
            float drag = 0.005f;
            Integrator integrator = new VerletNoVelocityIntegrator(this, drag);
            chainSim.Integrator = integrator;
        }
        private void InitGoalSoftBodyScene()
        {
            //cylinder attribute
            float length = 10.0f;
            float radius = 3.0f;
            int lengthSegments = 30;
            int radialSegments = 50;

            //load in the cylinder
            cylinder = new TexturedCylinder(this, length, radius, lengthSegments, radialSegments, "slinky");
            cylinder.Initialize();

            //load in another same cylinder as the goal
            goalCylinder = new TexturedCylinder(this, length, radius, lengthSegments, radialSegments, "checkerboard");
            goalCylinder.Initialize();

            //create a goal soft body sim
            float mass = 0.1f;
            float stiffness = 0.03f;
            float damping = 0.0f;
            goalSoftBodySim = new GoalSoftBodySim(this, cylinder, goalCylinder, mass, stiffness, damping);

            //create a force generator that we will use to push the cylinder later
            push = new Gravity(Vector3.Zero);
            goalSoftBodySim.AddGlobalForceGenerator(push);

            //create an integrator and assign it to the sim
            float drag = 0.05f;
            Integrator integrator = new VerletNoVelocityIntegrator(this, drag);
            goalSoftBodySim.Integrator = integrator;
        }