Page 1 of 1
controlling a SceneGraphComponent with keyboard
Posted: Tue 14. Jan 2014, 12:17
by andre.s7
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!
Re: controlling a SceneGraphComponent with keyboard
Posted: Fri 7. Feb 2014, 19:11
by benjamin.kutschan
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:
Code: Select all
Component comp = ((Component) this.getViewingComponent());
comp.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent input) {
switch(input.getKeyCode()) {
case KeyEvent.VK_W:
But, how do I edit the transformation-matrix of the transformation, that is bound to the camera, to move for example on x-axis?
edit:
I was able to handle translation about all 3 directions with this:
Code: Select all
m = camNode.getTransformation().getMatrix();
m[3]-=0.1;
camNode.getTransformation().setMatrix(m);
But, how can I handle rotation around z-axis? When I try like in the code above, it screws my perspective.