Hello,
recently I have come accross some problems concerning jme3 used with OSGI framework.
I found some jme3 design features that really made my goals hard to achieve.
But let's start from the beggining
First problem
I write an application that uses jme3 and lwjgl. I downloaded jme3 (nightbuild from 10.08.2010) engine and the latest lwjgl library (version 2.5).
Because OSGI is based on the idea of bundles (each bundle is a separate jar file in the end and a separate project in eclipse during development) I decided to split my application so that each bundle can be replaced with the newest version separately.
And thus I hava a bundle named lwjgl and bundle named jMonkeyEngine. The problem is that I want to keep the native libraries in lwjgl bundle, so that I can replace the graphic engine only.
Current implementation do not allow it. The reason is simple.
I call the method:
public void start(JmeContext.Type contextType);
from Application class.
This method is trying to create JmeContext using this piece of code:
context = JmeSystem.newContext(settings, contextType);
The class JmeSystem has only static methods.
In the newContext method it calls the initilialize method and inside a method that actually loads the native libraries.
Natives.extractNativeLibs(getPlatform(), settings);
As you may see it is a static method of the Natives class. It calls the following method:
protected static void extractNativeLib(String sysName, String name) throws IOException;
and it performs the following:
String path = "native/"+sysName+"/" + fullname;
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
And the second line is the core of my problem.
Each bundle has its own classloader and the method getResourceAsStream() loads only from the current jar file which is ... jMonkeyEngine.
In this implementation I can see no way to load the natives from lwjgl bundle.
Is there any chance to improve it so that the loading of natives could me more customizable ?
I could do with a simple interface with a method loading the inputStream which I would be able to provide from outside.
Second problem:
I wanted to have my application more customizable. For example I do not need to load all the default assets I totaly want to use my own. But the current implementation of Application class makes it hard to change that,
It loads these assets in a private method so I cannot alter it when extending this class.
This is the method:
private void initAssetManager(){
assetManager = JmeSystem.newAssetManager();
}
and it creates the manager that loads the default assets. And if I wanted to use my own implementation of the asset manager I simply have to wait first for this manager to load itself along with the data.
Is there any chance to make the methods protected instead of private ?? I mean all the methods that actually initialize something in the Application class.
Third problem:
This is the last one and most trivial.
I use the MouseAxisTrigger class and it has the private parameter:
private boolean negative;
but there is no getter to it :)
I can get it using reflection but it really complicates the code.
OK I hope that at least a couple of people made it to the end :D
If something is unclear (and I'm almost sure it will be) ... just ask.
Best regards,
Kaelthas