Importing textures on models into JME3

Hey,



I’ve created a simple 2D plane in Blender, added a material and also the “cloud” texture. I exported via the Ogre XML dotScene exporter, which generated a scene file, mesh file and material file.



I then convert the .scene to .j3o in JME3. When I open the file in scene viewer, the texture is not there.



I’m still learning the concepts of 3D modelling, and I was wondering if anyone could indulge me with a simple explanation of why this is not working. It may because I don’t quite get “textures”- is it the case that you can only import meshes to JME3 and have to add the textures yourself in-game? Or perhaps there are special options in blender to export textures too?



Thanks

A game compatible model is a uv-mapped model with color, normal and specular maps, nothing more. You cannot expect all functions of a offline-3d-renderer like blender to work in a game engine, “cloud texture” is not a globally defined thing that every 3d editor and engine understands. You have to either bake the things or try what the blender importer does (it also bakes lots of things but is in alpha state). …or best design the model with game compatibility in mind from the beginning. Our documentation has lots of info on all this.

1 Like

Hi, thanks for replying quickly! Okay, that’s interesting, I didn’t know that.



I haven’t heard of baking, is this a method of making permanent the visual effects on a model, for export? Google searches. I’m making a simulator in JME3 that uses a 3D globe with the world printed on. I’ve managed to UV map this and create the model in Blender, but have not been able to export it. I realise now that it’s probably because it’s not a basic model. Would “Baking” the map onto the model help then?

If this is all new to you I really suggest reading our documentation/wiki start to end, it teaches you a lot about game development and all the topics it touches.

1 Like

Thanks. I’ve spent days consulting online literature trying to comprehend this. I’m assuming then that there’s no way AT ALL that a model created in Blender with an image as its texture can be imported into JME3, because JME3 does not support it? Hence if you want texture on a model, it must be implemented locally in JME3.

As I said, you create a proper UV-Mapped model in blender. No other way to set a texture. Again, this is normal for every live rendering process.

1 Like

So, you create a UV mapped model in Blender that holds the coordinates for a mapping. Then, you load the texture in JME3 and “apply” it?

No, you just import it.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_asset

https://docs.google.com/fileview?id=0B9hhZie2D-fENDBlZDU5MzgtNzlkYi00YmQzLTliNTQtNzZhYTJhYjEzNWNk&hl=en

https://docs.google.com/leaf?id=0B9hhZie2D-fEYmRkMTYwN2YtMzQ0My00NTM4LThhOTYtZTk1MTRlYTNjYTc3&hl=en

Thanks for the tutorials. I think I’m getting closer to finding the problem … slowly. You say you can import textured models, I’m not sure how…



I used the second tutorial you linked me to to create a test. I added a material to the default cube, and an image as a texture. This rendered properly in Blender. I exported this using Ogre XML, creating a mesh file, material file and a scene file. So far so good.

The scene is converted to .j3o in JME3, and viewed in scenecomposer. Only the colour of the material is visible, not the image. The image is in the correct location.



This is what is strange- according to http://www.ogre3d.org/tikiwiki/Materials, the syntax



[java]material cubeMat

{

receive_shadows on

technique

{

pass

{

ambient 0.10744035243988037 0.04605450853705406 0.800000011920929 1.0

diffuse 0.0859522832326931 0.036843607378655774 0.6400000190734865 1.0

specular 0.5 0.5 0.5 1.0 12.5

emissive 0.0 0.0 0.0 1.0

texture_unit

{

texture icon.png

tex_address_mode wrap

scale 1.0 1.0

}

}

}[/java]



should create a texture. But the texture does not show. I can disable the ambient, diffuse … etc attributes and the cube goes from coloured blue to grey, showing a response. But the texture_unit syntax does not work. Does JME3 choose not to support this syntax?



So jme3 does not support this. I’m at a loss why I can’t import textured objects. How does everyone else do it?

On Blender you have to set your textured object to use UV Mapping

Could you tell me how the syntax would differ in the .material file? (So I can look out for it when playing around)

You know blender has documentation too :wink: UV-mapping a model is not exactly occult knowledge.

I have consulted the Blender documentation! I feel like I have exhausted everything I can find on it.



I’m asking for some handholding from people who know their stuff as I’ve spent days on this one problem. I have created a UV mapped object, but could not import it properly. Hence, I’ve gone back to basics with this basic example- I want to know where the missing link is.

Your texture is not set to be uv-mapped but wrapped.

Have you done this?





If you did everything correctly, then it should work straight on JMP. I’ve no problem loading a textured model with assetManager.loadModel(…).

Whoa, fabiano you star! Okay, I’ll try it soon and let you know how I get on. This helps! :stuck_out_tongue:

Thanks for your help. There’s been progress! I think I neglected to select an option. I followed the tutorial here: http://www.youtube.com/watch?v=obB9T3jXlak, and created a coloured cube as shown:



http://www.okayfish.com/goodcube.jpg



When I export it into jmonkeyengine though, this happens:



http://www.okayfish.com/redcube.jpg



The texture has been recognised (the numbers), which I’m pleased about. But the other colours are not there. Has anybody have idea why?



Here’s the material file:



[java]material missing_material

{

receive_shadows off

technique

{

pass

{

ambient 0.1 0.1 0.1 1.0

diffuse 0.8 0.0 0.0 1.0

specular 0.5 0.5 0.5 1.0 12.5

emissive 0.3 0.3 0.3 1.0

}

}

}





// blender material: Material

material Material

{

receive_shadows on

technique b2ogre_1327245555.441

{

pass b2ogre_1327245555.441

{

ambient 0.800000011920929 0.0 0.04147796705365181 1.0

diffuse 0.6400000190734865 0.0 0.033182374137377346 1.0

specular 0.5 0.5 0.5 1.0 12.5

emissive 0.0 0.0 0.0 1.0

alpha_to_coverage off

colour_write on

cull_hardware clockwise

depth_check on

depth_func less_equal

depth_write on

illumination_stage

light_clip_planes off

light_scissor off

lighting on

normalise_normals off

polygon_mode solid

scene_blend one zero

scene_blend_op add

shading gouraud

transparent_sorting on

texture_unit b2ogre_1327245555.441

{

texture cubemap.png

tex_address_mode wrap

scale 1.0 1.0

colour_op replace

}

}

}

}

[/java]



I realise that something’s not right with the “material missing” bit, I don’t know if that’s me or a problem with the exporter. It’s probably worth deleting? Fabiano, what do you use to export?

On Blender, did you assign a material to your object? You do that through that Materials tab on the left side of the Texture tab.

Hi, I have assigned the material, but the problem stays the same. (I selected the vertices in edit mode and clicked “assign”. Clicking select and deselect confirms this). The “missing material” thing in the material file is really strange, does this happen if I forget to check something, or is it a problem with the particular exporter?



Is it something to do with the “Influence” panel for texture? I only have color ticked and the Blend mode is “mix” …

Or perhaps something in “Options” for material. Do I need to tick “Face textures” for example?



Thanks again

Sorry to repost- I thought I’d just share some things that might help:


  • The cube is red, but the shade OF red’s darkness corresponds to the colour of the texture. e.g. 1 is darker than 5 in the screenshot above, to reflect the UV mapped image, and all black is visible too (obviously as the darkest colour). So, it is as if there is a red OVERLAY over the texture image. The red comes from the values for ambient, diffuse, specular and emissive in material “Material” (above). I changed these to green and the cube became green, overlaying the texture underneath. So the question is:



    How do I remove the material’s colour overlaying the texture? This may have something to do with the blending of the texture, could someone please enlighten me?


  • I’ve been through the mesh, material and scene files. Mesh seems fine, scene doesn’t seem to have anything to do with this, so it must be material.



    I don’t know if it would be useful if somebody could post the contents of a typical material file for a UV mapped object they have created, so I can go through the attributes and change them by hand in my own file, until I find the problem?



    I apologise if I come across as a noob detective! :smiley: