try{ 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)); }
for (int i=0;i<triMesh.getNumberOfUnits();i++){ if (triMesh.getTextures(i).length>0) { if (i!=0) atts.put("texindex",new Integer(i)); atts.put("data",triMesh.getTextures(i));
    private void writeTriMeshTags(TriMesh triMesh) throws IOException {        if (triMesh==null) return;        HashMap atts=new HashMap();        atts.clear();        if (triMesh.getVertices()!=null){            if (properties.get("q3vert")!=null)                atts.put("q3vert",vertsToShorts(triMesh.getVertices()));            else                atts.put("data",triMesh.getVertices());        }        writeTag("vertex",atts);        writeEndTag("vertex");        atts.clear();        if (triMesh.getNormals()!=null){            if (properties.get("q3norm")!=null)                atts.put("q3norm",normsToShorts(triMesh.getNormals()));            else                atts.put("data",triMesh.getNormals());        }        writeTag("normal",atts);        writeEndTag("normal");        atts.clear();        if (triMesh.getColors()!=null)            atts.put("data",triMesh.getColors());        writeTag("color",atts);        writeEndTag("color");        atts.clear();        try{            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");            }        } catch(NullPointerException e){  // in this case, there is no texture defined            // just do nothing        }        atts.clear();        if (triMesh.getIndices()!=null)            atts.put("data",triMesh.getIndices());        writeTag("index",atts);        writeEndTag("index");        if (triMesh.getModelBound()!=null)            writeBounds(triMesh.getModelBound());    }