XMLImporter: Load models w/o textures in "headless" mode

Hey there jME luminaries,



I'm running a copy of my scene graph within the server-side code so I can detect collisions and so forth.



I need to know the dimensions of things in the scene, naturally, so I'm loading my models with the XMLImporter – just like I do on the client side.



But there's no rendering thread, nor any visual expectations for these objects whatsoever.



I'm getting a bunch of these:



     [java] java.lang.NullPointerException
     [java]     at com.jme.scene.state.lwjgl.LWJGLTextureState.<init>(LWJGLTextureState.java:123)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     [java]     at java.lang.Class.newInstance0(Class.java:355)
     [java]     at java.lang.Class.newInstance(Class.java:308)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:813)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readTextureStateFromCurrent(DOMInputCapsule.java:830)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readRenderStateList(DOMInputCapsule.java:861)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavableArray(DOMInputCapsule.java:887)
     [java]     at com.jme.scene.Spatial.read(Spatial.java:1067)
     [java]     at com.jme.scene.Geometry.read(Geometry.java:874)
     [java]     at com.jme.scene.TriMesh.read(TriMesh.java:628)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:819)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:955)
     [java]     at com.jme.scene.Node.read(Node.java:679)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:819)
     [java]     at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:779)
     [java]     at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:75)
     [java]     at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:104)
     [java]     at org.danann.nimue.common.util.JmeEasyButton.createSpatial(JmeEasyButton.java:138)
    ...



I'd like to be able to get an instance of XMLImporter that will load the models without doing the rendering-related things that are giving me this error.

Cheers,

haruspex

I don't think you need to have the render states just to get the sizes of geometry? Though it's the loading of the model to get the geometry that's giving you fits.



You're getting the null pointer because when you load a model, it'll attempt to create the materials and texture states (and other states) from the display system, and there isn't a display system since you don't have any graphics rendering going on.



Probably will require some custom code on your part (or maybe you have geometry information in some sort of cache, so you don't need to load the entire model).

Starnick said:

You're getting the null pointer because when you load a model, it'll attempt to create the materials and texture states (and other states) from the display system, and there isn't a display system since you don't have any graphics rendering going on.


Yes, this is exactly the issue I was trying to describe.

As for custom code:  the approach that occurs to me is to enhance the XMLImporter (within jME) to allow me to obtain a "serverMode" instance that would simply skip any rendering-related work when it loads a model.