Sphere litten on the wrong side

Hi,



I'm having a problem with a spotlight that lit a sphere on the opposite face, I hope it's nothing big, however, I don't really know what's wrong with my code:



my shpere is created this way (lambda is a dimensional constant, myDungeon is the main spatial Node attach to rootNode)


private void CreateSphere(){
      Sphere mySphere = new Sphere("sphere", new Vector3f(12*lambda, 4*lambda,24*lambda),3*lambda,3*lambda,5);
      MaterialState ms = display.getRenderer().createMaterialState();
        ms.setColorMaterial(MaterialState.CM_AMBIENT_AND_DIFFUSE);
        ms.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
      myDungeon.attachChild(mySphere);
   }



my lights are like this


private void InitLights(){
      
      
      
      PointLight light = new PointLight();
      light.setAttenuate(true);
      light.setQuadratic(0.05f/(lambda*lambda));
      light.setDiffuse(ColorRGBA.red);
      light.setEnabled(true);
      light.setLocation(new Vector3f(120.0f*lambda,100.0f*lambda,180.0f*lambda));
      lightState.detachAll();
      lState = display.getRenderer().createLightState();
      lState.attach(light);
      lState.setEnabled(true);

      lNode = new SimpleLightNode("light ceiling", light);
      lNode.setLocalTranslation(new Vector3f(12.0f*lambda,2.0f*lambda,18.0f*lambda));

      rootNode.attachChild(lNode);
      rootNode.setRenderState(lState);
      rootNode.updateRenderState();
      
      
   }



and i call CreateSphere() before InitLights()

on the picture you can see the light source (point light) is in the right bottom corner, and the sphere is up left, and this is the upper left half of the sphere which is litten

[IMG]http://img218.imageshack.us/img218/443/wronglightingjq5.th.jpg

Thanks,
Adrien

Actually, that looks like there are 2 lights in the scene; your spot light and a directional light.  Make sure you do lightState.removeAll() before adding any new lights…

I’ve just tried to use this ‘removeAll()’ command, unfortunately, I cannot find it as a method of LightState http://www.jmonkeyengine.com/doc/com/jme/scene/state/LightState.html, the closest thing that appear to do that is ‘detachAll()’ which I’m already calling, or maybe I misunderstood



if you look at this second picture (light has been intensified), it’s like the light is not reflected correctly, what do you think?



[img=http://img228.imageshack.us/img228/2456/wronglighting2ui6.th.jpg]

i'm sure you tried lightstate.detachAll() already ?

Yep,

even twice …

there's only one light in my code, plus the only red one is the point light, the wrong side of the sphere MUST be lighten by the point light, no? I mean it could be an option that I misconfigurated?

Ok I think I know where the problem comes from,

private void InitRenderers(){
      CullState cs = display.getRenderer().createCullState();
      cs.setCullMode(CullState.CS_FRONT);

      rootNode.setRenderState(cs);

      ZBufferState zs = display.getRenderer().createZBufferState();
      zs.setEnabled(true);
      zs.setFunction(ZBufferState.CF_LEQUAL);

      rootNode.setRenderState(zs);
   }



probably one of the two

I confirm, I forgot to activate the CullState, when using setEnabled(true), suddenly it works !!