public PhysicsEngine GetPhysicsEnvironment()
		{
			var simulationParam = new SimulationParameters();
			var solverParameters = new SolverParameters();
			var collisionEngineParam = new CollisionEngineParameters();

			var physicsEnvironment = new PhysicsEngine(
													simulationParam,
													collisionEngineParam,
													solverParameters);

			physicsEnvironment.AddObject(getSimulationObjects()[0]);
			physicsEnvironment.RemoveObject(0);

			return physicsEnvironment;
		}
		public CollisionDetectionEngine (
			CollisionEngineParameters collisionEngineParameters)
		{
			this.collisionEngineParameters = collisionEngineParameters;

			collisionEngine = new GJK (
				collisionEngineParameters.MaxGJKIteration,
				collisionEngineParameters.Precision,
				collisionEngineParameters.GJKManifoldTolerance,
				collisionEngineParameters.ManifoldPointNumber);

			compenetrationCollisionEngine = new EPA (
				collisionEngineParameters.MaxEPAIteration,
				collisionEngineParameters.Precision,
				collisionEngineParameters.EPAManifoldTolerance,
				collisionEngineParameters.ManifoldPointNumber);

			sweepAndPruneEngine = new SweepAndPruneEngine (collisionEngineParameters);
		}
		public PhysicsEngine (
			SimulationParameters simulationParameters,
			CollisionEngineParameters collisionEngineParameters,
			SolverParameters solverParameters)
		{
			SolverParam = solverParameters;

			SetSolver(SolverType.NonLinearConjugateGradient);

			CollisionEngineParam = collisionEngineParameters;

			collisionEngine = new CollisionDetectionEngine(collisionEngineParameters);

			SimulationEngineParameters = simulationParameters;

			contactPartitioningEngine = new ContactPartitioningEngine();

			simulationObjects = new SimulationObject[0];
			simulationJoints = new List<IConstraint> ();
		}
		public SweepAndPruneEngine(CollisionEngineParameters collisionEngineParameters)
		{
			this.collisionEngineParameters = collisionEngineParameters;
		}
		void initProgram()
		{
			try
			{
                //var env = new BuildEnvironment();
                //env.GetPhysicsEnvironment();

                //LoadObject loadObject = new LoadObject ("startJoint.xml");
                //LoadObject loadObject = new LoadObject ("configJoint.xml");
                //var loadObject = new LoadObject ("startConfig.xml");
                //var loadObject = new LoadObject ("carConfig.xml");
                //var loadObject = new LoadObject("testJointBridge.xml");
                var loadObject = new LoadObject("compositeObjectConfig.xml");

                simulationObjects = loadObject.LoadSimulationObjects ();
				simulationJoints = loadObject.LoadSimulationJoints (simulationObjects);

				displayList = loadObject.GetOpenGLObjectList ();

				//Carico le texture
				textureID = loadObject.LoadTexture ();
				redTexture = OpenGLUtilities.LoadTexture ("red.bmp");

				//Set Collision Detection
				collisionEngineParameters = new CollisionEngineParameters();

				//Set Solver
				solverParameters = new SolverParameters();
				
				//Set Physics engine
				simulationParameters = new SimulationParameters();
				
				physicsEngine = new PhysicsEngine(
					simulationParameters,
					collisionEngineParameters,
					solverParameters);

				physicsEngine.SetSolver(SolverType.NonLinearConjugateGradient);

				for (int i = 0; i < simulationObjects.Count (); i++) 
				{
					physicsEngine.AddObject (simulationObjects [i]);
				}

				for (int i = 0; i < simulationJoints.Count (); i++) 
				{
					physicsEngine.AddJoint (simulationJoints [i]);
				}

				pause = true;

				//var obj = physicsEngine.GetJointsList();
//
//				obj.Add(null);

				#region Object Removing

				//physicsEngine.RemoveAllJoints();

				//physicsEngine.RemoveAllObjects();

				//int objectIndex = 2;

				//physicsEngine.RemoveObject(objectIndex);

				////Graphics engine
				//var buf = displayList.ToList();
				//buf.RemoveAt(objectIndex);
				//displayList = buf.ToArray();

				//var buf1 = textureID.ToList();
				//buf1.RemoveAt(objectIndex);
				//textureID = buf1.ToArray();

				#endregion


				collPoint = new List<CollisionPointStructure> ();
                collisionPartitionedPoints = new List<List<CollisionPointStructure>>();

			}
			catch (Exception e) 
			{
				throw new Exception (e.StackTrace);
			}
		}