A very annoying bug with Canvas3dPanel. The
registerKeyboard()
method does not accept a Canvas3dPanel, and it can't be cast to a Canvas3D. Is there another way to add a key Listener?
As you already discovered, there's a getCanvas() method, that returns the Canvas3D. Of course it can't be casted to Canvas3D, since it extends Panel. Canvas3DPanel and Canvas3DJPanel both implement the Canvas3DWrapper interface, which has the getCanvas() method. I guess you're still using an older release. In the current release (for quite a while) there are the registerKeyboard/registerMouse methods overloaded to also take a Canvas3DWrapper (Canvas3DPanel/Canvas3DJPanel). So there should not be a problem.
And I can't understand, why this should be a "big FAT bug". It's not bigger or fatter than others. This is not even a minor bug, but misusage. And please always check, if a bug is fixed in the most recent version.
By the way, when I tty this:
this.getInputManager().registerKeyboard(this.getInputManager().getKeyboard());
I get this:
Exception in thread "Thread-4" java.lang.NullPointerException
at org.xith3d.utility.input.InputManagerImpl.update(InputManagerImpl.java:325)
at org.xith3d.render.loop.RenderLoop.updateInputDevices(RenderLoop.java:527)
at org.xith3d.render.loop.RenderLoop.loopIteration(RenderLoop.java:562)
at exodus.game.threeD.worlds.zero.two.Exodus3dWorld.loopIteration(Exodus3dWorld.java:90)
at org.xith3d.render.loop.RenderLoop.nextIteration(RenderLoop.java:792)
at org.xith3d.render.loop.RenderLoop.run(RenderLoop.java:867)
at java.lang.Thread.run(Unknown Source)

Of course you get this. Why is this astonishing? If you haven't registered a Keyboard, this method of course returns null. The JavaDoc even tells this. And registering a null Keyboard throws an NPE. That's it.
Also, this
this.getInputManager().registerKeyboard(this.getInputManager().getKeyboards().get(0));
gives me this
Exception in thread "AWT-EventQueue-1" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
at java.util.Vector.get(Unknown Source)
at java.util.Collections$UnmodifiableList.get(Unknown Source)
at exodus.game.threeD.worlds.zero.two.Exodus3dWorld.prepareHeiarchy(Exodus3dWorld.java:108)
at exodus.game.threeD.worlds.zero.two.Exodus3dWorld.<init>(Exodus3dWorld.java:96)
at exodus.game.games.zero.two.Exodus.world(Exodus.java:98)
at exodus.game.games.zero.two.Exodus.initiateGUI(Exodus.java:80)
at exodus.game.games.zero.two.Exodus.<init>(Exodus.java:48)
at exodus.game.awt.zero.two.ExodusTitleScreen.logIn(ExodusTitleScreen.java:286)
at exodus.game.awt.zero.two.ExodusTitleScreen$6.actionPerformed(ExodusTitleScreen.java:159)
at exodus.awt.components.XawtButton.processMouseEvent(XawtButton.java:68)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Yes, of course.
It just hit me that the getKeyboard() method is showing up null because I haven't registered one. Is this the case, or am I off track?
You might be off track

.
this might be it:
this.getInputManager().registerKeyboard(
this.getInputManager().registerKeyboard(canvas3d.getCanvas()));
Whoops, that doesn't make any sense. I meant this:
this.getInputManager().registerKeyboard(canvas3d.getCanvas());
Exactly. Even if you're able to directly add instances of Canvas3DWrapper (Canvas3DPanel/Canvas3DJPanel) to these methods in the current version.
I've added more declarative NPEs to the registerKeyboard() and registerMouse() methods, so that people can directly read the cause of the Exception.
Make sure you've added the 3D peer to canvas and added the canvas to the view. Then, get the 3D peer from canvas and the awt component (I think the component is created when you create the 3d peer) to add the input listener. This is how I add a plain awt key listener.
canvas.get3DPeer().getComponent().addKeyListener(localInputListener);
This is not necessary. You never have to handle the CanvasPeer creation on your own. This is the way it was handled in the ancient xith times

. Nowadays you just invoke one of the create*() methods of Canvas3DFactory and you will get a fully initialized Canvas3D, which of course includes a fully initialized CanvasPeer. The same for Canvas3DPanel/Canvas3DJPanel. They both only need to be instatiated and they are fully set up.
I hope, this clears everything up a bit.
Marvin