1 16 17 package com.buchuki.ensmer.input.command.navigation; 18 19 import com.buchuki.ensmer.EnsmerManager; 20 import com.buchuki.ensmer.input.Accelerator; 21 import com.buchuki.ensmer.input.event.EnsmerInputEvent; 22 import com.buchuki.ensmer.input.event.Measurable; 23 import javax.media.j3d.Transform3D; 24 import javax.vecmath.*; 25 26 30 public class MoveCommand extends TransformCommand { 31 32 44 public MoveCommand(Transformable3D transformable, Accelerator accel, 45 float accelMod, Axis axis) { 46 super(transformable, accel, accelMod); 47 this.axis = axis; 48 } 49 50 58 public boolean execute(EnsmerInputEvent event) { 59 Transform3D transform = new Transform3D(); 60 float[] vector = new float[3]; 61 vector[axis.getIndex()] = getAcceleratedMagnitude((Measurable) event); 62 Vector3f vec = new Vector3f(vector); 63 transformVector(vec); 64 transform.set(vec); 65 Matrix4f matrix = new Matrix4f(); 66 transform.get(matrix); 67 updatePosition(matrix); 68 return true; 69 } 70 71 78 protected void transformVector(Vector3f vector) { 79 } 80 81 82 85 private Axis axis; 86 87 91 public enum Axis { 92 X(0), 93 Y(1), 94 Z(2); 95 96 99 private int arrayIndex; 100 101 107 Axis(int index) { 108 this.arrayIndex = index; 109 } 110 111 115 int getIndex() { 116 return arrayIndex; 117 } 118 } 119 } 120 | Popular Tags |