Blender material loading problem at JME engine

(solved… but only for this case…, I had the luck of these cycles materials actually use textures… see here for baking cycles textures)

I saw many topics saying we must create a j3m file to use with j3o ones, but most are too old topics, about 2011.

So now, is there some way to configure the blender material so it is auto loaded at JME?

Or at least some way to properly configure it so it can be extracted from blender file and we can create the j3m one? as easy it is to create the j3o one (new BinaryExporter().save(loadedSpatial, new File(fileNamedJ3o)))?

Or may be, should I export the blender file to some other format that could be recognized and auto-loaded by JME? or at least is usable on reading and exporting (j3m).

I want to make everything automatic. I just prepare the blend file (or exported format) and all other steps (j3o, j3m), I will code to be automatic.

I’m in the same situation, trying to figure out how best to do this. It’s a pain to have to the following:

  1. Create Blend Model Mesh
  2. Load Texture Image/Texture Atlas in Blender
  3. Unwrap UV and map UV coordinates in Blender
  4. Create Material in Blender on the Object and assign the Texture
  5. Save the Blender File in the “Assets/*” folder structure of the jME3 project
  6. Go into SDK, right-click the “.blend” file, and choose, “Convert to j3o Model”’
  7. Copy original Texture Image/Atlas to SDK jME3 proejcts “Assets/*” folder
  8. In SDK, create a new material and select the Texture Image/Atlas as the “Diffuse” texture (etc)
  9. Open the j3o model in the SDK
  10. Delete all the unnecessary nodes (light, camera, etc) from the j3o
  11. Set the jME3 material to the created material
  12. Save the j3o model

Now I have a model that can be linked/inserted into a scene which has texture(s) mapped and jME3 materials defined using U/V mapping.

Yikes! What a process. I’m hoping there is an easier way and I just need to learn more first.

I’m do the same. But when doing second model I only copy material from first and change textures. Simple. Don’t make camera and other unnecessary objects so you dont need to delete them in SDK :wink:

1 Like

You can extract the material from model and edit it ! so great :grinning:
I learned it from one of the @normen’s post earlier .(thanks Normen)



the textures assignment seem dynamic based on the j3m filename?
as there is no link to them at the j3m file, or such link is only at j3o file?
And at the JME-j3m-editor, there is no reference to the textures extracted either.

Anyway, it only worked for one model:

The way its texturized material is configured seems to work very well on being autoloaded at JME engine. So I dont have to extract them, but to use the much smaller j3o/j3m+textures format, I am sure it will work (I still just need to know how to extract j3m from it dynamically in my code).
The other models I got, lose their material/texture, resulting in a simple white model. Such models also dont have their textures extracted at JME SDK the way you showed.

I am researching, I think that JME Blender importer still doesnt have support to Blender Cycles Render engine Cycles Material, so we have to switch in Blender to the Blender Render, and try to fix/adapt the materials to it.
This explains the problem in Blender:

Of course you can do it at run time in code
here is some sloppy code I wrote for testing a week a go.

 Spatial G4 = assetManager.loadModel("Models/Rin Dae Normal Correct/Rin.j3o");
       Node g4 =(Node)G4;
       Node c4=(Node) g4.getChild("DrawCall_0569");
       Spatial s43=c4.getChild("DrawCall_05691");
       Material m43=((Geometry)s43).getMaterial();
       m43.setFloat("AlphaDiscardThreshold", 0.1f);
       //you can set texture to material 

I am starting to love JME3.1 blender importer … It works really great for me !
I do not know about blender Cycle .
I exported a .max file to OpenCollada (not Autodesk Collada) then imported to blender and saved as .blend then converted to .j3o . it worked well !

Can you explain the procedure you use to import model to JME .
What is the format of your model ?

Do you put textures beside your .blend file when you convert it to .j3o ?

How to prepare a blender model to have its material ready to be loaded on JME engine.
The most probable reason for it not be working is that in blender, your model is set to “Blender Cycles Render” mode, and so, its materials are using Cycles Nodes Materials.

What you have to do is:
1 - Change the render to: Blender Render (BI Blender Internal Render) (see here)
2 - Make sure the “use nodes” on material is DISABLED (see item 4 here).
3 - If (most probably), at model Textures, the textures are not already set:
3.1 - click on an empty texture slot, and + (add new)
3.2 - At “image” sector, “browse image to be linked” (simply select one of the available images)
3.3 - repeat step 3 to all available textures.

JME engine, seems to recognize it all kinds of textures (bump map, gloss…).

JME SDK wasnt able to extract all the available kinds of textures on the model, only diffuse was extracted, so at the SDK the model visualization was only with diffuse. But the JME engine, used them all and the colored textures looked very good!

A tip to convert all material at once, from cycles to blender internal BI, using python (in blender) is here.

Obs.: in blender internal render mode, you may have to create a high intensity point light to see the model textures.

PS.: improvements on this tip details are welcome.

1 Like

I am using the blender file format to load direcly on the JME game engine.
I use the textures packed into the blender file.

Well, I use decimate to lower the poly count on all models, and I extract and resize (down) all textures, and pack back again, so I have a lightweight blender file, but still, j3o+j3m+texture files are surely the best/fastest way to load the models. Because of that, to have the least trouble/work, I will dynamically decompose blend files into j3o/j3m/textures, to make a kind of cache for fast loading on the second game play. This could even be optinally automatic by the engine I guess. Could be called “JME3-models cache” or something like that.


I do things like that but dynamically, I read the model and remove everything that is not a geometry from the node structure, only after that I use the model.

1 Like