bergman Posted September 27, 2018 Share Posted September 27, 2018 Hi all! I am currently exporting a 3ds Max-scene to gltf models, and then using these models in a web project of mine. For various reasons I both need to export each model in my scene separately, as well as export the entire scene as a single gltf (to keep some information about how different objects relate to each other in the scene in 3dsmax, among other things). The problem I'm having is that when my 3dsmax scene gets too big, the gltf export of the entire scene takes an unnecessary long amount of time to complete. Since each model in my scene is also exported separately and since the scene export is mostly used to contain information about object transforms and such, I do not really need the actual binary model data for the whole scene export (Since I already have each model gltf+bin when exporting them separately). Therefore, my question is: What would be the easiest way to export a 3ds max scene to gltf without exporting the actual binary data of the models? The desired result of my export would be only a minimal .gltf-file (No .bin-file, and no model data embedded in the gltf-file). I would be open to make a modified version of the https://github.com/BabylonJS/Exporters/tree/master/3ds Max repo to suit my needs, but I could use some direction to where the binary data is actually exported. Thanks! Best Regards, Anton Quote Link to comment Share on other sites More sharing options...
bghgary Posted September 27, 2018 Share Posted September 27, 2018 @kcoley Ping Quote Link to comment Share on other sites More sharing options...
kcoley Posted September 27, 2018 Share Posted September 27, 2018 Hi @bergman. The easiest way is to comment out the .bin generation code in GLTFExporter.cs when exporting to .gltf: // Output RaiseMessage("GLTFExporter | Saving to output file"); if (!generateBinary) { // Write .gltf file string outputGltfFile = Path.ChangeExtension(outputFile, "gltf"); File.WriteAllText(outputGltfFile, gltfToJson(gltf)); // Write .bin file -- comment out this section string outputBinaryFile = Path.ChangeExtension(outputFile, "bin"); using (BinaryWriter writer = new BinaryWriter(File.Open(outputBinaryFile, FileMode.Create))) { gltf.BuffersList.ForEach(buffer => { buffer.bytesList.ForEach(b => writer.Write(b)); }); } } We can look into making the exporter more robust by checking if the file on disk is already the same as generated in the code. Quote Link to comment Share on other sites More sharing options...
bergman Posted October 11, 2018 Author Share Posted October 11, 2018 @kcoley Hi again! I commented out the code as per your suggestion, and it worked wonders - no .bin file is created. However, my expectation was that this would also speed up my export process, but it still takes the same amount of time just that no .bin file is created. Would there be some way where I could do something similar in order to speed up the export, since I do not need all the actual mesh data and such? Best Regards, Anton Quote Link to comment Share on other sites More sharing options...
kcoley Posted October 11, 2018 Share Posted October 11, 2018 Hi @bergman Hmm, another thing you can try is not writing out textures in your code by commenting out references to SaveBitmap, which is located in BabylonExporter.Texture.cs: private void SaveBitmap(Bitmap bitmap, string path, ImageFormat imageFormat) { SaveBitmap(bitmap, Path.GetDirectoryName(path), Path.GetFileName(path), imageFormat); } This may help cut some time out if you have lots of textures. The other bottleneck is writing the binary data, though commenting out this code may cause offset issues in the generated json. Quote Link to comment Share on other sites More sharing options...
kcoley Posted October 11, 2018 Share Posted October 11, 2018 @bergman you can also look for all areas where Bitmap objects are generated. There are several other locations in GLTFExporter.Texture.cs such as in ExportEmissiveTexture that do somewhat expensive operations. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.