Hello!
I'd like to rotate a SceneGraphComponent using the Arrow-Keys of the keyboard. In the tutorial I've only found help for creating a Tool from AbstractTool that handles Mouse input.
Can someone put me on the right track? :)
Thanks!
controlling a SceneGraphComponent with keyboard
-
- Posts: 48
- Joined: Mon 16. May 2011, 16:29
Re: controlling a SceneGraphComponent with keyboard
Maybe this helps...
goetz wrote:Hello,
I wrote a small application which uses a stand-alone-viewer, just like in your tutorial ViewerFromScratch, but is there any way to use keyboard-input for the avatar-navigation (like WASD-keys for navigation with fixed y-axis)? I'm not able to find any hint on this topic but it works fine in the applications, that uses the vr-viewer...
thx for your help!
edit:
I was able to add a keylistener in my viewer-class, like this:
But, how do I edit the transformation-matrix of the transformation, that is bound to the camera, to move for example on x-axis?Code: Select all
Component comp = ((Component) this.getViewingComponent()); comp.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent input) { switch(input.getKeyCode()) { case KeyEvent.VK_W:
edit:
I was able to handle translation about all 3 directions with this:
But, how can I handle rotation around z-axis? When I try like in the code above, it screws my perspective.Code: Select all
m = camNode.getTransformation().getMatrix(); m[3]-=0.1; camNode.getTransformation().setMatrix(m);