Headtracking with a Wiimote + Sensorbar

Hey everyone,

We are trying to get some headtracking working with jME3 and a Wiimote, like this:


Problem is that we are doing it wrong, but we don’t know what we’re doing wrong…


public void onIrEvent(IREvent arg0){

if(getCamera() == null){



getCamera().setLocation((new Vector3f(((float) arg0.getX(), (float) arg0.getY(), (float) arg0.getZ())));


Why does GetCamera in the Main class return null?

Probably because you didn’t start the application correctly. You have to do everything opengl related in the update loop of the application (simpleInitApp, simpleUpdate). Did you read the tutorials?

Good luck with this, looks interesting :slight_smile:

P.S. that onIrEvent probably arrives on another thread, make the call to the application safe like this:

[snippet id=“10”]

We used basicgame to initialize and added to the loop. We’ve dug through significant documentation. Because we stilll don’t understand why it doesn’t work (arg0 is from WiiUseJ), we figured it might help to hackz0r the joystick input itself for which someone made a new thred under this account, but time is not realy on our side as this is a school project and nobody has yet responded :frowning:

Two things, verify that arg0 is valid ? is it

then step two make sure that you call anything modifieng jmestuff in the opengl thread. Via the way norman said.

How is the scale of the getx,gety,getz ? it might be that there is a cange but only very minimal.

It works! (sorta)

We simply used a synchronized lock :’)

It works for our proof of concept but it insults the multithreading tutorial :blush: