Texture settings removed when importing mesh.xml objects

Hi!

I’m starting a new project and so far so good :slight_smile:

I made this method to import a mesh made in blender among with one texture (that covers the whole house):

[java]public static Node ShapeMesh(String name, String texture){

Spatial model = MainClass.getAsset().loadModel(name);

model.setMaterial(MaterialManager.Texture(texture));

return (Node) model;

}[/java]

MaterialManager.Texture(texture) method is this:

[java]public static Material Texture(String name){

Material mat = new Material(MainClass.getAsset(),“Common/MatDefs/Misc/SimpleTextured.j3md”);

mat.setTransparent(true);

mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);



mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);

Texture img = ImageLoader.Load(name);

mat.setTexture(“m_ColorMap”, img);



return mat;

}[/java]



Now the problem is that the texture gets applied. But all the hard work on editing what surface takes what part of the image, is totaly wasted.

It does not set the offset and changes that I’v made in UV mode in blender. It simply apply the whole texture on each and every face in the whole mesh. It looks truely ugly.

So I tried exporting and using the mesh as an .obj file.

Then I get com.jme3.scene.Geometry cannot be cast to com.jme3.scene.Node error.



So what should I do?

Is there a specific option to click when exporting from blender or do I import wrong in java?

Okej if someone is woundering how to fix this.

The solution is to export as mesh.xml from blender. Then rename the Scene.material to yourmodelname.material.

For example if your model is called hello. You should have these two files in your export directory:

hello.mesh.xml

Scene.material



Change the last one so that you have:

hello.mesh.xml

hello.material



And you will be good to go :smiley: