public NonLinearConjugateGradient(
            SolverParameters solverParameters)
        {
            solverParam = solverParameters;

			var gaussSeidelSolverParam = new SolverParameters (
				                                          3,
				                                          solverParam.ErrorTolerance,
				                                          1.0,
				                                          solverParam.MaxThreadNumber,
				                                          solverParam.SORStep,
                                                          false);
			
			gaussSeidelSolver = new ProjectedGaussSeidel(gaussSeidelSolverParam);
        }
		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 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 void SetSolverParameters(SolverParameters solverParameters)
		{
			this.solverParameters = solverParameters;
		}
		public LCPSolver (
			SolverParameters solverParameters)
		{
			this.solverParameters = solverParameters;
		}
 public ConjugateGradient(SolverParameters solverParameters)
 {
     SolverParameters = solverParameters;
 }
		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);
			}
		}
        public ProjectedGaussSeidel(
			SolverParameters solverParameters)
        {
			SolverParameters = solverParameters;
        }