Exemplo n.º 1
0
        private static void WriteSurfaces(ObjFile obj, StreamWriter stream, ObjFileWriterContext context)
        {
            foreach (ObjSurface surface in obj.Surfaces)
            {
                context.WriteGroupNames(stream, surface, g => g.Surfaces);
                context.WriteAttributesOfElement(stream, surface);
                context.WriteAttributesOfFreeFormElement(stream, surface);

                stream.Write("surf {0} {1} {2} {3}",
                             surface.StartParameterU.ToString("F6", CultureInfo.InvariantCulture),
                             surface.EndParameterU.ToString("F6", CultureInfo.InvariantCulture),
                             surface.StartParameterV.ToString("F6", CultureInfo.InvariantCulture),
                             surface.EndParameterV.ToString("F6", CultureInfo.InvariantCulture));

                foreach (ObjTriplet vertex in surface.Vertices)
                {
                    stream.Write(' ');
                    stream.Write(vertex);
                }

                stream.WriteLine();

                WriteBodyOfFreeFormElement(stream, surface);
            }
        }
Exemplo n.º 2
0
        public static void Write(ObjFile obj, StreamWriter stream)
        {
            var context = new ObjFileWriterContext(obj);

            WriteShadowObjectFileName(obj, stream);
            WriteTraceObjectFileName(obj, stream);

            WriteMapLibraries(obj, stream);
            WriteMaterialLibraries(obj, stream);

            WriteVertices(obj, stream);
            WriteParameterSpaceVertices(obj, stream);
            WriteVertexNormals(obj, stream);
            WriteTextureVertices(obj, stream);

            WritePoints(obj, stream, context);
            WriteLines(obj, stream, context);
            WriteFaces(obj, stream, context);

            WriteCurves(obj, stream, context);
            WriteCurves2D(obj, stream, context);
            WriteSurfaces(obj, stream, context);

            WriteSurfaceConnection(obj, stream);
        }
Exemplo n.º 3
0
        private static void WriteFaces(ObjFile obj, StreamWriter stream, ObjFileWriterContext context)
        {
            foreach (ObjFace face in obj.Faces)
            {
                context.WriteGroupNames(stream, face, g => g.Faces);
                context.WriteAttributesOfElement(stream, face);
                context.WriteAttributesOfPolygonalElement(stream, face);

                stream.Write("f");

                foreach (ObjTriplet vertex in face.Vertices)
                {
                    stream.Write(" {0}", vertex);
                }

                stream.WriteLine();
            }
        }
Exemplo n.º 4
0
        private static void WritePoints(ObjFile obj, StreamWriter stream, ObjFileWriterContext context)
        {
            foreach (ObjPoint point in obj.Points)
            {
                context.WriteGroupNames(stream, point, g => g.Points);
                context.WriteAttributesOfElement(stream, point);
                context.WriteAttributesOfPolygonalElement(stream, point);

                stream.Write("p");

                foreach (ObjTriplet vertex in point.Vertices)
                {
                    stream.Write(" {0}", vertex);
                }

                stream.WriteLine();
            }
        }
Exemplo n.º 5
0
        private static void WriteCurves2D(ObjFile obj, StreamWriter stream, ObjFileWriterContext context)
        {
            foreach (ObjCurve2D curve in obj.Curves2D)
            {
                context.WriteGroupNames(stream, curve, g => g.Curves2D);
                context.WriteAttributesOfElement(stream, curve);
                context.WriteAttributesOfFreeFormElement(stream, curve);

                stream.Write("curv2");

                foreach (int vertex in curve.ParameterSpaceVertices)
                {
                    stream.Write(' ');
                    stream.Write(vertex);
                }

                stream.WriteLine();

                WriteBodyOfFreeFormElement(stream, curve);
            }
        }
Exemplo n.º 6
0
        private static void WriteCurves(ObjFile obj, StreamWriter stream, ObjFileWriterContext context)
        {
            foreach (ObjCurve curve in obj.Curves)
            {
                context.WriteGroupNames(stream, curve, g => g.Curves);
                context.WriteAttributesOfElement(stream, curve);
                context.WriteAttributesOfFreeFormElement(stream, curve);

                stream.Write("curv {0} {1}",
                             curve.StartParameter.ToString("F6", CultureInfo.InvariantCulture),
                             curve.EndParameter.ToString("F6", CultureInfo.InvariantCulture));

                foreach (int vertex in curve.Vertices)
                {
                    stream.Write(' ');
                    stream.Write(vertex);
                }

                stream.WriteLine();

                WriteBodyOfFreeFormElement(stream, curve);
            }
        }