1

I've just started working with jME and I've created a 3d model in blender, and exported it to .obj and imported it in my jME application. Ambient light works fine, but the direct light I'm using, only lights up few faces, but instead of lighting up just one face of an object, it lights up the entire object regardless of the direction of the object (both upper arms):

enter image description here

The rest of the character stays unlit by the directional light. This is the source code:

public class Hello extends SimpleApplication {

@Override
public void simpleInitApp() {
    Spatial character = assetManager.loadModel("/character.obj");
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    character.setMaterial(mat);
    character.scale(0.5f, 0.5f, 0.5f);
    rootNode.attachChild(character);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(1.3f));
    rootNode.addLight(al);

    DirectionalLight sun = new DirectionalLight();
    sun.setColor(ColorRGBA.White);
    sun.setDirection(new Vector3f(0,1,0).normalizeLocal());
    rootNode.addLight(sun);
}

/**
 * @param args
 */
public static void main(String[] args) {
    Hello app = new Hello();
    app.start();
}

}

What is the problem?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Kristoffer Dorph
  • 1,233
  • 10
  • 18

1 Answers1

2

I would say something is wrong with the materials you used for your character model

Try adding :

TangentBinormalGenerator.generate(character.getMesh(), true);
mat.setBoolean("m_UseMaterialColors", true);
mat.setColor("m_Ambient",  ColorRGBA.Orange);
mat.setColor("m_Diffuse",  ColorRGBA.Orange);
mat.setColor("m_Specular", ColorRGBA.White);
mat.setFloat("m_Shininess", 12);

Taken from here: http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:light_and_shadow

Aquarius Power
  • 3,729
  • 5
  • 32
  • 67
Akis
  • 89
  • 1
  • 4