Problem applying texture in model imported from Blender

Hi guys,

I have created 2 boxes, one using the Box geometry class, and the other in Blender 2.6. I´ve applied the same Material to them, but I could not get the texture to work in the Blender one.

As you see in the screenshot, in the second box (created in Blender), the texture is split in 2 triangles. Worst, when I move the camera, the texture changes.

Here are the screenshots:

Here is my code:


package mygame;


import com.jme3.asset.TextureKey;

import com.jme3.light.AmbientLight;

import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.scene.shape.Box;

import com.jme3.texture.Texture;

import com.jme3.texture.Texture.WrapMode;


  • test
  • @author dvsantos


    public class Main extends SimpleApplication {

    Material mat;

    public static void main(String[] args) {

    Main app = new Main();




    public void simpleInitApp() {







    private void initMaterial() {

    mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

    // mat.setColor(“Color”, ColorRGBA.Blue);

    TextureKey key3 = new TextureKey(“Textures/Terrain/Pond/Pond.jpg”);


    Texture tex3 = assetManager.loadTexture(key3);


    mat.setTexture(“ColorMap”, tex3);


    private void createBox() {

    Box b = new Box(Vector3f.ZERO, 1, 1, 1);

    Geometry geom = new Geometry(“Box”, b);


    geom.setLocalTranslation(new Vector3f(0, 3, 0));



    private void loadBox() {

    Spatial spatial = assetManager.loadModel(“Scenes/test.j3o”);




    private void setUpLight() {

    // We add light so we see the scene

    AmbientLight al = new AmbientLight();



    DirectionalLight dl = new DirectionalLight();


    dl.setDirection(new Vector3f(-0.25f, -1f, -1f).normalizeLocal());




    public void simpleUpdate(float tpf) {

    //TODO: add update code



    public void simpleRender(RenderManager rm) {

    //TODO: add render code




    And here is the blend file:


    I´ve just created a new Blender file with the default box, and then converted it to j3o binary format with a right-click, in the JME3 SDK. The code is in the method loadBox().

    Btw, I get the same problem with Blender 2.49.

    Can you help me to figure out what is happening? Am I doing something wrong?



You probably need to setup your UV mapping in Blender, looks like the default mapping.

I´ve created a complex model in Blender, using UV mapping, and had no problem. I also saw that the Blender loader only support UV mapped textures, I could not use any Global texture.

But in this test, I only wanted to create the model in Blender, and assign the texture in the code.

The mesh is a simple cube. Why the texture looks so weird?

I mean no offence but it sound to me like your not fully understanding the concepts behind UV mapping, it relates to how a texture is stretched across a model and has nothing to do with the actual texture you ultimately decide to use.

Read over the link I gave you before, set up your UV mapping in Blender, import your model into the engine then assign a texture to your model. The engine will combine the texture you specify with the UV coords saved as part of your model data.

Humm, ok. I´ll do that.

Tks :slight_smile:

Well, got a better result now:

I´ve only marked the Seams in Blender, unwrapped, and saved the blend file.

Now, I have to understand why the texture is scaled differently in the 2 boxes. Any hint?

Tks for the help, thetoucher!

Now, I have to understand why the texture is scaled differently in the 2 boxes. Any hint?

I wonder why are you assingning the textures in jmp, once it's automatically assigned when you export it to jmp from blender. Just load the model....

It’s to do with the way you have setup your UV mapping. You really need go through some UV mapping tutorials to get a better understanding of how this works, a good understanding will really help you as a developer.

The best thing to do would be load up the uv editor window in blender then have a play with different unwrap methods, and scaling / moving the points around in the UV editor window, you will very quickly gain insight into how it all works.

Bellow are some Blender screen shots, the left window is the 3d view of a simple texture mapped cube, the right is the uv editor window displaying the texture (so we can see whats going on) and the UV points. Each square in the uv window maps directly to a face of the cube. The top example has these faces overallping. The top and bottom show the same cube unwrapped 2 different ways, which should help explain the scaling:

The top one is roughly how the Box geometry is mapped, each face will show all of the texture.

The bottom one is roughly what you have done, as you can see on the right , each face only shows a small amount of the texture, and the engine needs to scale that up to fill the entire face. If we were to scale up the UV coords, each face would be showing more of the texure and thus the texture would appear smaller or scalled down on the model.

I’m really not sure how to break it down any more for you sorry.


Yeah, It seems to be an easier way, glauco. But maybe for some reason, one may want to load the texture dinamically, right?

In this case, I was just testing and trying to understand the difference.

Ok thetoucher, I´ll study the subject.

Tks guys!