ChaseCamera with JMECanvas: How to integrate Keyboard Events?

Hi,



I have a problem with SwingGUI and JMECanvas event handling. (similar to /jmetest/util/JMESwingTest.java)

I use a chaseCamera for navigation on a sphere surface around my model. This works fine for mouse.



But there is a problem with keyboard events, and i solved this like discussed in this thread:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=7248.msg63929#msg63929



Here is my application as one-jar:

http://knecht.homelinux.net/ftp/ftp2/knecht/swarms_20080626_1057.jar

run with: (tested on linux and windows)

java -jar swarms_20080626_1057.jar


With left mousebutton pressed over the 3DCanvas you can navigate the scene, mouseWheel ist radius.

I now have a ChaseCamera which work with mouse, and a external event method that is triggered when a keyboard key is pressed. OK, so far so good.

What i want is to navigate in the same way like the mouse, but with keyboard keys. (Button w=get up,a=left,d=right,s=down, radius with +/- keys).

My question is, what is the best approach to do this ? generate and throw mouse events in some way ? make my own ThirdPersonMouseLook class with public rotateRight, rotateUp methods ?

i am not shure how to solve this problem, and have no idea how to come closer to an solution. Can anybody give me some hint what is a good way to solve this problem ?

thanks
Sebastian

PS: please report me if my one-jar build is not running on your os, it should be run with linux, win and mac.

I tested to solve this problem  with a little quick&dirty hack . . . more or less successfully



I set the methods rotateUp, rotateRight and rollIn from class ThirdPersonMouseLook to public (package com.jme.input.thirdperson) . The keyboard events are handled from awt, and this method is triggered.


   public void keyboardEvent(char c) {
      // Navigation mit dem Keyboard
      float amount=1f;
      if (  c == 'w' ) viewer.getChaser().getMouseLook().rotateUp(amount/100);
      if (  c == 's' ) viewer.getChaser().getMouseLook().rotateUp(-amount/100);
      if (  c == 'a' ) viewer.getChaser().getMouseLook().rotateRight(amount/50,0.01f);
      if (  c == 'd' ) viewer.getChaser().getMouseLook().rotateRight(-amount/50,0.01f);
      if (  c == '+' ) viewer.getChaser().getMouseLook().rollIn(-amount);
      if (  c == '-' ) viewer.getChaser().getMouseLook().rollIn(amount);
   }



That works not bad for rotating up/down and rollIn/rollOut. But if i do a rotateRight/rotateLeft my navigation is bucking very bad.

I'm not quite happy, but it seems to be a way. Or is this totaly crap and should never be done this way ?

Any ideas how to solve that in a better way ? Or a hint why its do a good job for up/down and rollIn/Out, but not for rotateRight/Left ?

i would be very thankful for some help . . .
Sebastian