Problem converting from .blend to .j30

Firstly I am sorry to ask this as I see it gets asked quite a lot but I have read the tutorials trawled the forum and read the pdf (bananapie). However I am still having problems with my model or more accurately material. It is a very simple model of a wall section which I intend to load and then place copies next to each other to build mazes. It is a very simple cube shape and I have created an atlas for the material as I have a brick wall with concrete coping stone along the top. In the .blend I have uv mapped to the image. My project is being built in Eclipse but for now I am using the SDK on

Dell Inspiron 1750
memory 4gb
Pentium® Dual-Core CPU T4300 @ 2.10GHz × 2
Mobile Intel® GM45 Express Chipset
64-bit
ubuntu 13.04
Blender2.69

Product Version: jMonkeyEngine SDK 3.0
Updates: Updates available
Java: 1.7.0_11; Java HotSpot™ 64-Bit Server VM 23.6-b04
Runtime: Java™ SE Runtime Environment 1.7.0_11-b21
System: Linux version 3.8.0-25-generic running on amd64; UTF-8; en_GB (jmonkeyplatform)
User directory: /home/lg/.jmonkeyplatform/3.0
Cache directory: /home/lg/.jmonkeyplatform/3.0/var/cache

My texture file is 2048 x 2048 which is big enough for me to get the two images I am using in.

So as per the instructions I copy my .blend file and the .png file to the textures directory in assets, right click on the .blend and select convert to j3o. I then move the .j3o to the Models directory. If I look at his file in the scene explorer I see nothing so I assume that the material/texture did not get converted. This doesn’t appear to be unusual and all threads etc that mention this simply create a material and attach it. This is where I am having issues as I don’t seem to quite understand the process. I have tried creating a material as per the basics tutorial and then adding my .png as the texture. I get:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Textures/wall-section-atlas.png (Flipped)

So far my simple app is:

@Override
public void simpleInitApp() {

    Spatial wall = assetManager.loadModel("Models/wall_sections.j3o");
    
    Material mat_default = new Material( 
        assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
    
    /*mat_default.setTexture("wall_atlas", 
            assetManager.loadTexture("Textures/wall-section-atlas.png"));*/
    
    Texture tex = assetManager.loadTexture(new TextureKey(
                                        "Textures/wall-section-atlas.png"));
    
    mat_default.setTexture("wall_tex", tex);
    
    wall.setMaterial(mat_default);
    wall.setLocalTranslation(2.0f,-2.5f,0.0f);
    rootNode.attachChild(wall);
}[/java] 

Please advise.

@onesixtyfourth said: I have tried creating a material as per the basics tutorial and then adding my .png as the texture. I get:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Textures/wall-section-atlas.png (Flipped)

Where did you put the png file?

The .png is in the textures directory with the .blend. I also packed the .png for one attempt. From reading I thijght the .jmo would work on its own. The ogre ezported seems to be favourite should I give that a go.

@onesixtyfourth said: The .png is in the textures directory with the .blend.

In the “assets/Textures” directory?

The error states otherwise.

Well that got past an error for me. I had changed the name of the .png to wall-sections from wall-section-atlas and altering that has got me past the notFoundException. Now this line

[java]mat_default.setTexture(“wall_tex”, tex);[/java]

is causing:

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: Material parameter is not defined: wall_tex[/java]

So now I am thinking that the material has this set so how to I create a basic material to attach my texture to?

but yes the .png was in the assets/Texture at least I can see it under the basic project structure in Project Assets -> Textures

Well, the image has to be named the same as you are loading… so glad you got past that.

The “wall_tex”… I’m not sure where you are getting that name. When you set a material parameter you have to use one of the actual parameters for that material. I’m not sure the “show normals” material is the one you really want anyway.

Have you been through any of the material tutorials yet?

Yes I will go back over the Materials tutorials and set a basic one up that I can set my texture to. Thanks for your help.

@onesixtyfourth said: Yes I will go back over the Materials tutorials and set a basic one up that I can set my texture to. Thanks for your help.

Sure. Let us know if you are still stuck.

Thank you all sorted now. I used the lighting j3md to create my material after adding some other attributes and some light I can now see the model. / Thanks for pointing me in the right direction. Everything I neede to know was contained in the tutorial I just needed a pointer to realise where I was going wrong.

[java]Spatial wall = assetManager.loadModel(“Models/wall_sections.j3o”);

    Material wallMtl = new Material(assetManager, 
                                "Common/MatDefs/Light/Lighting.j3md");
    
   Texture tex = assetManager.loadTexture(new TextureKey(
                                        "Textures/wall-sections.png"));
   
    wallMtl.setBoolean("UseMaterialColors",true);    
    wallMtl.setColor("Diffuse",ColorRGBA.White);
    wallMtl.setColor("Specular",ColorRGBA.White);
    wallMtl.setFloat("Shininess", 64f);  // [0,128]        
    wallMtl.setTexture("DiffuseMap", tex);
    
    wall.setMaterial(wallMtl);
    wall.setLocalTranslation(2.0f,-2.5f,0.0f);
    rootNode.attachChild(wall);
    
    /** Must add a light to make the lit object visible! */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
    
    DirectionalLight sun1 = new DirectionalLight();
    sun1.setDirection(new Vector3f(-1,0,2).normalizeLocal());
    sun1.setColor(ColorRGBA.White);
    rootNode.addLight(sun1);[/java]
1 Like

Glad it worked out for you… and thumbs up for posting the working code for the next adventurers that stumble onto this path.