Hello, I've built a chess scene where I want to be able to move and drag & drop pieces.. I've tried using com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior but it had 2 problems. First it was taking 100% of my CPU even when not touching any button and second we could not set the key we wanted to move around and they where not doing what I wanted..
I though it would have been fixed in the 1.3.1 but it was not so I first decided to get that CPU usage down. To do so I've built a second wakeupCriterion that is not using the "on next frame". When no useful key is pressed, I use that behavior so it won't wake up after that frame and thus won't request a new frame to be drawn. To know when no key is used, I simply return the state from my new KeyBehavior. I've copied some part from the old KeyNavigator but not much (well.. almost only the structure :) ) and now it does what I want it to do -- it's like walking in any direction, but relative to the chess game .. so pressing forward will get you running in the XY plane but not on the Z axis even if you look down.. anyway, the problem I now encounter is that after some time, CPU usage goes up to 100% and I don't see any more change. It took, before hanging (maybe a deadlock?), respectively, 732 frames, 166 frames, 1560 frames, 1080 frames .. and I've not understood what's wrong.. ..few minutes later.. Finally, I've found a way to overcome the problem. I've switched from getCurrentMillis to the high resolution java 3d timer and I've been able to go well over 10k frames repeatidly without any deadlock.. anyone can explain this ?? Now here is a real question : how can I do like the MouseTranslate behavior except that the piece will follow the mouse, from whatever I am looking. Using the MouseTranslate class, it follow the mouse as if I was from overhead .. I've had a hard time to get the screen shot I've included ;) Also, how can I "allow" an object to be moved or not without having to set the properties ? (Since that will be changed often -- between each user -- and I believe properties can't be changed when the scene is live). Well, that's it for now .. I include the screenshot I took and my 2 file for the keyboard behavior, if it's needed to find why it was locking with the getCurrentMillis and if someone need it =)
<<attachment: queen.jpg>>
KeyNavigatorBehavior.java
Description: Binary data
KeyNavigator.java
Description: Binary data