[SOLVED] BinaryExporter


#1
public class ModelConverter {
    private final AssetManager assetManager;

    public ModelConverter(final AssetManager assetManager) {
        this.assetManager = assetManager;
    }

    public void convert(final File inputFile, final File outputFile, final boolean generateTangents) {
        final String parentPath = inputFile.getParent();
        assetManager.registerLocator(parentPath, FileLocator.class);

        try {
            final Spatial modelToImport = assetManager.loadModel(inputFile.getName());

            if (modelToImport != null) {
                if (generateTangents) {
                    TangentBinormalGenerator.generate(modelToImport);
                }

                final BinaryExporter binaryExporter = new BinaryExporter();

                if (outputFile.getParentFile().exists() || outputFile.getParentFile().mkdirs()) {
                    try {
                        binaryExporter.save(modelToImport, outputFile);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }  finally {
            assetManager.unregisterLocator(parentPath, FileLocator.class);
        }
    }

}

Got this off the forums awhile back and was working fine. Haven’t used it in awhile but now when I try to convert ogre models its butchering them.

Its no different really than the one in Tests. Is there something about ogre files that needs to be done different?

How about for blends?

Edit: Writing it out as a .j3o and importing it back in with assetManager,

        Spatial loadModel = this.assetManager.loadModel("Models/Oto.mesh.j3o");
        rootNode.attachChild(loadModel);

#2

Are you on jme 3.3 ? Is the model rigged ?
If so, then this might help


#3

yes and yes.

Very nice. Thank you.