public bool loadZone(int index){
			Zone zone;
			bool Ended = false;
			bool founded = false;
			if (!scene.zones.TryGetValue(index, out zone)){
				//Console.Write("loading zone" + index + "\n");
				string line;
				bool first = true;
				int cmptObjets = 0;
				System.IO.StreamReader file = new System.IO.StreamReader(filePath);
				while((line = file.ReadLine()) != null && !Ended)
				{
					if(line.StartsWith("z") && line.Contains(Convert.ToString(index))){
						founded = true;
						string[] zoneParams = line.Split(' ');
						zone = new Zone(zoneParams[2] + index, index);
						Objet3D o = new Objet3D();
						line = file.ReadLine();
						while(!Ended)
						{
							if(line == null)
								Ended = true;
							else {
								if (line.StartsWith("o") || line.StartsWith("g")) {
									if(line.Length > 1){
										if (!first) {
											cmptObjets++;
											zone.addObjet(cmptObjets, o);
										}
										
										o = new Objet3D(); 
										first = false;
									}
								}
								
								if (line.StartsWith("m")) {
									string[] mParams = line.Split(' ');
									readMaterial(mtlPath, mParams[1]);
									o.material = mParams[1];
								}
				
								if (line.StartsWith("v")) {
									
									char[] delimiterChars = {' '};
									string[] positions = line.Split (delimiterChars);
									Vector4 v = new Vector4 (float.Parse (positions [2]), float.Parse (positions [3]), float.Parse (positions [4]), 1.0f);
									
									if(line.StartsWith ("vn"))
										scene.addNormal(int.Parse(positions[1]),v);
				
									else if(line.StartsWith ("vt"))
										scene.addTexture(int.Parse (positions[1]),v);
									
									else
										scene.addVertex(int.Parse (positions[1]),v);
		
								}
				
								if ('f'.Equals(line[0])) {
									// Je sépare la ligne en fonction des espaces
									char[] delimiterChars = {' '};
									string[] vertex = line.Split (delimiterChars);
									string[] vertexValues = vertex[1].Split('/');
									FACE f1 = new FACE();
									f1.vertex = new int[vertex.Length-1];
									if(vertexValues.Length > 2) {
										if(!vertexValues[1].Equals(""))
											f1.texture = new int[vertex.Length-1];
										if (!vertexValues[2].Equals(""))
											f1.normals = new int[vertex.Length-1];
									}
									for(int i=1; i<vertex.Length; i++)
									{
										vertexValues = vertex[i].Split('/');
										f1.vertex[i-1] = (int.Parse(vertexValues[0]));

										if(vertexValues.Length > 2) {
											if(!vertexValues[1].Equals("")){
												f1.texture[i-1] = (int.Parse(vertexValues[1]));
											}
											if(!vertexValues[2].Equals("")){
												f1.normals[i-1] = (int.Parse(vertexValues[2]));
											}
										}
									}
									o.addFace(f1);
								}
								
								if(line.StartsWith("z"))
									Ended = true;

								line = file.ReadLine();
							}
							
						}
						Ended = true;
						zone.addObjet(cmptObjets,o);
					}
				}
				if(!founded)
				{
					zone = new Zone("zone"+index,index);
				}
				lock (scene.access)
						scene.addZone(index, ref zone);
			}
			return Ended;
		}
		public void addZone(int cle, ref Zone z)
		{
			if (!zones.ContainsKey(cle))
				zones.Add(cle, z);
		}
		public static void parseObj(string path, string pathMtl, Scene3D s)
		{
			int cmptVertex = 0;
			int cmptObjets = 0;
			string line;
			bool first = true;
			Zone z = new Zone("huge",0);
			Objet3D o = new Objet3D (); 
			System.IO.StreamReader file = new System.IO.StreamReader(path);
			while ((line = file.ReadLine()) != null) {
				if (!line.Equals ("")) {
					if('u'.Equals(line[0]))
					{
						if (line.Contains("usemtl"))
						{
							char[] delimiterChars = {' '};
							string[] positions = line.Split (delimiterChars);
							//o.material = positions[1];
							//readMaterial(pathMtl,positions[1], s);
						}
					}
					// On regarde si on a un nouvel objet
					if ('o'.Equals(line[0]) || 'g'.Equals(line [0])) {
						if(line.Length > 1){
							if (!first) {
								o.Center /= o.VertexCount;
								cmptObjets++;
								z.addObjet(cmptObjets, o);
							}
			
							o = new Objet3D(); 

							first = false;
						}
					}
			
					if ('v'.Equals(line[0])) {
						if('n'.Equals(line[1]))
						{
							// Je sépare la ligne en fonction des espaces
							char[] delimiterChars = {' '};
							string[] positions = line.Split (delimiterChars);
							//Console.WriteLine ("\t" + line);		
							// Je suis obligé de changer les . par des , sinon il n'arrive pas à parser
							Vector4 v = new Vector4 (float.Parse (positions [1]), float.Parse (positions [2]), float.Parse (positions [3]), 1.0f);
							s.addNormal(s.vertexNormals.Count,v);
						}

						else if('t'.Equals(line[1]))
						{
							// Je sépare la ligne en fonction des espaces
							char[] delimiterChars = {' '};
							string[] positions = line.Split (delimiterChars);
							Vector4 v;
							if(positions.Length == 3)
								v = new Vector4 (float.Parse (positions [1]), float.Parse (positions [2]), 0.0f, 1.0f);
							else
								v = new Vector4 (float.Parse (positions [1]), float.Parse (positions [2]), float.Parse (positions [3]), 1.0f);

							s.addTexture(s.textureCoords.Count,v);
						}

						else
						{
							// Je sépare la ligne en fonction des espaces
							char[] delimiterChars = {' '};
							string[] positions = line.Split (delimiterChars);
							//Console.WriteLine ("\t" + line);		
							// Je suis obligé de changer les . par des , sinon il n'arrive pas à parser
							Vector4 v = new Vector4 (float.Parse(positions[1]), float.Parse (positions[2]), float.Parse (positions[3]), 1.0f);
							Vector4 v3 = new Vector4(v.X,v.Y,v.Z, 1);
							tabMinMaxXZScene(v3, s);
							tabMinMaxXZObject(v3, o);
							o.Center += v3;
							o.VertexCount++;
							cmptVertex++;
							s.addVertex(s.vertex.Count, v);
						}
					}

					if ('f'.Equals(line[0])) {
						// Je sépare la ligne en fonction des espaces
						char[] delimiterChars = {' '};
						string[] vertex = line.Split (delimiterChars);
						string[] vertexValues = vertex[1].Split('/');
						FACE f1 = new FACE();
						f1.vertex = new int[vertex.Length-1];
						if(vertexValues.Length > 2) {
							if(!vertexValues[1].Equals(""))
								f1.texture = new int[vertex.Length-1];
							if (!vertexValues[2].Equals(""))
								f1.normals = new int[vertex.Length-1];
						}
						for(int i=1; i<vertex.Length; i++)
						{
							vertexValues = vertex[i].Split('/');
							f1.vertex[i-1] = (int.Parse(vertexValues[0])) -1;
							f1.center += new Vector3(s.vertex[f1.vertex[i-1]]);
							if(vertexValues.Length > 2) {
								if(!vertexValues[1].Equals("")){
									f1.texture[i-1] = (int.Parse(vertexValues[1])) -1;
								}
								if(!vertexValues[2].Equals("")){
									f1.normals[i-1] = (int.Parse(vertexValues[2])) -1;
								}
							}

						}
						f1.center /= vertex.Length-1;
						o.addFace(f1);
					}
				}
			}
			cmptObjets++;
			z.addObjet(cmptObjets, o);
			s.addZone(s.zones.Count, ref z);
			s.SetTaille();
			s._nbrVertex = cmptVertex;
		}
		public void ZoneScene (int taille)
		{
			Scene3D finalScene = new Scene3D();
			foreach (Objet3D o in this.zones[0].GetObjets.Values) 
			{
				Zone z;
				int cle;
				foreach (FACE f in o.GetFace)
				{
					cle = CalculZone(f.center, taille);
					if(!(finalScene.zones.TryGetValue(cle, out z)))
					{
						z = new Zone("Zone " + cle, cle);
						finalScene.addZone(cle, ref z);
					}
					 
					
					if (finalScene.zones[cle].GetObjets.Values.Count == 0)
					{
						Objet3D newO = new Objet3D();
						newO.material = o.material;
						newO.addFace(f);
						finalScene.zones[cle].addObjet(cmptObjets, newO);
						cmptObjets++;
					}
					else
					{
						Objet3D newO = new Objet3D();
						Boolean newObjet = false;
						foreach (Objet3D underO in finalScene.zones[cle].GetObjets.Values)
						{
							//underO.addFace(f);
							if (o.material == null)
								underO.addFace(f);
							else
							{
								if (underO.material == o.material)
								{
									underO.addFace(f);
								}
								else
								{
									newObjet = true;
									newO.material = o.material;
									newO.addFace(f);
									cmptObjets++;
								}
							}
						}

						if (newObjet)
						{
							finalScene.zones[cle].addObjet(cmptObjets, newO);
						}
					}
					for (int i = 0; i < 3; i++)
					{
						finalScene.zones[cle].addVertex(f.vertex[i], this.vertex[f.vertex[i]]);
						if(f.normals != null)
							finalScene.zones[cle].addNormal(f.normals[i], this.vertexNormals[f.normals[i]]);
						//finalScene.addTexture(f.texture[i], this.textureCoords[f.texture[i]]);
					}
				}
				/*cle = CalculZone(o.Center, taille);
				finalScene.addZone(cle, new Zone("Zone " + cle));
				finalScene.zones[cle].addObjet(cmpt, o);
				cmpt++;*/
			}
			this.zones = finalScene.zones;			
		}
        public static void parseObj(string path, string pathMtl, Scene3D s)
        {
            int     cmptVertex = 0;
            int     cmptObjets = 0;
            string  line;
            bool    first = true;
            Zone    z     = new Zone("huge", 0);
            Objet3D o     = new Objet3D();

            System.IO.StreamReader file = new System.IO.StreamReader(path);
            while ((line = file.ReadLine()) != null)
            {
                if (!line.Equals(""))
                {
                    if ('u'.Equals(line[0]))
                    {
                        if (line.Contains("usemtl"))
                        {
                            char[]   delimiterChars = { ' ' };
                            string[] positions      = line.Split(delimiterChars);
                            //o.material = positions[1];
                            //readMaterial(pathMtl,positions[1], s);
                        }
                    }
                    // On regarde si on a un nouvel objet
                    if ('o'.Equals(line[0]) || 'g'.Equals(line [0]))
                    {
                        if (line.Length > 1)
                        {
                            if (!first)
                            {
                                o.Center /= o.VertexCount;
                                cmptObjets++;
                                z.addObjet(cmptObjets, o);
                            }

                            o = new Objet3D();

                            first = false;
                        }
                    }

                    if ('v'.Equals(line[0]))
                    {
                        if ('n'.Equals(line[1]))
                        {
                            // Je sépare la ligne en fonction des espaces
                            char[]   delimiterChars = { ' ' };
                            string[] positions      = line.Split(delimiterChars);
                            //Console.WriteLine ("\t" + line);
                            // Je suis obligé de changer les . par des , sinon il n'arrive pas à parser
                            Vector4 v = new Vector4(float.Parse(positions [1]), float.Parse(positions [2]), float.Parse(positions [3]), 1.0f);
                            s.addNormal(s.vertexNormals.Count, v);
                        }

                        else if ('t'.Equals(line[1]))
                        {
                            // Je sépare la ligne en fonction des espaces
                            char[]   delimiterChars = { ' ' };
                            string[] positions      = line.Split(delimiterChars);
                            Vector4  v;
                            if (positions.Length == 3)
                            {
                                v = new Vector4(float.Parse(positions [1]), float.Parse(positions [2]), 0.0f, 1.0f);
                            }
                            else
                            {
                                v = new Vector4(float.Parse(positions [1]), float.Parse(positions [2]), float.Parse(positions [3]), 1.0f);
                            }

                            s.addTexture(s.textureCoords.Count, v);
                        }

                        else
                        {
                            // Je sépare la ligne en fonction des espaces
                            char[]   delimiterChars = { ' ' };
                            string[] positions      = line.Split(delimiterChars);
                            //Console.WriteLine ("\t" + line);
                            // Je suis obligé de changer les . par des , sinon il n'arrive pas à parser
                            Vector4 v  = new Vector4(float.Parse(positions[1]), float.Parse(positions[2]), float.Parse(positions[3]), 1.0f);
                            Vector4 v3 = new Vector4(v.X, v.Y, v.Z, 1);
                            tabMinMaxXZScene(v3, s);
                            tabMinMaxXZObject(v3, o);
                            o.Center += v3;
                            o.VertexCount++;
                            cmptVertex++;
                            s.addVertex(s.vertex.Count, v);
                        }
                    }

                    if ('f'.Equals(line[0]))
                    {
                        // Je sépare la ligne en fonction des espaces
                        char[]   delimiterChars = { ' ' };
                        string[] vertex         = line.Split(delimiterChars);
                        string[] vertexValues   = vertex[1].Split('/');
                        FACE     f1             = new FACE();
                        f1.vertex = new int[vertex.Length - 1];
                        if (vertexValues.Length > 2)
                        {
                            if (!vertexValues[1].Equals(""))
                            {
                                f1.texture = new int[vertex.Length - 1];
                            }
                            if (!vertexValues[2].Equals(""))
                            {
                                f1.normals = new int[vertex.Length - 1];
                            }
                        }
                        for (int i = 1; i < vertex.Length; i++)
                        {
                            vertexValues     = vertex[i].Split('/');
                            f1.vertex[i - 1] = (int.Parse(vertexValues[0])) - 1;
                            f1.center       += new Vector3(s.vertex[f1.vertex[i - 1]]);
                            if (vertexValues.Length > 2)
                            {
                                if (!vertexValues[1].Equals(""))
                                {
                                    f1.texture[i - 1] = (int.Parse(vertexValues[1])) - 1;
                                }
                                if (!vertexValues[2].Equals(""))
                                {
                                    f1.normals[i - 1] = (int.Parse(vertexValues[2])) - 1;
                                }
                            }
                        }
                        f1.center /= vertex.Length - 1;
                        o.addFace(f1);
                    }
                }
            }
            cmptObjets++;
            z.addObjet(cmptObjets, o);
            s.addZone(s.zones.Count, ref z);
            s.SetTaille();
            s._nbrVertex = cmptVertex;
        }