Importing assets from blender to JME3 (noobie question + ¿What are the best practices?)

Hi, guys. I was practicing with JME3 and did a small model in blender like this, with a camera and some lights:



http://www.freeimagehosting.net/ea081



Just the default cube with a texture and a plane as a floor (both UV mapped). I exported as a OGRE3D files and it gives me cube.scene, Material.001 (I checked it , and it refers only to the texture of the floor but not the one of the box) , and plane.mesh. I tried putting inside a zip file called scene and loaded like with town.zip (calling cube.scene), but it fails.



[java]package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.asset.plugins.ZipLocator;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Spatial;



/**

  • test
  • @author normenhansen

    */

    public class Main extends SimpleApplication {



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }



    @Override

    public void simpleInitApp() {



    assetManager.registerLocator(“scene.zip”, ZipLocator.class.getName());

    Spatial scene = assetManager.loadModel(“cube.main”);



    rootNode.attachChild(scene);

    }



    @Override

    public void simpleUpdate(float tpf) {

    //TODO: add update code

    }



    @Override

    public void simpleRender(RenderManager rm) {

    //TODO: add render code

    }

    }

    [/java]



    I tried loading putting them in the different assets folders, but when trying to view the scene in the SceneComposer JME3 asks for the textures to be in the same folder as as the mesh and having the same name. Doing so it only shows me the floor properly textured and lit, but no trace of the box, and mesh.xml produces an untextured red plane (¿?).



    I know I’m doing something wrong and there is and obvious solution (there cannot be more than one separated mesh in a scene?), but I tried searching in the forums and the documentation, and nothing. I think the “hello asset” tutorial fails a bit on explaining how to load your own models properly and the uses of the default folders (what is exactly the difference between the materials folder, the textures folder, and the scene folder or the model folder?) and the blender exporter guide should be updated. That’s what i am asking. How can I load them properly? How to use the folders so I can have the game project organized?. Should all assets be referenced separately through code (i.e load (“models/maincharacter.xml”) and load(“textures/maincharacter.jpg”)), or just load one (the mesh) and all is implicitly referenced? Is it better to use zip files?



    Thanks in advance, I know the question is a bit wide, but I tried a few days myself in the solution and I cannot figure it out. Regards.

Material and scene name have to be the same, also the importer supports OgreXML, so you have to convert the model using the command line tool before trying to import it. The SDK supports converting binary models that have been placed in the assets directory directly, using the command line tool internally. The Model Import dialog will only accept XML files.

@normen said:
Material and scene name have to be the same, also the importer supports OgreXML, so you have to convert the model using the command line tool before trying to import it. The SDK supports converting binary models that have been placed in the assets directory directly, using the command line tool internally. The Model Import dialog will only accept XML files.

Mmmm... from your answer I assume that placing the .blend file inside the project assets folder and asking JME3 to convert it to j3o will convert it. I just did that and it does not do anything... Do I have to download the OGRE command Line Tools and deal with those? What are exactly the steps to do it?

I am not talking about blend files, I talk about ogre files. You said you got “plane.mesh”, which would be a binary file. If you use blender and the OgreXML exporter that comes with the SDK (Tools->OgreXML) then you should get xml files and can ignore the “binary files” part. However that the blend file doesn’t get converted hints at other issues with e.g. texturing (only UV-maps are supported in games) or the texture files not being accessible. At any instance in the SDK or using command line or when compiling you usually get warnings and exceptions that show you whats up. (check the Application log and the warning signs in the lower right in the SDK).