Exemplo n.º 1
0
        public Face(Vertex[] _vertices, OBJFile _myObject)
        {
            vertices = new List <Vertex>(_vertices);
            myObject = _myObject;

            if (_vertices.Length > 3)
            {
                triangles = new List <Face>();

                for (int i = 1; i < vertices.Count - 1; i++)
                {
                    Vertex[] triangleIndexes = new Vertex[3];

                    triangleIndexes[0] = vertices[0];
                    triangleIndexes[2] = vertices[i];
                    triangleIndexes[1] = vertices[i + 1];


                    triangles.Add(new Face(triangleIndexes, myObject));
                }
            }
        }
Exemplo n.º 2
0
        public Face(string[] indices, OBJFile _myObject)
        {
            vertexIndex   = new int[indices.Length];
            texCoordIndex = new int[indices.Length];
            normalIndex   = new int[indices.Length];

            myObject = _myObject;

            for (int i = 0; i < indices.Length; i++)
            {
                string[] subParts = indices[i].Split(new char[] { '/' });
                vertexIndex[i]   = int.Parse(subParts[0]) - 1;
                texCoordIndex[i] = int.Parse(subParts[0]) - 1;
                normalIndex[i]   = int.Parse(subParts[0]) - 1;
            }


            LoadVertexData(vertexIndex.Length);



            if (indices.Length > 3)
            {
                triangles = new List <Face>();

                for (int i = 1; i < vertices.Count - 1; i++)
                {
                    Vertex[] triangleIndexes = new Vertex[3];

                    triangleIndexes[0] = vertices[0];
                    triangleIndexes[2] = vertices[i];
                    triangleIndexes[1] = vertices[i + 1];

                    triangles.Add(new Face(triangleIndexes, myObject));
                }
            }
        }