ObjToJme

Hi,



as far as I can see ObjToJme converts materials to meshes and not groups (or objects). I used PoseRay to export model as OBJ and added o "group_name" lines for objects I wanted to have a name for. The problem is that I had two identical doors that used same materials. I wanted to detect if I clicked on Door1 or Door2 and I wanted to change their appearance accordingly, but I couldn't because they are made of the same materials and I can only know if I clicked on a material 1/2… So I modified the ObjToJme class a little. Here are the changes:

I added some fields to the class:

    /** Object material */
    private MaterialGrouping curObject;
    /** Maps Objects to their vertex usage * */
    private HashMap<MaterialGrouping, ArraySet> objectSets = new HashMap<MaterialGrouping, ArraySet>();



In the method buildStructure I changed every occurrence of the materialSets with objectSets and in the addFaces method curGroup with curObject.
I also added some lines in the "g" branch of the processLine method:

        } else if ("g".equals(parts[0])) {
            // see what the material name is if there isn't a name, assume its
            // the default group
            if (parts.length >= 2 && materialNames.get(parts[1]) != null) {
                curGroupName = parts[1];
                curGroup = materialNames.get(parts[1]);
            }
            else
                setDefaultGroup();
           
            [b]MaterialGrouping newObj = new MaterialGrouping();
            ArraySet set = new ArraySet();
            set.objName = parts[1];
            objectSets.put(newObj, set);
            curObject = newObj;[/b]
            return;


and in the "usemtl" branch:

        } else if ("usemtl".equals(parts[0])) {
            if (materialNames.get(parts[1]) != null)
                curGroup = materialNames.get(parts[1]);                          
            else
                setDefaultGroup();
           
            [b]curObject.as = curGroup.as;
            curObject.m = curGroup.m;
            curObject.ts = curGroup.ts;[/b]
            return;



Now I can get every group as a mesh and it works fine. The whole class is in the attachment, its meant to be put in the com.jmex.model.converters package. The code is not meant to be efficient, but just to get it to work, and I also tried not to change lines that I didn't have to.
My question is: was this really necessary or is there already a way to get every group as a mesh and does anyone think that my changes could cause any problems?

Best,
Vuk