XML scenegraph management


I've been playing around with JME's XML format and have taken a thourough look at JmeBinaryReader' source code to try and understand how JME's features are used through XML.

So far, i can load models, textures, materials and all, but it's not quite clear how to use some of the other features, specifically <areaclod> and the likes. I'm sure i must be missing something simple somewhere, but i will risk the following question: Is there a comprehensive sample JME XML scene available anywhere that demostrates the use of most if not all of the available features ?

Here's the XML file im'trying to load with <areaclod>. I'm sure i'm not using it correctly. Any clues ?

<?xml version="1.0" encoding="UTF-8" ?><scene>
 <node name="rootNode" rotation="0.0 0.7071068 0.7071068 0.0">


I found some errors:

1 - in your xml file , the attribute is not "trisppx" but must be called "trisppix"

2 - in JmeBinaryReader, there is a BUG in the method processAreaClod(AreaClodMesh areaClodMesh, HashMap attributes):

    private AreaClodMesh processAreaClod(AreaClodMesh areaClodMesh, HashMap attributes) {
        return areaClodMesh;

attributes.get("disttol") and attributes.get("trisppix") return a String that cannot be cast with a Float: that is why you have a ClassCastException.
I suppose the method processAreaClod() needs something like that:

3 - It works fine for me untill the line "parentNode=(Node) s.pop();" in the method "readEnd()" of JmeBinaryReader where i catch a ClassCastException. The problem should come from your xml file.


I have gained some experience fixing those "class cast from String bugs" in the xml loading classes, and here's what I'd say about this:

cj: 1. you are right about trisppix.

2. you are right about the source of the class cast problem, but your solution is not the "official" one. In the design of the xml/binary loading mechanism, those two are closely related. The correct way to fix this, as it occurs to me, is in XMLtoBinary.SAXConverter.processWrite(), where a huge block of else if's manages all attribute reading. somewhere there, an:

else if ("areaclod".equals(qName) && ("disttol".equals(att) || "trisppix".equals(att)))

has to be inserted.
3. This is a little bit of guesswork from me, but I think you are right with the "parentNode=(Node) s.pop();" thing again, cj. I think this is because there is a nested <mesh> tag inside the <areaclod> tag. Removing it results in loading and displaying the mesh correctly (as far as I can see), but without any TargetRecords, which doesn't surprise me, because there are none defined in the xml file. Anyway, I fixed the above in a modified version of XMLtoBinary, if you are interested, grab it here:
I am not a developer for jME, so I can't just put it into cvs, but maybe some dev reads this (maybe even Cep, who is responsible for all that xml/binary loading stuff), and looks at my fix, then it might show up in cvs. You can read about my motivation to research those class cast problems and about some more stuff I fixed in XMLtoBinary and JmeBinaryReader/Writer here:

Just from reading this the changes sound correct to me. Do you have a Test for this? Or would be willing to write one (e.g. writing a scene to file and load it again)?

Done. Pick it up here:


Note that there is skeletal animation in the loaded scene (that run.ms3d guy). To get that working, you will need my modified JmeBinaryReader and JmeBinaryWriter classes, as well. All three needed files are here:




See the thread linked in my last post for details on the xml/skeletal animation issues.

EDIT: Don't download JmeBinaryReader and JmeBinaryWriter! See http://www.jmonkeyengine.com/jmeforum/index.php?topic=2667.msg21431#msg21431 for details.

Since Cep published his fix for the skeletal animation problem, which is a lot better than mine, I removed my modified JmeBinaryReader/Writer classes, and adjusted XMLToBinary to work with Cep's fix instead of mine. All you need now to get areaclod meshes, skeletal animation, and bounding spheres (and probably most of the other stuff, but that's untested yet) to load from xml is my new XMLToBinary class, which you can find at the known location:


I wrote Cep an email about my changes to XMLtoBinary, if he thinks they are ok, they might end up in cvs soon.