private static void WriteModelFile(string outputFile, Pr3Model model) { using var f = new BinaryWriter(File.Open(outputFile, FileMode.Create)); const string magic = "PR3"; const int version = 2; 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); WriteLengthCodedFaces(f, pr3Object.Faces); } }
private static void WriteRiggingFile(string outputFile, Pr3Model model) { using var f = new BinaryWriter(File.Open(outputFile, FileMode.Create)); const string magic = "PR3R"; 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); WriteMatrix4(f, pr3Object.TransformationMatrix); } }
static int Main(string[] args) { if (args.Length < 3) { return(-1); } var collada = XElement.Parse(File.ReadAllText(args[0])); var scene = new GeometryLoader(collada).Load(); if (scene == null) { return(-2); } var model = Pr3Model.FromCollada(scene); WriteModelFile(args[1], model); WriteRiggingFile(args[2], model); return(0); }