Loading .obj and .mtl in JME3

I made a chess board using Blender and gave it a marble material texture. When i render it it looks fine. But when i load it into jME3, it only slows a partial board. And if i use the “ShowNormals” material def it shows part of the board as the rest as a grey square without the detailed pattern on top. Can anyone help me out with this?

If you load it without the texture does it work then?

Maybe look at this: Material Editing

that doesnt affect anything. i only see two columns with the alternating pattern and one partial either way.

How are you lighting your scene in JME?

directional lighting.

Maybe post a picture and some code?

[java]
assetManager.registerLocator(“D:\Files\LUMS\Spring 2014\AP\Blender Files”,FileLocator.class);
Spatial pawn = assetManager.loadModel(“Board_postjoin.obj”);
pawn.setLocalTranslation(0.0f, -10.0f, -2.0f);

    Material mat_brick = new Material( 
    assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
    pawn.setMaterial(mat_brick);
    rootNode.attachChild(pawn);
    
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun)

;[/java]

what i see vs what i expect to see

if i remove the lines assigning the shownormals material. then i dont see the white squares at all.

Where are you loading the textures (the .png or .jpg)?

There should be something like

mat_Brick.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/marble.jpg”));

(or something similar) before the setMaterial line

Edit: And try using the “Common/MatDefs/Light/Lighting.j3md” shader?

Additional Q, the marble texture you used in Blender, is it a procedural texture or based on an image?

The first doesn’t translate to jME, you need the second, an actual image to apply.

sorry. i was using the procedural one. i’ll base it on an image and try again. thank you so much.

question, cause its an alternating black and white patter. how would i incorporate that into the texture? or should i just grab a jpg of a chess board and texture that onto the board?

Simplest is a single image of a chessboard.
Higher quality might be an image of black marble and another of White.
Then break your mesh up into two sets of cubes that form the board.

That way you could also have several different “skins” to apply to the same board - Marble, wood, glass, etc.

would i break the board into two sets of cubes in blender or can jme handle it?

I’m not so confident of my java skills to do it in jME :stuck_out_tongue:

Far simpler for me to just make a cube in blender, clone it 32 times, and offset it in a checkerboard pattern. Assign that one the white texture.

Clone the whole shebang, <span style=“text-decoration:line-through;”>rotate it 180 degrees</span> and assign it the black texture.
Edit: Mirror it, don’t rotate it…

Depending on your pivot point, they should align perfectly :slight_smile:

It’s interesting that your light points directly sideways:
sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());

The fact that it’s getting lit at all might be an error if it’s laying flat on the ground like I think it is.

That’s an interesting point, @pspeed.

With the x,y,z values of the sun’s vector set to 1,0,-2, there is no vertical (y) component to the vector, is the white/grey shading coming from some interaction with the ShowNormals.j3md?

@HITman, re-thinking my easy solution (modeling it), as a learning exercise, it would probably be much more rewarding to create each cube from scratch in jME, offset them the right amount (a nice nested for loop? ) and assign them the textures.

And play with the sun.setDirection vectors? =)

@foxhavendesigns would you recommend a good tutorial for creating a knight for chess in blender? The one i found made a horrible horse and i could really use a better one.

also i updated the code to include the texture loading. and switched to the pawn. but all i see is a white silhouette of it.
[java]assetManager.registerLocator(“D:\Files\LUMS\Spring 2014\AP\Blender Files”,FileLocator.class);
Spatial pawn = assetManager.loadModel(“Pawn.obj”);
pawn.setLocalTranslation(0.0f, -5.0f, -2.0f);
Material mat_default = new Material(
assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
// mat_default.setTexture( “ColorMap”, assetManager.loadTexture("" ));
mat_default.setTexture(“ColorMap”, assetManager.loadTexture(“Carrara-White-Marble.jpg”));
mat_default.setBoolean(“SeparateTexCoord”,true);
mat_default.setTexture(“LightMap”, assetManager.loadTexture(“Carrara-White-Marble.jpg”));
pawn.setMaterial(mat_default);[/java]

@HITman said: @foxhavendesigns would you recommend a good tutorial for creating a knight for chess in blender? The one i found made a horrible horse and i could really use a better one.

Depends if you really want to make it yourself to learn blender, or you just need a nice chess set. For free chess sets, check out

For modelling yourself, there are some nice chess 3ds tutorials on youtube - you could possibly grab some techniques from there, even if actual details of operations will different in Blender.

1 Like
@HITman said: also i updated the code to include the texture loading. and switched to the pawn. but all i see is a white silhouette of it. [java]assetManager.registerLocator("D:\Files\LUMS\Spring 2014\AP\Blender Files",FileLocator.class); Spatial pawn = assetManager.loadModel("Pawn.obj"); pawn.setLocalTranslation(0.0f, -5.0f, -2.0f); Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // mat_default.setTexture( "ColorMap", assetManager.loadTexture("" )); mat_default.setTexture("ColorMap", assetManager.loadTexture("Carrara-White-Marble.jpg")); mat_default.setBoolean("SeparateTexCoord",true); mat_default.setTexture("LightMap", assetManager.loadTexture("Carrara-White-Marble.jpg")); pawn.setMaterial(mat_default);[/java]

Well, you set a texture to the lightmap that is clearly not a light map.