but I want to rotate via the right mouseButton, not the left. So I tried to delete the mapping in the inputManager in simpleInitApp().
Turns out that doesn’t work, because the mappings of the flyByCam are not yet initialized when simpleInitApp() is called.
Next I tried to extend the FlyByCam and change the mapping in the new class. But that’s not possible either, because I can’t set the cam in FlyCamAppState, since the setCamera method in there isn’t public.
I’m sure there’s an obvious solution to this, but how? Do I have to implement my own cam with its own appState?
And bonus question: do you use the default FlyByCam in your project? Or do you implement your own?
inputManager.addMapping("FLYCAM_Forward", new KeyTrigger(KeyInput.KEY_NUMPAD8));
inputManager.addMapping("FLYCAM_Backward", new KeyTrigger(KeyInput.KEY_NUMPAD5));
inputManager.addMapping("FLYCAM_StrafeLeft", new KeyTrigger(KeyInput.KEY_NUMPAD4));
inputManager.addMapping("FLYCAM_StrafeRight", new KeyTrigger(KeyInput.KEY_NUMPAD6));
inputManager.addMapping("FLYCAM_Lower", new KeyTrigger(KeyInput.KEY_NUMPAD7));
inputManager.addMapping("FLYCAM_Rise", new KeyTrigger(KeyInput.KEY_NUMPAD9));
inputManager.addMapping("FLYCAM_Left", new MouseAxisTrigger(MouseInput.AXIS_X, true), new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("FLYCAM_Right", new MouseAxisTrigger(MouseInput.AXIS_X, false), new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("FLYCAM_Up", new MouseAxisTrigger(MouseInput.AXIS_Y, false), new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("FLYCAM_Down", new MouseAxisTrigger(MouseInput.AXIS_Y, true), new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addListener(application.getFlyByCamera(), new String[]{
"FLYCAM_Forward", "FLYCAM_Backward", "FLYCAM_StrafeLeft", "FLYCAM_StrafeRight",
"FLYCAM_Lower", "FLYCAM_Rise", "FLYCAM_Left", "FLYCAM_Right", "FLYCAM_Up", "FLYCAM_Down"});
}
loopies, thanks. But when (from which method) do you call this code? The mappings for the flyByCam are not registered when initSimpleApp() is called, so the deleteMapping-calls do not work then.
A tongue-in-cheek solution:
Step 1: Open FlyBycam.java
Step 2: Ctrl-A
Step 3: Ctrl-C
Step 4: Open a new file MyFlyCam.java
Step 5: Ctrl-V
Step 6: Change class name to MyFlyCam.java and constructor
Step 7: Change mappings as needed.
…or whatever… (Actually, the SDK will let you copy and rename at the same time I think in the refactor menu.)
FlyByCam is only useful for demos and tests as it rapidly becomes unuseful for games where you are more likely to want to control a player object instead of the players eyeball. Any real game will eventually need its own camera implementation. Might as well start early, I say.
@pspeed said:
A tongue-in-cheek solution:
Step 1: Open FlyBycam.java
Step 2: Ctrl-A
Step 3: Ctrl-C
Step 4: Open a new file MyFlyCam.java
Step 5: Ctrl-V
Step 6: Change class name to MyFlyCam.java and constructor
Step 7: Change mappings as needed.
…or whatever… (Actually, the SDK will let you copy and rename at the same time I think in the refactor menu.)
FlyByCam is only useful for demos and tests as it rapidly becomes unuseful for games where you are more likely to want to control a player object instead of the players eyeball. Any real game will eventually need its own camera implementation. Might as well start early, I say.
Yeah, just Ctrl-C FlyCam.java itself, then Ctrl-P it to the package you want it in, then press “OK” to refactor.