Jump to content

3dsmax gltf export without .bin?


bergman
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

@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

Link to comment
Share on other sites

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.  

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...