Lighting working for teapot and sphere, but not a cube

Just wondering what I’m missing here. See this image:

http://imgur.com/r9HCv

Not how the teapot and the sphere have specular highlights, but the cube (Box) does not. Here is the setup code:

[java] @Override

public void simpleInitApp() {

flyCam.setDragToRotate(true);

cam.setLocation(new Vector3f(0, 8f, 10));

cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);



Box b = new Box(Vector3f.ZERO, 15, 0, 15);

Geometry geom = new Geometry(“plane cube”, b);

Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Black);

mat.setColor(“Diffuse”, ColorRGBA.Gray);

mat.setColor(“Specular”, ColorRGBA.Gray);

mat.setFloat(“Shininess”, 12);

geom.setMaterial(mat);

rootNode.attachChild(geom);



Sphere s = new Sphere(25, 25, 1);//Box(new Vector3f(0,4,0), 1, 1, 1);

geom = new Geometry(“red cube”, s);

geom.setLocalTranslation(0, 3, 0);

mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Black);

mat.setColor(“Diffuse”, ColorRGBA.Red);

mat.setColor(“Specular”, ColorRGBA.White);

mat.setFloat(“Shininess”, 12);

geom.setMaterial(mat);

rootNode.attachChild(geom);



Box b2 = new Box(new Vector3f(0,5,0), 0.75f, 0.75f, 0.75f);

geom = new Geometry(“blue cube”, b2);

//geom.setLocalTranslation(0, 3, 0);

mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Black);

mat.setColor(“Diffuse”, ColorRGBA.Blue);

mat.setColor(“Specular”, ColorRGBA.White);

mat.setFloat(“Shininess”, 12);

geom.setMaterial(mat);

rootNode.attachChild(geom);



Geometry teapot = (Geometry) assetManager.loadModel(“Models/Teapot/Teapot.obj”);

TangentBinormalGenerator.generate(teapot.getMesh(), true);

teapot.setLocalScale(2f);

mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Black);

mat.setColor(“Diffuse”, ColorRGBA.Gray);

mat.setColor(“Specular”, ColorRGBA.Gray);

mat.setFloat(“Shininess”, 12);

teapot.setMaterial(mat);

rootNode.attachChild(teapot);



lightMdl = new Geometry(“Light”, new Sphere(10, 10, 0.1f));

lightMdl.setMaterial(assetManager.loadMaterial(“Common/Materials/RedColor.j3m”));

lightMdl.getMesh().setStatic();

rootNode.attachChild(lightMdl);



pl = new PointLight();

pl.setColor(ColorRGBA.White);

pl.setRadius(4f);

rootNode.addLight(pl);



DirectionalLight dl = new DirectionalLight();

dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());

dl.setColor(ColorRGBA.White);

rootNode.addLight(dl);



rootNode.attachChild(SkyFactory.createSky(

assetManager, “Textures/sky2.jpg”, true));



}[/java]

Not sure what I’m missing here… thanks for any suggestions.

And I apologize that there are no empty lines in the code… not sure how to add them!

The cube’s normals are sharp, so given the light’s direction, there shouldn’t be any specular highlight.

If you move the camera to the left until you hit the light’s reflection ray then you will see it

Thanks! Got it working. Weird how the direction parameters are all negative since the docs say it specifies the direction the light is coming “from.” I would expect it to be the opposite.