Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: Java  |  size: 2.29 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.     Node playerNode;
  3.     Node player;
  4.     Quaternion derp = new Quaternion();
  5.     Quaternion rodarX = new Quaternion();
  6.     Quaternion rodarY = new Quaternion();
  7.     Quaternion rodarZ = new Quaternion();
  8.    
  9.   @Override
  10.   public void simpleInitApp() {
  11.     setupKeys();
  12.     cam.setLocation(new Vector3f(0, 10, 0));
  13.     cam.lookAt(new Vector3f(0, -1, 0), Vector3f.UNIT_Y);
  14.    
  15.     flyCam.setEnabled(false);
  16.    
  17.     playerNode = new Node();
  18.     player = new Node();
  19.     rootNode.attachChild(playerNode);
  20.     playerNode.attachChild(player);
  21.    
  22.     (...)
  23.  
  24.   }
  25.  
  26.     @Override
  27.   public void simpleUpdate(float tpf) {
  28.         Vector3f vec = cam.getDirection();
  29.         //System.out.println(vec.getX());
  30.         //System.out.println(vec.getY());
  31.         //System.out.println(vec.getZ());
  32.         System.out.println(derp.getX());
  33.         System.out.println(derp.getY());
  34.         System.out.println(derp.getZ());
  35.   }
  36.    
  37.     private void setupKeys() {
  38.         inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
  39.         inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
  40.         inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
  41.         inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
  42.  
  43.         inputManager.addListener(analogListener, new String[]{ "Left", "Right", "Up", "Down" });
  44.     }
  45.      
  46.     private AnalogListener analogListener = new AnalogListener() {
  47.         public void onAnalog(String name, float value, float tpf) {
  48.                 if (name.equals("Right")) {
  49.                     Vector3f pos = cam.getLocation();
  50.                     cam.setLocation(new Vector3f(pos.x+tpf*3, pos.y, pos.z));
  51.                 }
  52.                 if (name.equals("Left")) {
  53.                     Vector3f pos = cam.getLocation();
  54.                     cam.setLocation(new Vector3f(pos.x-tpf*3, pos.y, pos.z));
  55.                 }
  56.                 if (name.equals("Up")) {
  57.                     Vector3f pos = cam.getLocation();
  58.                     cam.setLocation(new Vector3f(pos.x, pos.y, pos.z-tpf*3));
  59.                 }
  60.                 if (name.equals("Down")) {
  61.                     Vector3f pos = cam.getLocation();
  62.                     cam.setLocation(new Vector3f(pos.x, pos.y, pos.z+tpf*3));
  63.                 }
  64.         }
  65.     };
  66. }