HI guys!
I try to rotate my spaceship model with the mouse. I added a MouseInputListener to my code like this:
mouse = new RelativeMouse("The Mouse");
mouseHandler = new InputHandler();
mouse.registerWithInputHandler(mouseHandler);
MouseInput.get().addListener(new MouseInputListener() {
public void onButton(int button, boolean pressed, int x, int y) {
System.out.println("Clicked " + button);
}
public void onMove(int xDelta, int yDelta, int newX, int newY) {
if(xDelta < 0) {
System.out.println("Moving left");
} else if(xDelta >= 0) {
System.out.println("Moving right");
}
if(yDelta < 0) {
System.out.println("Moving down");
} else if(yDelta >= 0) {
System.out.println("Moving up");
}
}
public void onWheel(int wheelDelta, int x, int y) {
System.out.println("Wheeled (" + wheelDelta + "," + x + "," + y + ")");
}});
}
Now I don't know how to add the rotation to the current local rotation. Let's say I have a simple box as a player node and I want to rotate it. How do I add the new rotation to the current? Something like
player.getLocalRotation().addLocal(new Quaternion(xDelta, 0, 0, 0));
doesn't work. Can someone please post the correct solution to this? I bet this questions came up 10245296 times before... :(