public void Actualizar(ref Poliedro[] Poliedros, ref Camara3D Camara) { List<ElementoZBuffer> Objetos = new List<ElementoZBuffer>(); List<Poligono2D> Representaciones = new List<Poligono2D>(); System.DateTime T = DateAndTime.Now; int n = 0; if ((Poliedros != null)) { if (!Vacio) { for (int i = 0; i <= mObjetos.GetUpperBound(0); i++) { if (mObjetos[i].Indices[1] <= Poliedros.GetUpperBound(0) && mObjetos[i].Indices[2] < Poliedros[mObjetos[i].Indices[1]].NumeroCaras) { if (Poliedros[mObjetos[i].Indices[1]].CaraVisible[mObjetos[i].Indices[2], Camara]) { Objetos.Add(new ElementoZBuffer(Poliedros[mObjetos[i].Indices[1]].Caras[mObjetos[i].Indices[2]].BaricentroSRC.Z, n, mObjetos[i].Indices[1], mObjetos[i].Indices[2])); Representaciones.Add(new Poligono2D(Poliedros[mObjetos[i].Indices[1]].Caras[mObjetos[i].Indices[2]].Representacion[Poliedros[mObjetos[i].Indices[1]].Vertices])); Representaciones[Representaciones.Count - 1].Color = Poliedros[mObjetos[i].Indices[1]].Caras[mObjetos[i].Indices[2]].Color; Poliedros[mObjetos[i].Indices[1]].Caras[mObjetos[i].Indices[2]].CargadaEnBuffer = true; n += 1; } else { Poliedros[mObjetos[i].Indices[1]].Caras[mObjetos[i].Indices[2]].CargadaEnBuffer = false; } } } } for (int i = 0; i <= Poliedros.GetUpperBound(0); i++) { for (int j = 0; j <= Poliedros[i].NumeroCaras - 1; j++) { if (!Poliedros[i].Caras[j].CargadaEnBuffer) { if (Poliedros[i].CaraVisible[j, Camara]) { Objetos.Add(new ElementoZBuffer(Poliedros[i].Caras[j].BaricentroSRC.Z, n, i, j)); Representaciones.Add(Poliedros[i].Representacion[j]); Poliedros[i].Caras[j].CargadaEnBuffer = true; n += 1; } } } } mObjetos = Objetos.ToArray(); mRepresentaciones = Representaciones.ToArray(); Reordenar(); } else { mObjetos = null; mRepresentaciones = null; } mTiempo = (DateAndTime.Now - T).TotalMilliseconds; if (Modificado != null) { Modificado(this); } }
public void QuitarPoliedro(ref Poliedro Poliedro) { if ((mPoliedros != null) && mPoliedros.Contains(Poliedro)) { if (mPoliedros.GetUpperBound(0) > 0) { Poliedro[] Copia = new Poliedro[mPoliedros.GetUpperBound(0) + 1]; mPoliedros.CopyTo(Copia, 0); mPoliedros = new Poliedro[mPoliedros.GetUpperBound(0)]; for (int i = 0; i <= Copia.GetUpperBound(0); i++) { if (Copia[i] != Poliedro) { if (i <= mPoliedros.GetUpperBound(0)) { mPoliedros[i] = Copia[i]; } else { mPoliedros[i - 1] = Copia[i]; } } } Poliedro.Modificado -= PoliedroModificado; } else { mPoliedros = null; } Buffer.Actualizar(ref mPoliedros, ref mCamaraSeleccionada); if (Modificado != null) { Modificado(this); } } }