Node playerNode;
Node player;
Quaternion derp = new Quaternion();
Quaternion rodarX = new Quaternion();
Quaternion rodarY = new Quaternion();
Quaternion rodarZ = new Quaternion();
@Override
public void simpleInitApp() {
setupKeys();
cam.setLocation(new Vector3f(0, 10, 0));
cam.lookAt(new Vector3f(0, -1, 0), Vector3f.UNIT_Y);
flyCam.setEnabled(false);
playerNode = new Node();
player = new Node();
rootNode.attachChild(playerNode);
playerNode.attachChild(player);
(...)
}
@Override
public void simpleUpdate(float tpf) {
Vector3f vec = cam.getDirection();
//System.out.println(vec.getX());
//System.out.println(vec.getY());
//System.out.println(vec.getZ());
System.out.println(derp.getX());
System.out.println(derp.getY());
System.out.println(derp.getZ());
}
private void setupKeys() {
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
inputManager.addListener(analogListener, new String[]{ "Left", "Right", "Up", "Down" });
}
private AnalogListener analogListener = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("Right")) {
Vector3f pos = cam.getLocation();
cam.setLocation(new Vector3f(pos.x+tpf*3, pos.y, pos.z));
}
if (name.equals("Left")) {
Vector3f pos = cam.getLocation();
cam.setLocation(new Vector3f(pos.x-tpf*3, pos.y, pos.z));
}
if (name.equals("Up")) {
Vector3f pos = cam.getLocation();
cam.setLocation(new Vector3f(pos.x, pos.y, pos.z-tpf*3));
}
if (name.equals("Down")) {
Vector3f pos = cam.getLocation();
cam.setLocation(new Vector3f(pos.x, pos.y, pos.z+tpf*3));
}
}
};
}