I seem to be having issues with setting the position of my camera. I copied the init code from SimpleGame but no matter what value I put in the loc vector my camera sits at 0,0,0. I also am confused to why my box is only visible when it’s z position is >0. I thought that the camera was looking down the -z axis and thus a position of -30 would be farther away than a position of -20. If I set the box’s position to negative anything it is behind the camera and the larger (positive) z position I give it the farther away it moves. I’m using FixedFramerateGame to drive my update/render loops. I have a GameStateManager and my main game state loaded through the manager. Here is my initialization code for my StandardGameState.
public class MainGameState extends StandardGameState {
private DisplaySystem display;
public MainGameState() {
display = DisplaySystem.getDisplaySystem();
Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
cam.setFrame(loc, left, up, dir);
cam.update();
Box b = new Box("Box", new Vector3f(0, 0, 10), 1f, 1f, 1f);
stateNode.attachChild(b);
b.setRandomColors();
stateNode.updateGeometricState(0.0f, true);
stateNode.updateRenderState();
System.out.println("Cam at:" + cam.getLocation());
System.out.println("Node at:" + b.getCenter());
}
The output from those println's are:
[java] Cam at:com.jme.math.Vector3f [X=0.0, Y=0.0, Z=25.0]
[java] Node at:com.jme.math.Vector3f [X=0.0, Y=0.0, Z=10.0]
I also tried creating a CameraNode and putting the camera in that. If I set the local translation to (0,0,-25) then I see my box far away but I've moved in the -z direction when I thought I should have moved in the +z direction to back away. Reversing the dir vector up in the camera initialization didn't effect what I was seeing, I still got the same box in the same place.