[Solved] Importing a material

Hi all,

I looked over the internet, and didn’t find a answer to this question.
I want to import a model (a tree) which is totally unspecular.

If I just load the model’s j3o file without anything more, I have the good colors, but there is specularity. But if I want to set manually the imported material to my model (the Lighting.j3md which is in Common/MatDefs/Light of my imported model’s file), a I do not have specularity (what I wanted) but the colors disappeared… I guess there is a problem of diffuse map when I want to use Lighting.j3md. But I guess there is a way to combine both?

thanks for attention, sorry for my english.
Theodeme

How about calling clone on the material and setting the specularity to 0 or even directly edit the Material?

Else you need to specify the diffuse map and maybe the UV coords. Maybe the unshaded Material is what you want?

Well actually I import my assets directly from blender files, not from Ogre export, I do not have a .material file.

No, I just want a sort of lowpoly render, without any specularity but not unshaded. Just want it “clean” but lighted.

You have a Material embedded into the j3o.
You can export it in the SDK by selecting the Geometry and looking at the Properties Dialog. There you see Material. When you click into it it will be generated.

Apart from that you could also set that value dynamically in the code, since you want that for all files. That basically means after loading using a SceneGraphVisitor and for each Geometry something like:

geom.getMaterial().setMatParam("Specularity", 0); (pseudocode!)

Sorry if I’m dumb, but what do you mean by selecting the geometry ? If I select my .j3o file, I don’t see “material” in the property dialog.

Moreover, I can’t use the second solution because my object is a spatial (used with assetManager) which doesn’t have any getMaterial() method.

I’m sorry I guess this is absolute basics.

SceneGraphVisitor
…the important thing in that quote… SceneGraphVisitor
As in a thing to visit the scene graph… ie: SceneGraphVisitor

Which you can find in the Javadoc… or even look at Spatial’s javadoc and find the method that takes a SceneGraphVisitor.

You can even make your life easier by looking at the already defined implementations of SceneGraphVisitor in the javadoc.

Hopefully you know how to find the javadoc.

In the scene editor, there is a tree. That tree will have your model. If you expand the tree, there must be a geometry in there somewhere… else nothing would be displayed because only Geometry can produce visuals.

1 Like

Okay I got it. Thanks a lot for help, sorry for the time it took to make me understand.

Another last question : if my meshe is a scene, with multiple geometries, is there a way to use a unique material to them all? or must I make only one big object in blender? (without assigning this material by selecting every geometry one by one)

Do you mean you want them each to have their own unique material different than the others? Or do you mean you want them to share the same material (ie: not at all unique)?

I want them to share the same material.

So… not unique.

Easiest was is with a scene graph visitor. You can visit every geometry and set it’s material to the one you pass to your scene graph visitor. You can look at the Javadoc to see the existing implementations of SceneGraphVisitor to find the one that makes this just a few lines of code.

All right, that answers all my questions, and even more. Thanks a lot for your time.