Writting multiple texture states in .jme format

This update will allow writting multitextured objects in the .jme format.





The code for JmeBinaryReader is symetric so I didn’t really include it. This change doesn’t affect anything outside of the .jme format so nobody should notice it. Here’s some sample code.



Both inside class JmeBinaryWriter:



This snip is inside the writting of a TriMesh:


        for (int i=0;i<triMesh.getNumberOfUnits();i++){
            if (triMesh.getTextures(i)!=null){
                if (i!=0)
                    atts.put("texindex",new Integer(i));
                atts.put("data",triMesh.getTextures(i));
            }
            writeTag("texturecoords",atts);
            writeEndTag("texturecoords");
        }


This snip is inside the writting of a texture state.


    private void writeTextureState(TextureState state) throws IOException{
        writeTag("texturestate",null);
        for (int i=0;i<state.getNumberOfUnits();i++){
            if (state.getTexture(i)==null || state.getTexture(i).getImageLocation()==null)
                continue;
            HashMap atts=new HashMap();
            atts.clear();
            Texture toTest=state.getTexture(i);
            String s=toTest.getImageLocation();
            if (sharedObjects.containsKey(state))
                atts.put("sharedident",sharedObjects.get(state));
            if ("file:/".equals(s.substring(0,6)))
                atts.put("file",replaceSpecialsForFile(new StringBuffer(s.substring(6))).toString());
            else
                atts.put("URL",new URL(s));
            atts.put("wrap",new Integer(toTest.getWrap()));
            atts.put("texnum",new Integer(i));
            writeTag("texture",atts);
            writeEndTag("texture");
        }
        writeEndTag("texturestate");
    }

Looks good to me.

Just need confirmation that this was added? I seem to remember you adding it, but want to make sure, before I lock the thread.

It is not in the cvs. :frowning:

Weekend vacation. I’ll add it tonight.

cough done. Sorry it took way too long. I reformated the XML to fit the change, and the class “Box” is no longer XMLloadable (didn’t like xml loadable and multitexture for some reason).