controlling a SceneGraphComponent with keyboard

Have jReality programming problems or questions? Post them here.
Post Reply
Posts: 5
Joined: Tue 14. Jan 2014, 12:08

controlling a SceneGraphComponent with keyboard

Post by andre.s7 » Tue 14. Jan 2014, 12:17


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? :)


Posts: 48
Joined: Mon 16. May 2011, 16:29

Re: controlling a SceneGraphComponent with keyboard

Post by benjamin.kutschan » Fri 7. Feb 2014, 19:11

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!

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?


I was able to handle translation about all 3 directions with this:

Code: Select all

m = camNode.getTransformation().getMatrix();
But, how can I handle rotation around z-axis? When I try like in the code above, it screws my perspective.

Post Reply