ArrayList texCoords=new ArrayList(myFace.nFaces);
ArrayList<Vector2f> texCoords=new ArrayList<Vector2f>(myFace.nFaces);
    private void putChildMeshes(Node parentNode, TriMeshChunk whatIAm,Vector3f pivotLoc) throws IOException {        FacesChunk myFace=whatIAm.face;        if (myFace==null) return;        boolean[] faceHasMaterial=new boolean[myFace.nFaces];        int noMaterialCount=myFace.nFaces;        ArrayList normals=new ArrayList(myFace.nFaces);        ArrayList vertexes=new ArrayList(myFace.nFaces);        Vector3f tempNormal=new Vector3f();        ArrayList texCoords=new ArrayList(myFace.nFaces);        if (whatIAm.coordSystem==null)            whatIAm.coordSystem=new TransformMatrix();        whatIAm.coordSystem.inverse();        for (int i=0;i<whatIAm.vertexes.length;i++){            whatIAm.coordSystem.multPoint(whatIAm.vertexes[i]);            whatIAm.vertexes[i].subtractLocal(pivotLoc);        }        Vector3f[] faceNormals=new Vector3f[myFace.nFaces];        calculateFaceNormals(faceNormals,whatIAm.vertexes,whatIAm.face.faces);        // Precalculate nextTo[vertex][0...i] <--->        // whatIAm.vertexes[vertex] is next to face nextTo[vertex][0] & nextTo[vertex][i]        if (DEBUG || DEBUG_LIGHT) System.out.println("Precaching");        int[] vertexCount=new int[whatIAm.vertexes.length];        int vertexIndex;        for (int i=0;i<myFace.nFaces;i++){            for (int j=0;j<3;j++){                vertexCount[myFace.faces[i][j]]++;            }        }        int[][] realNextFaces=new int[whatIAm.vertexes.length][];        for (int i=0;i<realNextFaces.length;i++)            realNextFaces[i]=new int[vertexCount[i]];        for (int i=0;i<myFace.nFaces;i++){            for (int j=0;j<3;j++){                vertexIndex=myFace.faces[i][j];                realNextFaces[vertexIndex][--vertexCount[vertexIndex]]=i;            }        }        if (DEBUG || DEBUG_LIGHT) System.out.println("Precaching done");        int[] indexes=new int[myFace.nFaces*3];        int curPosition;        for (int i=0;i<myFace.materialIndexes.size();i++){  // For every original material            String matName=(String) myFace.materialNames.get(i);            int[] appliedFacesIndexes=(int[])myFace.materialIndexes.get(i);            if (DEBUG_LIGHT || DEBUG) System.out.println("On material " + matName + " with " + appliedFacesIndexes.length + " faces.");            if (appliedFacesIndexes.length!=0){ // If it's got something make a new trimesh for it                TriMesh part=new TriMesh(parentNode.getName()+i);                normals.clear();                curPosition=0;                vertexes.clear();                texCoords.clear();                for (int j=0;j<appliedFacesIndexes.length;j++){ // Look thru every face in that new TriMesh                    if (DEBUG) if (j%500==0) System.out.println("Face:" + j);                    int actuallFace=appliedFacesIndexes[j];                    if (faceHasMaterial[actuallFace]==false){                        faceHasMaterial[actuallFace]=true;                        noMaterialCount--;                    }                    for (int k=0;k<3;k++){                      //   and every vertex in that face                        // what faces contain this vertex index? If they do and are in the same SG, average                        vertexIndex=myFace.faces[actuallFace][k];                        tempNormal.set(faceNormals[actuallFace]);                        calcFacesWithVertexAndSmoothGroup(realNextFaces[vertexIndex],faceNormals,myFace,tempNormal,actuallFace);                        // Now can I just index this Vertex/tempNormal combination?                        int l=0;                        Vector3f vertexValue=whatIAm.vertexes[vertexIndex];                        for (l=0;l<normals.size();l++)                            if (normals.get(l).equals(tempNormal) && vertexes.get(l).equals(vertexValue))                                break;                        if (l==normals.size()){ // if new                            normals.add(new Vector3f(tempNormal));                            vertexes.add(whatIAm.vertexes[vertexIndex]);                            if (whatIAm.texCoords!=null)                                texCoords.add(whatIAm.texCoords[vertexIndex]);                            indexes[curPosition++]=l;                        } else { // if old                            indexes[curPosition++]=l;                        }                    }                }                Vector3f[] newVerts=new Vector3f[vertexes.size()];                for (int indexV=0;indexV<newVerts.length;indexV++)                    newVerts[indexV]=(Vector3f) vertexes.get(indexV);                part.setVertexBuffer(0, BufferUtils.createFloatBuffer(newVerts));                part.setNormalBuffer(0, BufferUtils.createFloatBuffer((Vector3f[]) normals.toArray(new Vector3f[]{})));                if (whatIAm.texCoords!=null) part.setTextureBuffer(0, BufferUtils.createFloatBuffer((Vector2f[]) texCoords.toArray(new Vector2f[]{})));                int[] intIndexes=new int[curPosition];                System.arraycopy(indexes,0,intIndexes,0,curPosition);                part.setIndexBuffer(0, BufferUtils.createIntBuffer(intIndexes));                MaterialBlock myMaterials=(MaterialBlock) objects.materialBlocks.get(matName);                if (matName==null)                    throw new IOException("Couldn't find the correct name of " + myMaterials);                if (myMaterials.myMatState.isEnabled()) {                    part.setRenderState(myMaterials.myMatState);                    if ( myMaterials.myMatState.getDiffuse().a < 1.0f ) {                        part.setRenderQueueMode( Renderer.QUEUE_TRANSPARENT );                        if ( alpha == null ) {                            alpha = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();                            alpha.setEnabled( true );                            alpha.setBlendEnabled( true );                            alpha.setSrcFunction( AlphaState.SB_SRC_ALPHA );                            alpha.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );                            alpha.setTestEnabled( true );                            alpha.setTestFunction( AlphaState.TF_GREATER );                        }                        part.setRenderState( alpha );                    }                }                if (myMaterials.myTexState.isEnabled())                    part.setRenderState(myMaterials.myTexState);                if (myMaterials.myWireState.isEnabled())                    part.setRenderState(myMaterials.myWireState);                parentNode.attachChild(part);            }        }        if (noMaterialCount!=0){    // attach materialless parts            int[] noMaterialIndexes=new int[noMaterialCount*3];            int partCount=0;            for (int i=0;i<whatIAm.face.nFaces;i++){                if (!faceHasMaterial[i]){                    noMaterialIndexes[partCount++]=myFace.faces[i][0];                    noMaterialIndexes[partCount++]=myFace.faces[i][1];                    noMaterialIndexes[partCount++]=myFace.faces[i][2];                }            }            TriMesh noMaterials=new TriMesh(parentNode.getName()+"-1");            noMaterials.setVertexBuffer(0, BufferUtils.createFloatBuffer(whatIAm.vertexes));            noMaterials.setIndexBuffer(0, BufferUtils.createIntBuffer(noMaterialIndexes));            parentNode.attachChild(noMaterials);        }    }