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");
}