I realise the importer is clunky and this is a bad idea, however in my case this is necessary.
The project is a simulator and the users will be providing blend files. When they want to import a new environment (which is usually rare) they want to be able to do so directly within the application. What I need to do is in effect clone what the import model does, saving them as a j3o then restarting the simulation code.
The blend file in question imports absolutely fine if “Import Model” in the SDK is used, however if I use loadModel things start to go wrong. loc is the string for the path of the directory both blend files are in. The code is shown below.
[java]
public void newModel(String loc) {
appSettings.setModelLocation(“Models/ImportedModel/”);
Spatial navMod = assetManager.loadModel(loc + “/NavModel.blend”);
Spatial showMod = assetManager.loadModel(loc + “/ShowModel.blend”);
BinaryExporter exporter = BinaryExporter.getInstance();
File navModel = new File(“assets/Models/NavModel.j3o”);
try {
exporter.save(navMod, navModel);
} catch (IOException ex) {
Logger.getLogger(Settings.class.getName()).log(Level.SEVERE, “Error: Failed to save NavMesh!”, ex);
}
File file2 = new File(“assets/Models/ShowModel.j3o”);
try {
exporter.save(showMod, file2);
} catch (IOException ex) {
Logger.getLogger(Settings.class.getName()).log(Level.SEVERE, “Error: Failed to save NavMeshCoords!”, ex);
}
}
[/java]
The error i get is
Exception in thread “AWT-EventQueue-0” com.jme3.asset.AssetNotFoundException: /home/hector/Desktop/ImportTest/NavModel.blend
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:278)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:369)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:373)
I know the file at /home/hector/Desktop/ImportTest/NavModel.blend to exist and be a valid blend file (It imports fine with “Import Model”)
Any assistance would be much appreciated
Thanks, Hector