private string printTriangles(Triangle[] triangles, bool hasUvSets)
        {
            string export = "";

            string format = "f {0}/{0}/{0} {1}/{1}/{1} {2}/{2}/{2}";
            if (!hasUvSets)
            {
                format = "f {0}//{0} {1}//{1} {2}//{2}";
            }

            int max = m_triangleCounter;
            foreach (Triangle face in triangles)
            {
                export += string.Format(format, face.X + m_triangleCounter, face.Y + m_triangleCounter, face.Z + m_triangleCounter) + Environment.NewLine;
                if (face.X + m_triangleCounter > max) max = face.X + m_triangleCounter;
                if (face.Y + m_triangleCounter > max) max = face.Y + m_triangleCounter;
                if (face.Z + m_triangleCounter > max) max = face.Z + m_triangleCounter;
            }
            m_triangleCounter = max + 1;

            /*
            foreach (Triangle face in triangles)
            {
                export += string.Format(format, face.X, face.Y, face.Z) + Environment.NewLine;
            }
             * */

            return export;
        }
Beispiel #2
0
        private void computePolys(Triangle[] trianlges, Vector3[] vertices, Matrix transformation)
        {
            // Transaform all vertices
            List<Vector3> verticesTransformed = new List<Vector3>();
            foreach (Vector3 vector in vertices) verticesTransformed.Add(Vector3.TransformCoordinate(vector, transformation));

            foreach (Triangle triangle in trianlges)
            {
                Polygon poly = new Polygon(
                    new Vector3(verticesTransformed[triangle.X].X, verticesTransformed[triangle.X].Y, verticesTransformed[triangle.X].Z),
                    new Vector3(verticesTransformed[triangle.Y].X, verticesTransformed[triangle.Y].Y, verticesTransformed[triangle.Y].Z),
                    new Vector3(verticesTransformed[triangle.Z].X, verticesTransformed[triangle.Z].Y, verticesTransformed[triangle.Z].Z)
                );
                m_polys.Add(poly);
            }
        }