示例#1
0
        public void WriteToOBJ(TextWriter writer, int lodNumber, int firstVertexNumber, int firstNormalNumber, int firstCoordNumber,
                               Dictionary <string, int?> materialNames, Stream unknownData)
        {
            unknownData.Write(unknown);
            unknownData.WriteByte(unknown2);
            unknownData.WriteByte(unknown3);

            double scaleFactor = ConvertScale(Scale);

            writer.WriteLine($"g lod{lodNumber}/scale={scaleFactor}");

            writer.WriteLine("# vertices");
            Vertices.ForEach(vertex => vertex.WriteToOBJ(writer, scaleFactor));

            writer.WriteLine("# normals");
            Normals.ForEach(normal => normal.WriteToOBJ(writer));

            List <UVCoordinate> coords = GetAllUVCoords();

            writer.WriteLine("# UV coords");
            coords.ForEach(coord => coord.WriteToOBJ(writer));

            writer.WriteLine("# triangles");
            Triangles.ForEach(polygon => polygon.WriteToOBJ(writer, false, Vertices, Normals, firstVertexNumber, firstNormalNumber, materialNames));

            writer.WriteLine("# quads");
            Quads.ForEach(polygon => polygon.WriteToOBJ(writer, true, Vertices, Normals, firstVertexNumber, firstNormalNumber, materialNames));

            writer.WriteLine("# UV triangles");
            UVTriangles.ForEach(polygon => polygon.WriteToOBJ(writer, false, Vertices, Normals, firstVertexNumber, firstNormalNumber, coords, firstCoordNumber, materialNames));

            writer.WriteLine("# UV quads");
            UVQuads.ForEach(polygon => polygon.WriteToOBJ(writer, true, Vertices, Normals, firstVertexNumber, firstNormalNumber, coords, firstCoordNumber, materialNames));
        }
示例#2
0
 public void Serialize(BinaryWriter writer)
 {
     Header.Serialize(writer);
     Vertices.ForEach(vertex => vertex.Serialize(writer));
     Normals.ForEach(normal => normal.Serialize(writer));
     Faces.ForEach(face => face.Serialize(writer));
     SubObjects.ForEach(subObject => subObject.Serialize(writer));
     PartAnimations?.ForEach(partAnimation => partAnimation.Serialize(writer));
     CollisionPlaneVectors.ForEach(plane => plane.Serialize(writer));
     CollisionVolumes.ForEach(volume => volume.Serialize(writer));
     Materials.ForEach(material => material.Serialize(writer));
 }
示例#3
0
        private int CalculateLength()
        {
            using (MemoryStream buffer = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(buffer))
                {
                    Vertices.ForEach(vertex => vertex.Serialize(writer));
                    Normals.ForEach(normal => normal.Serialize(writer));
                    Faces.ForEach(face => face.Serialize(writer));
                    SubObjects.ForEach(subObject => subObject.Serialize(writer));
                    CollisionPlaneVectors.ForEach(collisionPlane => collisionPlane.Serialize(writer));
                    CollisionVolumes.ForEach(collisionVolume => collisionVolume.Serialize(writer));
                    Materials.ForEach(material => material.Serialize(writer));

                    return((int)buffer.Length);
                }
        }