Lighting not staying in one place

Hey all,



Sorry, I'm quite new to all of this.  I'm having a strange problem.  I've created three boxes and one light.  Each box is rotating along a different axis, but it seems like there are three lights.  Each following a box in it's rotation and not affecting the others.  In other words, it looks like the lighting is being calculated for the first frame, but never again for any subsequent frames.  Am I missing something?







package jMETest;

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.scene.Node;
import com.jme.renderer.ColorRGBA;
import com.jme.light.LightNode;
import com.jme.light.PointLight;
import com.jme.scene.state.LightState;
import com.jme.scene.state.MaterialState;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.math.FastMath;
import com.jme.scene.shape.Box;

/*
 * A test game intended to practice using the SimpleGame
 */

public class Experiment extends SimpleGame {

   final float ROLLRATE  = FastMath.PI / 3.0f; // rad/sec
   final float PITCHRATE = FastMath.PI / 2.0f; // rad/sec
   final float YAWRATE   = FastMath.PI / 1.0f; // rad/sec
   
   private Quaternion roll, pitch, yaw;
   Box testBox1, testBox2, testBox3;
   
   final Vector3f zAxis = new Vector3f(0, 0, 1);
   final Vector3f yAxis = new Vector3f(0, 1, 0);
   final Vector3f xAxis = new Vector3f(1, 0, 0);
   
   public static void main(String[] args) {
      Experiment expGame = new Experiment();
      expGame.setConfigShowMode(ConfigShowMode.AlwaysShow);
      expGame.start();
   }
   
   @Override
   protected void simpleInitGame() {
      // create a box
      
      display.setTitle("Rotating Box");
      
      testBox1 = new Box("testBox", new Vector3f(0, 0, 0), 3.5f, 4.5f, 2.0f);
      testBox1.setModelBound(new BoundingBox());
      testBox1.updateModelBound();
      
      testBox2 = new Box("testBox2", new Vector3f(0, 0, 0), 3.5f, 4.5f, 2.0f);
      testBox2.setLocalTranslation(new Vector3f(20, 0, 0));
      testBox2.setModelBound(new BoundingBox());
      testBox2.updateModelBound();
      
      testBox3 = new Box("testBox3", new Vector3f(0, 0, 0), 3.5f, 4.5f, 2.0f);
      testBox3.setLocalTranslation(new Vector3f(-20, 0, 0));
      testBox3.setModelBound(new BoundingBox());
      testBox3.updateModelBound();
      
      MaterialState ms = display.getRenderer().createMaterialState();
      ms.setEmissive(new ColorRGBA(0f,.3f,0f,1));
      
      Node boxes = new Node("someBoxes");
      
      lightState.detachAll();
      rootNode.clearRenderState(lightState.getStateType());
      
      PointLight pl = new PointLight();
      pl.setLocation(new Vector3f(0, -50, 0));
      pl.setDiffuse(new ColorRGBA(1f, 1f, 1f, 1f));
      pl.setEnabled(true);
      
      LightState ls = lightState;
      
      LightNode ln = new LightNode("testLightNode");
      ls.attach(pl);
      ln.setLight(pl);
      
      boxes.attachChild(testBox1);
      boxes.attachChild(testBox2);
      boxes.attachChild(testBox3);
      
      boxes.setRenderState(ms);
      
      rootNode.attachChild(boxes);
      //rootNode.setRenderState(ls);
      boxes.attachChild(ln);
      boxes.setRenderState(ls);
      
      roll  = new Quaternion();
      pitch = new Quaternion();
      yaw   = new Quaternion();

   }
   

   protected void simpleUpdate(){
      
      float FRAME_ROLL_AMOUNT  = ROLLRATE  * tpf;
      float FRAME_PITCH_AMOUNT = PITCHRATE * tpf;
      float FRAME_YAW_AMOUNT   = YAWRATE   * tpf;
      
      roll.fromAngleNormalAxis(FRAME_ROLL_AMOUNT, zAxis);
      pitch.fromAngleNormalAxis(FRAME_PITCH_AMOUNT, xAxis);
      yaw.fromAngleNormalAxis(FRAME_YAW_AMOUNT, yAxis);
            
      testBox1.rotatePoints(roll);
      testBox2.rotatePoints(pitch);
      testBox3.rotatePoints(yaw);

      System.out.println("World Translation: " + testBox3.getWorldTranslation());
      System.out.println("Local Translation: " + testBox3.getLocalTranslation());
      System.out.println("Center:            " + testBox3.getCenter());
      
      rootNode.updateRenderState();
      rootNode.updateGeometricState(timer.getTime(), true);
   }
   

   protected void simpleRender() {
      display.getRenderer().clearColorBuffer();
      display.getRenderer().draw(rootNode);
      //rootNode.updateRenderState();
   }
   
   
}

What if you use setLocalRotation() instead rotatePoints()?

I think I'm confused as to the difference between the two.  Is there somewhere you can point me?

hmm i am not sure when rotatePoints is useful, i never used it.