Let me explain what I am trying to achieve.
I have managed to get Jmonkey code working on a Raspberry Pi with Jogl by all your help. I have few hardware peripherals attached to the RaspberryPi's GPIO port. For simplicity let us assume that they are buttons. I have written a JNI library and Multi threaded Java API to communicate with the GPIO of the Raspberry Pi. Any Java application can get the status of the button by calling this API and registering event handlers. I have tested this and it works in a stand alone Java app. Now I would like to use JMonkey and JOGL to develop a UI to interact with this API. i.e when a button is pressed in this external hardware - I would like to have on screen changes. i.e camera movement or object movement. How do I plug my events in to either JOGL input or Jmonkey input stream? |
Administrator
|
Hi
It would be fine to add GPIO support into NEWT Controller API (work in progress). Then, I'll be able to modify JMonkeyEngine to receive the events coming from these peripherals. If you're really in a hurry, you can directly integrate your libraries in JMonkeyEngine but it will be a bit tricky. Edit.: Look at the "core" module in the package "com.jme3.input". Edit.2: Implement the interface com.jme3.input.JoyInput in com/jme3/input/jogl for example. This is what I will do with NewtJoyInput in some weeks or months.
Julien Gouesse | Personal blog | Website
|
As I am new to the code base, please correct me if my observation is incorrect
Application Class instantiates the InputManager Class with a JoyInput . InputManager sets itself as the listener for the JoyInput or MouseInput In the Programmers application we call inputManager.addListener to register a listener to perform the programmers logic. So all event based logic happens inside InputManager. The MouseInput or JoyInput objects are passed to the InputManager from a JmeContext object. JmeContext is implemented by JoglContext/ AwtPanelsContext JoglContext gets mouse Input from ???? - I am not clear how the System Mouse details gets in to JMEContext -Is it just using AwtKeyInput Is it AwtPanelsContext that is providing the mouse and Keyboard inputs? I can include a new class MyNewtJoyInput inside jogl/com/jme3/input/jogl/ to read my GPIO ports -- this is probably what you are referring in your Edit 2? - If I implement my MyNewtJoyInput - how do I pass the joyInput Object to JoglContext.java or JmeContext.Java so that getJoyInput returns a value? How do I bind my NewtJoyInput to a Jmecontext - I am confused at this point. Please enlighten. |
Administrator
|
This method should return your object implementing JoyInput, it is not difficult :) But you should override it in this class. I can modify a bit JoglContext for you tonight so that it already contains the proper field.
Julien Gouesse | Personal blog | Website
|
This post was updated on .
I have done the changes, I have an external Jar which needs to be included in the build process, I am building using target build-engine.
Can I add the jars inside the lib folder used for compiling or do I need to modify the build.xml to specify the location of my jar. I initially added my jar inside engine/lib/jogl - but the build fails with class not found compilation error. I am unable to figure out how the class path is set. Edit: I modified nblibraries.properties file which was inside the lib folder - is this the correct way? |
Administrator
|
Put it into engine/lib/jogl and modify "-post-jar" in order to copy the JAR into /opt as I do for other JARs.
Julien Gouesse | Personal blog | Website
|
The method you suggested will copy the JARs after compilation. But my problem is slightly different, to build JMonkey I need this file, the jar file doesn't get included in the class path even though it is inside the lib folder. I mean my JoyInput implementation depends on classes which are not part of the JMonkey I have made a jar of those classes. So in order to compile JMonkey with my JoyInput implementation - I have to set this external jar in the class path. I looked in the build.xml but couldn't figure out a way, I then added the file name in nblibraries.properties - this allowed me to compile Jmonkey using ant build-engine . I wanted to know whether this is the correct method to include JARS in the classpath to get JMonkey engine built? This nblibrary looks like some netbeans file - I am not familiar with Netbeans/ ANT integaration.
|
Administrator
|
It would be better to copy the JAR in /lib/jogl as I suggested but maybe there is a missing step. Look at the instructions to install TUER development environment in Netbeans, it explains how to add a JAR to the classpath in this IDE. You may have to modify the Java library path too for JNI.
Julien Gouesse | Personal blog | Website
|
I have managed to complete the Joystick implementation. I have tested the button press events from buttons attached to the GPIO port of the PI, I am yet to test the axis movements.
On the PI, JMonkey code is taking 60% CPU cycle. I have a PI with 256MB memory with a split of 128MB for GPU and 128MB for CPU. Memory usage on the GPU was 60MB. Memory usage on the CPU was 105MB A simple app with a single Quad was receiving the buttons in human perceived real time. I used the HelloPhysics app - which had 180 objects. It took 30 seconds for a button press to reach the UI. I will do some more testing and report back. |
In reply to this post by gouessej
I am implementing the Joystick axis using a DPAD connected to the GPIO . I have only implemented the POV_X and POV_Y for time being.
I am creating the axis like this inside my JoyInput implementation this.povX = new DefaultJoystickAxis( getInputManager(), this, getAxisCount(), JoystickAxis.POV_X, "POV_x", false, true, 0 ); I have flycam enabled in Jmonkey App. When I press the buttons, the camera moves in the correct direction with speed. When I release the button press, the camera stops moving with speed, but it keeps moving in the same direction at a very minimal speed. I am confused as to what is causing the minor camera motion inspite of no events being generated. What does the isAnalog variable in the DefaultJoystickConstructor do - does it have any relation to this behavior? I have set it to false. When I press the button a JoyAxis event is created like this in the JoyInput implementation if (name.equalsIgnoreCase(RemoteButtons.DPadL.name())||(name.equalsIgnoreCase(RemoteButtons.DPadD.name()))) { value = -1f; } else { value = 1f; } if (name.equalsIgnoreCase(RemoteButtons.DPadL.name())||(name.equalsIgnoreCase(RemoteButtons.DPadR.name()))) { laxis = vjt.getAxis("POV_x") ; } else { laxis = vjt.getAxis("POV_y") ; } axevt = new JoyAxisEvent(laxis,value); listener.onJoyAxisEvent(axevt); |
Administrator
|
The word "analog" refers to JInput net.java.games.input.Component.isAnalog(). I think that the problem rather comes from the notion of "relative" and "absolute" data in your case, look at another boolean.
Julien Gouesse | Personal blog | Website
|
The other boolean isRelative is not used any where in the code, I made a reference search for the method JoystickAxis.isRelative () method and also for DefaultJoystickAxis.isRelative() - both brought no results for this method.
However is isAnalog is having 1 reference. I get the camera motion even after a button press has been released irrespective of the isAnalog values or isRelative values (I have tried all combinations for these two) - it doesn't seem to have any effect. |
Free forum by Nabble | Edit this page |