// Converts .json file from parsing arguments into... // TODO: Refactor to remove references to fbx files as they are no // longer a part of the Luminaire workflow. private static void ConvertFile(string gfxbin, string gpubin) { DefaultPrintFunction.SetDefaultPrintFunction(Console.WriteLine); var readData = File.ReadAllBytes(gfxbin); var gpubinReadData = File.ReadAllBytes(gpubin); // TODO don't hardcode var dependencies = new Dictionary <string, byte[]> { { /* "data://character/nh/nh00/model_010/nh00_010.gpubin"*/ gpubin, gpubinReadData } }; var unpackContext = new LmGfxBinUnpackContext { // Shorthand initialization for auto-implemented properties GpuBuffer = gpubinReadData // TODO don't hardcode }; var msgPck = new LmMsgPck(readData, unpackContext); var gmtlLoader = new LmGfxBinMaterialAssetLoader(); var gmdlLoader = new LmGfxBinAssetLoader(); // After tracing this dependencies variable as its passed through // various functions, it seems that the dictionary isn't actually // used anywhere. The reference in the deepest level of function // calls the place where this variable is used is commented out. gmdlLoader.BuildDependencyTable(unpackContext, msgPck, dependencies); var modelResourceNode = LmGfxBinAssetLoader.Convert(msgPck); var fbx = gpubin.Replace(gpubinExtension, fbxExtension); GmdlUnityAssetConverter.Convert(modelResourceNode, gfxbin, ""); }
// This function takes a gmtl file name as input and converts to // contents of that file to json format. It then writes that json // to a file in the same directory as the input file. The output // file will have the same name as the input file but with the // .json extension. private static void ConvertMaterial(string gfxbin) { DefaultPrintFunction.SetDefaultPrintFunction(Console.WriteLine); // Reads contents of gfxbin file (which is binary) into a // bytearray. This implies that readData is a byte[]. var readData = File.ReadAllBytes(gfxbin); var unpackContext = new LmGfxBinUnpackContext(); var msgPck = new LmMsgPck(readData, unpackContext); // Loads the unpacked message data into a MaterialGmtl. var gmtlLoader = new LmGfxBinMaterialAssetLoader(); var gmtl = gmtlLoader.Initialize(unpackContext, msgPck, null); // Make a string for the file path of the input file, but with // a .json file extension. The output file should be stored in // the same directory as the input file. var jsonPath = gfxbin.Replace(gmtlExtension, "json"); JsonConvert.Convert(gmtl, jsonPath); }