XBuf Updates - migrating to java & physics!

https://www.youtube.com/watch?v=X9rJwvzYoLA

Since some days I’ve joined the development of @david_bernard_31’s xbuf.
After obtaining the permission, I started migrating the loader from xtend to java8.

Now we have two loaders: the original xtend one, and the java loader whose temporary name is loader2 and will eventually replace the other one in the future.

While I was at it, I’ve also added the support for physics that now can be easily imported (only with loader2) from blender (similar of what i did for the ogre importer).

List of updated links


Blender Addon

DOWNLOAD from GitHub

loader2 (gradle)
repo:

maven { url "https://jitpack.io" }

dependency:

compile 'com.github.xbuf.jme3_xbuf:jme3_xbuf_loader2:0.8.1'

If you want to use it with V-HACD you’ll need to add it as dependency.



For now there is no updated documentation, however here there is a simple example of usage.

7 Likes

So does this mean it will be java8 only from now on? If so that’s unfortunate.

1 Like

Yes, if it were for me i would have ported it directly to java7… but there are people complaining about verbosity i don’t see :chipmunk:
It is not impossible that it will be ported to java7 though, actually there is just the 1% of code that is benefiting of the features of j8…

1 Like

Another neat work. You are wonderful.
Thanks a lot from you and @david_bernard_31. :heart:

1 Like

Good work.
Does it still require that you have the loader lib at runtime? or does it produce jme3.1 complient j3os?

1 Like

We are working/experimenting a more configurable loader. That should allow dev to say don’t “use additionnal lib for runtime” like jme3_xbuf_rt, jme3-bullet-vhacd. But in this case some feature will not be available. We are experimenting way to allow dev to easily customize the loader.

today size of jme3_xbuf_rt is 54K.

2 Likes

What features?

It’s not about the size really, it’s that the j3o you produce cannot be loaded by jme3 alone. That bothers me…

1 Like

Out if interest, what format is the physics stored in, is there some open source physics language that you are using?

1 Like

Nope, since both blender and jme uses bullet, i just export the rigidbodies settings from blender and then i rebuild them on jme.

1 Like

Right now there shouldn’t be any required runtime dependency for the scenes loaded with loader2 if you use default settings.
With the xbuf model key you can toggle various options, the ones that will need runtime dependencies are

  • useLightControl: that uses a custom light control, that does something useful i don’t remember.
  • useEnhancedRigidbodies: that will use a custom rigidbody that allows the spatial to be moved normally when not attached to physics spaces

And possibly more in the future.


I have to amend what i said yesterday do david, vhacd doesn’t require runtime dependencies for the generated j3o.

2 Likes

There was a custom skeleton control for bone animations, if I recall correctly. Maybe it’s not needed anymore.

1 Like

tried to test xbuf loader with this simple class:

import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import jme3_ext_xbuf.XbufLoader;


public class testXbuf extends SimpleApplication{



    @Override
    public void simpleInitApp() {
                flyCam.setEnabled(true);
        assetManager.registerLoader(XbufLoader.class,"xbuf");
        
                Spatial xbuf_scene=assetManager.loadModel("Models/Models/Players/Doha/Doha.xbuf");
        rootNode.attachChild(xbuf_scene);
                
                    /** A white, directional light source */ 
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun); 
    }

    public static void main(String[] args) {
        new testXbuf().start();
    }
}

but got some errors :anguished:

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NoClassDefFoundError: com/google/protobuf/ExtensionRegistryLite
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getConstructor0(Class.java:3075)
    at java.lang.Class.newInstance(Class.java:412)
    at com.jme3.asset.ImplHandler$ImplThreadLocal.initialValue(ImplHandler.java:117)
    at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
    at java.lang.ThreadLocal.get(ThreadLocal.java:170)
    at com.jme3.asset.ImplHandler.aquireLoader(ImplHandler.java:203)
    at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:255)
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:373)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:416)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:420)
    at mygame.testXbuf.simpleInitApp(testXbuf.java:22)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.ExtensionRegistryLite
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

there are some differences with your PhysicsLoaderTest.java

Spatial xbuf_scene=assetManager.loadModel(
 new XbufKey("models/physicsScene2/physicsScene2.xbuf"));

in my case assetManager.loadModel does not accept XbufKey …:no_mouth:

I am using jme3_xbuf_loader2.jar.

Should I build my jmonkeyengine from your github fork?

1 Like

No, it’s not required.
I think that the issue here is a missing dependency, try to add it by hand for now

compile  'com.google.protobuf:protobuf-java:2.6.1'
2 Likes

thanks for above tip.

now getting

java.lang.NoClassDefFoundError: com/jme3/physicsloader/impl/PhysicsLoaderModelKey
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at jme3_ext_xbuf.XbufLoader.load(XbufLoader.java:27)
    at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:259)
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:373)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:416)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:420)
    at mygame.testXbuf.simpleInitApp(testXbuf.java:22)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.jme3.physicsloader.impl.PhysicsLoaderModelKey
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 22 more

think it is because of
Spatial xbuf_scene=assetManager.loadModel("Models/Models/Players/Doha/Doha.xbuf");

1 Like

No, this shouldn’t happen, post your build.gradle

1 Like

I am in SDK

1 Like

Ah, then you have to include manually all the required libraries.
You can find the list under the dependencies section in build.gradle

Or you could try to use gradle with the sdk, there should be some kind of support for netbeans.

2 Likes

Hurrah… finally I could load a model :yum:
but seems there is no texture imported !?

it is a simple model with one material and one texture.(the model and texture are in “asset” directory)

and this is the main model in blender

@Riccardo can you please test the model ?
you can download model from here : https://drive.google.com/open?id=0B35eWZpi0dBoaXZlcWwtdTRZcGc

1 Like

It seems that the blender addons replace the paths to be relative to Textures/ inside your asset root.
I don’t know if there is a way to configure this. ( i didn’t touch this part of the code )
Open an issue on github repo, please.
For the moment, even thought it’s a bit annoying, you can move your texture in Textures/

1 Like

yep, it worked :slight_smile:
I will open an issue then. thanks
Does xbuf support normal map and specular map directly from blender ?

?

Anyway, i will test it myself.
Riccardo thanks a lot for your helps :heart:

1 Like