Translation with MouseTrigger?

Hey,



i need some help with the inputmanager and MouseTrigger function.

Right now, I rotate and zoom my node with the chaseCamera.

Furthermore I could program different translations (in x,y and z Axes) with the InputManager and just pressing keyes.

But I actually would like to have a Translation JUST with the right mouse button.

I already deactivated the right mouse button in chaseCamera and could define it new. But my problem is, i just can define it like that:



[java]inputManager.addMapping(“Translation”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

inputManager.addListener(analogListener, new String[]{“Translation”});



private AnalogListener analogListener = new AnalogListener() {

public void onAnalog(String name, float value, float tpf) {

if (name.equals(“Translation”)) {

// and here i need some help

}[/java]

so what happens in my opinion: I just can do another DEFINED Translation (like go 3 to the left and 5 up or something like that) WHEN the right mouse button is pressed.



But I wish I could somehow write my programm that the inputManager recognizes the path the mouse is doing pressed (or better just the start and end point (=released moment), so that the translation of the node could be like the user moves his mouse when the right button is pressed.



Can somebody help me with that? Or tell me what kind of class / listener / methode i could use or at least look at ??



I just can’t get the information when (or better at what Location) the mouse is pressed and released…



Thanks a lot !



hubble

RawInputListener or something like that.

onMouseMotionEvent

Thanks for your answer :slight_smile:

Yes, I think RawInputListener could help me…

But I still got some problems with that…

Am I right, that it only recognices the mouse movement in x and y (event.getDX(), event.getDY()) but not in z ?

So that I could only translate my object with ONE mouse button motion in 2 axes and not in 3 ?



Sorry if I bother you with so “easy” questions… I am trying now for 2 days different cameras, listeners and settings to get what i want, but it just does not work the way i want it :frowning:

hubble said:
Am I right, that it only recognices the mouse movement in x and y (event.getDX(), event.getDY()) but not in z ?

My mouse also only recognizes two axes, your moue is 3d? ^^ You have to do ray picking into the screen to get a z coordinate.

I’m not here to make propaganda for my own code snippets but have you tried this piece here?:

Drag demo

If you change line 47:

cube.rotate(-movement.y, movement.x, 0);

to:

cube.move(movement.x, movement.y, 0);

The box will be dragged instead of rotated based on the mouse movement while left is held down. Note tho you have to press T first to switch to the right mode :wink:

It’s not a matter of using certain classes, just store info and make changes based on the change between past info and current info in the right situations.

@normen… I just hoped there would be a class that could make it easier to me.

But thank you :slight_smile: so i will try ray picking.



@baalgarnaal yes thank you ! I already looked at that code. But unfortunately it would also only move on the x and y axis…

But mabye together with ray picking… !?

I will try it ! :slight_smile: