private static void WriteOutputFile(string outputFile, Pr3Model model) { var s = new StreamWriter(outputFile); var bs = new BrotliStream(s.BaseStream, CompressionMode.Compress); using (var f = new BinaryWriter(bs)) { const string magic = "PR3"; const int version = 1; var ident = magic.ToCharArray(); f.Write(ident); f.Write(version); f.Write(model.Objects.Count); foreach (var pr3Object in model.Objects) { f.WriteNtString(pr3Object.Name); f.WriteNtString(pr3Object.MaterialName); WriteMatrix4(f, pr3Object.TransformationMatrix); WriteLengthCodedVectors(f, pr3Object.Vertices); WriteLengthCodedVectors(f, pr3Object.Normals); WriteLengthCodedVectors(f, pr3Object.Uvs); } } }
static int Main(string[] args) { if (args.Length < 2) { return(-1); } var collada = XElement.Parse(File.ReadAllText(args[0])); var scene = new GeometryLoader(collada).Load(); var outputFile = args[1]; if (scene == null) { return(-2); } var model = Pr3Model.FromCollada(scene); WriteOutputFile(outputFile, model); return(0); }