FlyBy camera and movementer with the center button of the mouse --Solved

Hello,



I’m using a SimpleApplication class in my game and I try to modify the FlyBy camera.



I wish to move the camera with the center button and not with the left button.

For what I have seen, the classic FlyCam is by default with the left button.



How can I modify that ?

( Should I drop the SimpleApplication on go for a more complex one ? )



Thanks in advance

Just switch the mappings, look at the source of SimpleApplication how the flyCam key mappings are set and switch the buttons you want switched.

Hello,

Thanks for the tip !



For those who had the some question as me, here is how I solved my problem :





[java]

private void customFlyByCameraMapping()

{

String[] mappings = new String[]{

“FLYCAM_Left”,

“FLYCAM_Right”,

“FLYCAM_Up”,

“FLYCAM_Down”,



“FLYCAM_StrafeLeft”,

“FLYCAM_StrafeRight”,

“FLYCAM_Forward”,

“FLYCAM_Backward”,



“FLYCAM_ZoomIn”,

“FLYCAM_ZoomOut”,

“FLYCAM_RotateDrag”,



“FLYCAM_Rise”,

“FLYCAM_Lower”

};



// Remove last mapping for the flyByCam

inputManager.removeListener( flyCam );



// Change the mappings we don’t want

inputManager.deleteMapping( “FLYCAM_RotateDrag” );

inputManager.addMapping( “FLYCAM_RotateDrag”, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE ) );



// Recreate the mapping for the flyByCam

inputManager.addListener( flyCam, mappings );

}

[/java]

1 Like

Hello,
I’m working with the new jme3 RC2 and had also the goal to modify the FlyByCamera-Mappings. I have used a similar customFlyByCameraMapping method and my approach was to call these method at the end of the simpleInitApp() method (in my SimpleApplication subclass). But I figured out that the FlyByCamera is controlled by a FlyCamAppState, which are not initialized until after simpleInitApp(). Now I call customFlyByCameraMapping method from the update() method. But I think thats really a bad hack, rather it is not necessary to change the mapping in each update round. Does anyone has a better approach to customize the FlyByCamera Mappings?

You could create an appstate and in that initialize do the setting of the flycam, then detach it. You could create your own fly cam, or you could copy/paste the flycamappstate, disable the original one and attach urs with other code in the initialize method.