Custom 3D model issues

Hey, I try to load a custom model (xml) but I’m encountering an error. I checked out the documentation section and I found this:

[java]Spatial model = assetManager.loadModel(

“Models/MonkeyHead/MonkeyHead.mesh.xml” );[/java]

So I’m trying to use this and so far I have this code:

[java] Texture texture = assetManager.loadTexture(new TextureKey(“Models/DeathTrap.tga”));

Spatial model = assetManager.loadModel(“Models/DeathTrap.xml” );

Geometry modelGeometry = new Geometry(“Model”, model);

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

material.setTexture(“ColorMap”, texture);[/java]

But eclipse is displaying me an error on the Geometry() method telling me that “the constructor Geometry(String, Spatial) is undefined”. So I’m a little confused.

I have a model “xxx.xml” and its texture “xxx.tga” and I just want to display it with jME. Can anyone guide me please ?

Thx !

Ur setting a spatial as mesh for that geometry…

And thats not how to load a model, u should set that texture inside the model’s material file.

You mean in the xml file ? And then I’ll only have to load the spatial and attach it to the rootnode ?

For now when I try only this code:

[java]Spatial model = assetManager.loadModel(“Models/DeathTrap.xml”);


I have the error “No loader registered for type “xml””.

Its .mesh.xml … This is recognized by the loader. :wink:

Nice, it works thx !

Is there a way to apply the textures after loading the model or must the textures be integrated into the xml file of the model ?

I’ve tried this but it crashed:

[java]Spatial model = assetManager.loadModel(“Models/DeathTrap.mesh.xml”);

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

material.setTexture(“NormalMap”, assetManager.loadTexture(“Models/DeathTrap.tga”));



[java] Spatial model = assetManager.loadModel("Models/DeathTrap.mesh.xml");

Material material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

material.setTexture("NormalMap", assetManager.loadTexture("Models/DeathTrap.tga"));



I have a black screen on both desktop and Android apps…

@s4milli4: What light are you using?Did you already try with all kinda light?

If you are using blender : Try to recalculate the face normals outside in blender (ctrl+n) before exporting.

Or try something like this:




try with the others face cull modes too.

Edit: Did you generate tangent binormals?

-_-’ I have no light… Ok i get my mistake, then what material should I use if I don’t want to put lights and add my texture ?

use Unshaded material instead of Lighting material if you don’t want lighted material

Hmm! The Lightning material support glow map and glow color, but looks it requires a light source. But anyways i think you must to add a light to the scene graph. Simple add a light to the scene graph:


PointLight pl = new PointLight();

pl.setLocation(new Vector3f(-2, 2, -2));



Read about lights here : and about materials here.

Edit: WOw! You were fast nehon :D.

It’s ok I don’t need lights as I just want to check out the texture render. but I don’t know what to put as String in :

[java] material.setTexture(“WHAT TO PUT HERE ?”, assetManager.loadTexture(“Models/DeathTrap.tga”));[/java]

I tried “ColorMap” but it crashes when I do so…

that’s ColorMap, maybe it crashes because your texture is null.

check the path

No the path is fine, could it come from the “.tga” extension ? I’m having this error on desktop:

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalArgumentException: The given texture parameter is not set.
at com.jme3.material.Material.clearTextureParam(
at com.jme3.material.Material.setTexture(
at jme3test.helloworld.HelloNode.simpleInitApp(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(

Well, I kinda managed to display my model with its texture but the texture mapping is totally wrong…



Is there any mean to fix this or do I have to do my texture again ?

Another problem I have is that I can now make the texture display under jMP but I still have an error under Eclipse (with the same code)…

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Models/DeathTrap.mesh.xml
at com.jme3.asset.DesktopAssetManager.loadAsset(
at com.jme3.asset.DesktopAssetManager.loadModel(
at com.jme3.asset.DesktopAssetManager.loadModel(
at com.lesmobilizers.general.Test1.simpleInitApp(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(

And finally, I can display texture on an Android device but the texture is still reversed (as above) and the color is altered (instead of being brown like on previous screenshots, it's kinda blue/grey - more specifically, blue and red seem to have been swapped).

Try generating tangent binormals in jmp by right click on .j3o ----> advanced binary converter, and select “tangents”. Upload model, material and textures here so we can check them.

I don’t have any “.j3o” files… my models are “.xml” files imported from 3DS Max.

glaucomardano said:
Try generating tangent binormals in jmp by right click on .j3o ----> advanced binary converter, and select "tangents". Upload model, material and textures here so we can check them.

Sorry, i wanted to say ".mesh.xml" instead ".j3o". But anyways the "mesh.xml" models are converted to binary ".j3o" when loaded. But how i suggested before, did you generated tangent binormals to your model?

Actually I may have found another way to export my models so that when i load them they are already textured.

What was the another way did you find?