Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
1.0 kB
15
Indexable
Never
string fileName = args[0];
                SmdMesh model = new SmdMesh(File.OpenRead(fileName));

                Stream output = File.Create(Path.GetFileNameWithoutExtension(fileName) + ".msh");
                BinaryWriter writer = new BinaryWriter(output);

                writer.Write((ushort)Version);
                writer.Write((ushort)(model.Triangles.Count * 3));

                foreach(SmdTriangle tri in model.Triangles)
                {
                    for(int i = 0; i < 3; i++)
                    {
                        writer.Write(tri.Verts[i].Position.X * 0.1f);
                        writer.Write(tri.Verts[i].Position.Y * 0.1f);
                        writer.Write(tri.Verts[i].Position.Z * 0.1f);

                        writer.Write(tri.Verts[i].UV.X);
                        writer.Write(tri.Verts[i].UV.Y);
                    }
                }

                Console.WriteLine("Total {0} vertices", model.Triangles.Count * 3);

                output.Close();
Leave a Comment