Problem with XMLImporter and/or HottBJ Exporter from Blender

Hello Forum,



I am new here so it could be that the question is stupid but I have trying to load a model created with Blender 2.48

into JME (updated a only a few days ago) using the HottBJ (0.3d) jme-xml exporter in Blender as described on these pages. On JME side I used the XMLImporter also following the tuturials here.

It works fine to import the objects, they are all displayed correclty.

However, at two points strange behaviour occurs which I am unable to understand, so maybe you can help:


  1. Objects (e.g. spheres) exported from Blender have the wrong bouding volumes when scaled in blender. The bounding

    volume has the radius the Blender sphere has upon creation (e.g. 3.0). If I scale the objects in Blender ('s') and export

    them the bounding volumes in JME are still '3.0'. Any JME updating of the model bounds will not correct this.

    The code is kind of



                // Loop over  loaded model

                List<Spatial> children = new LinkedList<Spatial>(n.getChildren());

                    for (Spatial child:children)

                    {

                        System.out.println("PBound for "+child.getClass()); => Gives TriMesh

                        child.setModelBound(new BoundingSphere()); => Without this the bound is NULL

                        child.updateModelBound();

                        parentNode.updateModelBound();

                        System.out.println("  IS "+child.getWorldBound()); => Gives wrong radius

                  }

                  // Model or world bounds result in the same

     

          // A Manual sphere like this works fine

            Sphere s = new Sphere("MSphere", 20, 20, 5);

            s.setModelBound(new BoundingSphere());

            s.setLocalTranslation(new Vector3f(0,0,5));

            s.updateModelBound();

            System.out.println("Bm="+s.getWorldBound());






  2. A similar issue arises when putting (image) textures on the objects in blender. What I want is to

    simply put a 'wall' texture around a sphere or cube. Nothing fancy.

    I have been following all tuturials I could find on these webpages, e.g. creating the UV texture, the cube projected one

    or a plain image.

    Two possibilites arise:

    a) Using e.g. the UV texture tuturial: The exporter refused to export the object

    b) Just mapping a texture to the object (assign texture in blender from image). This texture will be loaded

    in JME but it is shown very strange. I dont actually know what it is doing, but it looks as if the texture is

    mini and repeated endlessly, ending up in a fuzzy jittering brown ball.



    Funnily it is then also not possible to assign a texture created and loaded in JME to any object loaded from

    the XMLImporter. Assigning a texture to a newly created object works fine though.



    Code is like this:

                                      TextureState ts = renderer.createTextureState(); 

                                        ts.setEnabled(true); 

                                        ts.setTexture(TextureManager.loadTexture("wall.jpg", 

                                                Texture.MinificationFilter.BilinearNearestMipMap, 

                                                Texture.MagnificationFilter.Bilinear)); 



                                        Sphere s = new Sphere("Sphere", 30, 30, 4); // New local sphere for testing

                                        s.setLocalTranslation(new Vector3f(0,0,-40));

                                        s.setRenderState(ts);  // works fine

                                       

                                        // Child is sphere/TriMesh element loaded from XML Importer

                                        child.setRenderState(ts); // makes fuzzy mini texture





    I would be grateful if someone could point out where I go wrong. It would be also helpful if you

    could post a blender save file which allows the texture and bounding box importing with HottBJ. This

    could serve as a testcase to my code.



    I am also willing to use a different import/export mechanism but the XML via HOTTBJ looked like a very

    neat way of importing the data so I thought to go with it.




I must be brief right now, but it sounds like:


  1. Apply your transform/scale changes in Blender after changing scale.  Ctrl-A, I think.  If you don't do this then the exporter will use the unscaled value;


  2. How are you applying the uv map?  Sounds like there is a problem in your setup in Blender – most likely with linking the map to the mesh.

Thank you for your answer. The first problem is indeed fixed. The second is described below in more detail.


  1. Apply your transform/scale changes in Blender after changing scale.  Ctrl-A, I think.  If you don't do this then the exporter will use the unscaled value;



    Ctrl-A does fix the scaling. I thought the exporter or blender would do this but I am ok with this workaround.


  2. How are you applying the uv map?  Sounds like there is a problem in your setup in Blender – most likely with linking the map to the mesh.



    I exactly follow the guide on e.g. http://jmonkeyengine.com/wiki/doku.php?id=howto_jme2_and_blender2.48

    Basically it tells me to do:
  • Go to edit mode
  • unwrap object to cube projection
  • Goto UV image editor and load image file (I load JPG - is this ok?)
  • Set Material Options to

Sorry for finding this a few days after you posted – I've got competing priorities going on right now and so I'm sort of slow in the jME world right now. 



I'm glad that # 1 was fixed.



As for # 2: If you run Blender from a console or command window and run the exporter you'll be able to see some error information about why the exporter is refusing the model w/applied uv map.  If you do that, post the output here.  Other than that, you can either post a link to your model and uv pic here, or pm me the info, and I'll take a look at it and see if I can determine what is wrong – in either your model or the documentation.

Hello



I'm also new here. . I'm having some problems with loading models with exported physics (jME Physics2).

Using blender and HottBj Exporter I exported some model. After that i loaded it in my code, added some Dynamic/StaticPhysicsNode and exported. But now, while trying to import that model with XMLImporter i'm getting this error

java.io.IOException: java.lang.NullPointerException

   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:1143)

   at com.jme.scene.Node.read(Node.java:674)

   at com.jmex.physics.PhysicsNode.read(PhysicsNode.java:633)

   at com.jmex.physics.DynamicPhysicsNode.read(DynamicPhysicsNode.java:254)

   at com.jmex.physics.impl.ode.DynamicPhysicsNodeImpl.read(DynamicPhysicsNodeImpl.java:450)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:986)

   at com.jme.util.export.xml.DOMInputCapsule.readSavable(DOMInputCapsule.java:946)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:75)

   at com.jme.util.export.xml.XMLImporter.load(XMLImporter.java:104)

   at gProject0.samples.PhysicsXML.simpleInitGame(PhysicsXML.java:54)

   at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:545)

   at com.jme.app.BaseGame.start(BaseGame.java:74)

   at gProject0.samples.PhysicsXML.main(PhysicsXML.java:63)

Caused by: java.lang.NullPointerException

   at com.jmex.physics.PhysicsCollisionGeometry.readPhysicsNodeFromInputCapsule(PhysicsCollisionGeometry.java:126)

   at com.jmex.physics.util.binarymodules.BinaryPhysicsBoxModule.load(BinaryPhysicsBoxModule.java:50)

   at com.jme.util.export.binary.BinaryClassLoader.fromName(BinaryClassLoader.java:125)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableFromCurrentElem(DOMInputCapsule.java:981)

   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:1128)

   … 12 more





I've found that i'm also getting this error without using blender exported objects (see below piece of code)



      PhysicsSpace pSpace = PhysicsSpace.create();

      pSpace.setupBinaryClassLoader(BinaryImporter.getInstance());

      

      DynamicPhysicsNode pNode = pSpace.createDynamicNode();

      Box box = new Box( "some_box", new Vector3f(), 5, 0.25f, 5 );

      pNode.attachChild(box);

      pNode.generatePhysicsGeometry();



      File file = new File("/home/users/pablo/phys_model.xml");

      try {

         file.createNewFile();

         XMLExporter.getInstance().save(pNode, file);

         Node tmpNode = (Node)XMLImporter.getInstance().load(new URL("file:/home/users/pablo/phys_model.xml"));

      } catch (IOException e) {

         e.printStackTrace();

      }

Sources of JME2 and jME Physics2 are up to date (taken today from svn). All tests inside jME2 and jME Physics 2 are working great. How can i do it correctly?? I will be grateful for help :slight_smile:





PS:

Sorry for my english.

jBob said:

....
- Set Material Options to

As your issue has nothing to do with HottBJ, may I suggest that you open a new Topic, especially since ToM is still working the issue which is the proper subject of this topic?



To the matter at hand, you have the stack trace and you have the XML at-hand to view, so you can dig in and find out what it is that is expected but is not being stored.

Quote:
Hello

I'm also new here. . I'm having some problems with loading models with exported physics (jME Physics2).
Using blender and HottBj Exporter I exported some model. After that i loaded it in my code, added some Dynamic/StaticPhysicsNode and exported. But now, while trying to import that model with XMLImporter i'm getting this error

java.io.IOException: java.lang.NullPointerException
   at com.jme.util.export.xml.DOMInputCapsule.readSavableArrayList(DOMInputCapsule.java:1143)
   at com.jme.scene.Node.read(Node.java:674)...

PS:
Sorry for my english.
[/quote]

Thank you guys for your excellent help !!!

I finally got the texture to load. I post what I needed to minimally do to export the texture

so that others might be able to repeat



TO EXPORT BLENDER 2.48 TEXTURE TO JME USING HottBJ XML EXPORTER:

"Space" -> Add Mesh -> "UV Sphere"

"Tab" to go to "Edit Mode"

Mesh Menu->Unwrap-> Any (e.g. Cube Projection)

Panel Shading & Material: View Link & Piplines  -> "Add New"

Panel Shading & Material: Texture View -> "Add New"

Panel Shading & Material: Texture View -> Map Input Panel -> "UV"

Panel Shading & Material: Material -> enable "Texface" and "Shadeless"

Panel Texture (F6): Texture View -> Texture Type "Image"

Panel Texture (F6): Image -> Load (choose JPG and set Relative Path )

F12 To verify rendering

File Menu -> Export JME-XML (HottBJ exporter) [Enable "Scene" & "Silently" for convenience] -> "export"

            (you have to probably resize the panel window to fit the exporter widget)

          -> Choose filename and "write xml"

I, and others, use relative texture resources constantly and don't need hard-coding to do it, let alone 30 lines of a custom resource ResourceLocator impl.  See the API and source code for XMLImporter and you'll see that it adds its own relative ResourceLocator automatically.  If that is not working for some situation, supply a test case and I'll fix it.  Specifically, both the provided XmlWorld.java and XmlAnimator.java classes have been used hundreds of times to automatically pull in relative texture files with no extra resource locator work.



I don't see how it could be useful to other new people to post the "minimal Java part to load the HottBJ XML exporter from Blender", when "this method basically doesn't do anything it might work without".