Adding materials removes the shading, why?


I just noticed that when I made a cube in jME3 like this:

Box b = new Box(Vector3f.ZERO, 10, 1, 10);

        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");

        mat.setColor("m_Color", ColorRGBA.Blue);


then the shading disappears which makes the cube look like it is a lamp or something…

How do I enable shading?

Dont use the solidcolor material??

Check out an extremely in-depth look at the material system here thanks to MomokoFan:

Okeej, Now I'v read it :slight_smile:

But from what I get from it, I must create my own material if I want

a solid color with shading?

Because looking at this page:

I can see that the only avalible with shading is textured onces…

So I gota modd a SolidColor.j3dm?

I tried to modd the WireColor by setting wiremode to false.

But then it gave same results as SolidColor…

The guide you gave me said there was enough j3dm materials so I wouldn't

have to create my own, yet there is not even a simple standard material :confused:

I'm sorry, I should add I've no experience with any of this. I just happened to remember the explanation…

Well, then I guess this is mainly disturbing me in my debugging process

as objects who doesnt show shadow is hard to figure out the form of.

BUT if you can help me, explain how I could use assetManager to get a

texture from a png image on my desktop.

I'v tried long time, dunno how to create a Texture object with an image

in any other way :confused:

The tutorials and explenations Iv read on this page really doesn't help.

All it shows is how to create a texture based on images in THEIR database!

you need to register a FileLocator which is the location of the image…

sorta like this…

File imageFile = new File("desktop/picture.png");
assetManager.registerLocator(imageFile.getParent(), FileLocator.class.getName());

i've never tried this for textures but it works fine for object loading...

You don't have to use the Lighting.j3md material with a texture, just don't use any of the setTexture() methods on the material. You can change the color of the material by setting m_UseMaterialColors to true and then setting the m_Ambient, m_Diffuse and m_Specular variables.

See the TestSimpleLighting example on how to have solid colored lit materials.

Thank you Very Very much!

Now, After a half days work, I finaly got it all working, just

before I was gona go to sleep! :smiley:

Thanks alot everyone!