Example #1
0
        //Devuelve un arreglo con las normales suavizadas (promedio de todas las del vertice) para cada vertice de posiciones (repetidas).
        public Vector3[] suavizarNormales()
        {
            Vector3[] ListaNormales = new Vector3[vertexList.Count];
            int       cantFaces     = faceList.Count;

            for (int f = 0; f < cantFaces; f++)
            {
                FVLFace    cara = faceList[f];
                List <int> nor  = cara.NormalIndexes;
                for (int n = 0; n < cara.VertexCount; n++)
                {
                    if (ListaNormales[cara.VertexIndexes[n]] == null)
                    {
                        ListaNormales[cara.VertexIndexes[n]] = Vector3.Normalize(vertexNormalList[cara.NormalIndexes[n]]);
                    }
                    else
                    {
                        ListaNormales[cara.VertexIndexes[n]] = Vector3.Normalize(ListaNormales[cara.VertexIndexes[n]] + vertexNormalList[cara.NormalIndexes[n]]);
                    }
                }
            }

            int[]          indicesPos = CarasToIndices();
            List <Vector3> ListaNormalesSuavizadas = new List <Vector3>();

            foreach (int i in indicesPos)
            {
                ListaNormalesSuavizadas.Add(ListaNormales[i]);
            }

            return(ListaNormalesSuavizadas.ToArray());
        }
Example #2
0
        //Devuelve un arreglo con las normales ordenadas para cada vertice de posiciones (repetidas).
        public Vector3[] ordenarTexturas()
        {
            List <Vector3> ListaTexturas = new List <Vector3>();
            int            cantFaces     = faceList.Count;

            for (int f = 0; f < cantFaces; f++)
            {
                FVLFace    cara   = faceList[f];
                List <int> texInd = cara.TexCordIndexes;
                for (int n = 0; n < cara.VertexCount; n++)
                {
                    ListaTexturas.Add(new Vector3(texCordList[texInd[n]].X, texCordList[texInd[n]].Y, 1.0f));
                }
            }
            return(ListaTexturas.ToArray());
        }
Example #3
0
        //Devuelve un arreglo con las normales ordenadas para cada vertice de posiciones (repetidas).
        public Vector3[] ordenarNormales()
        {
            List <Vector3> ListaNormales = new List <Vector3>();
            int            cantFaces     = faceList.Count;

            for (int f = 0; f < cantFaces; f++)
            {
                FVLFace    cara = faceList[f];
                List <int> nor  = cara.NormalIndexes;
                for (int n = 0; n < cara.VertexCount; n++)
                {
                    ListaNormales.Add(vertexNormalList[nor[n]]);
                }
            }
            return(ListaNormales.ToArray());
        }
Example #4
0
        /*
         *
         *      void OrdenarDatos(bool siText, bool siNormal, out Vector3[] posiciones, out Vector3[] coorTex, out Vector3[] normales, out int[] Indices)
         *      {
         *          int k = 0;
         *          int cantCaras = faceList.Count;
         *          Indices = new int[cantCaras * 3]; //OJO solo si  TODAS las caras son triƔgulos
         *          posiciones = new Vector3[cantCaras * 3];
         *          coorTex = new Vector3[cantCaras * 3];
         *          normales = new Vector3[cantCaras * 3];
         *
         *          for (int i = 0; i < cantCaras; i++)
         *          {
         *              FVLFace Cara = faceList[i];
         *              int[] indPosF = Cara.VertexIndexes.ToArray();
         *              int[] indTexF = Cara.TexCordIndexes.ToArray();
         *              int[] indNormF = Cara.NormalIndexes.ToArray();
         *
         *              for (int j = 0; j < 3; j++)
         *              {
         *                  posiciones[k] = VertexList[indPosF[j]];
         *
         *                  if (siText)
         *                      coorTex[k] = new Vector3(texCordList[indTexF[j]].X, texCordList[indTexF[j]].Y, 1.0f);
         *
         *                  if (siNormal)
         *                      normales[k] = VertexNormalList[indNormF[j]];
         *
         *                  Indices[k] = k;
         *                  k = k + 1;
         *              }
         *
         *          }
         *
         *      }
         */


        //Devuelve un arreglo con las posiciones ordenadas (repetidas) segun el indice.
        public Vector3[] ordenarPosiciones()
        {
            List <Vector3> ListaPosiciones = new List <Vector3>();
            int            cantFaces       = faceList.Count;

            for (int f = 0; f < cantFaces; f++)
            {
                FVLFace    cara = faceList[f];
                List <int> pos  = cara.VertexIndexes;
                for (int n = 0; n < cara.VertexCount; n++)
                {
                    ListaPosiciones.Add(vertexList[pos[n]]);
                }
            }
            return(ListaPosiciones.ToArray());
        }
Example #5
0
        //Devuelve un arreglo con los indices de VertexList ordenados segun el orden de las cara
        private int[] CarasToIndices()
        {
            int cantFaces = faceList.Count;

            int[] arrayIndices = new int[cantFaces * 3]; //OJO solo si  TODAS las caras son triƔgulos

            int i = 0;

            for (int f = 0; f < cantFaces; f++)
            {
                FVLFace cara            = faceList[f];
                int[]   indicesCara     = cara.IndicesDeCara();
                int     cuantosVertices = cara.VertexCount;
                for (int j = 0; j < cuantosVertices; j++)
                {
                    arrayIndices[i] = indicesCara[j];
                    i++;
                }
            }
            return(arrayIndices);
        }
Example #6
0
 public int AddFace(FVLFace face)
 {
     faceList.Add(face);
     return(faceList.Count - 1);
 }