this.addController(controller);
tm.addController(controller);
        private void convertDataStructures() {            triMesh = new TriMesh[header.numFrames];            Vector2f[] texCoords2 = new Vector2f[header.numVertices];            controller = new KeyframeController();            for (int i = 0; i < header.numFrames; i++) {                int numOfVerts = header.numVertices;                int numTexVertex = header.numTexCoords;                int numOfFaces = header.numTriangles;                if (i!=0)                    triMesh[i] = new TriMesh();                else                    triMesh[i] = this;                Vector3f[] verts = new Vector3f[numOfVerts];                Vector2f[] texVerts = new Vector2f[numTexVertex];                Face[] faces = new Face[numOfFaces];                //assign a vector array for the trimesh.                for (int j = 0; j < numOfVerts; j++) {//                    verts[j] = new Vector3f();//                    verts[j].x = frames[i].vertices[j].vertex.x;//                    verts[j].y = frames[i].vertices[j].vertex.y;//                    verts[j].z = frames[i].vertices[j].vertex.z;                    if (i!=0)                        verts[j]=frames[i].vertices[j].vertex;                    else                        verts[j]=new Vector3f(frames[i].vertices[j].vertex);                }                //set up the initial indices array.                for (int j = 0; j < numOfFaces; j++) {                    faces[j] = new Face();                    faces[j].vertIndex[0] = triangles[j].vertexIndices[0];                    faces[j].vertIndex[1] = triangles[j].vertexIndices[1];                    faces[j].vertIndex[2] = triangles[j].vertexIndices[2];                    faces[j].coordIndex[0] = triangles[j].textureIndices[0];                    faces[j].coordIndex[1] = triangles[j].textureIndices[1];                    faces[j].coordIndex[2] = triangles[j].textureIndices[2];                }                if (i == 0) {                    //texture coordinates.                    for (int j = 0; j < numTexVertex; j++) {                        texVerts[j] = new Vector2f();                        texVerts[j].x = texCoords[j].x / (float) (header.skinWidth);                        texVerts[j].y =                            1 - texCoords[j].y / (float) (header.skinHeight);                    }                    //reorginize coordinates to match the vertex index.                    if (numTexVertex != 0) {                      for (int j = 0; j < numOfFaces; j++) {                        int index = faces[j].vertIndex[0];//                        texCoords2[index] = new Vector2f();   ??? Why was this here???                        texCoords2[index] = texVerts[faces[j].coordIndex[0]];                        index = faces[j].vertIndex[1];//                        texCoords2[index] = new Vector2f();                        texCoords2[index] = texVerts[faces[j].coordIndex[1]];                        index = faces[j].vertIndex[2];//                        texCoords2[index] = new Vector2f();   ??                        texCoords2[index] = texVerts[faces[j].coordIndex[2]];                      }                    }                    int[] indices = new int[numOfFaces * 3];                    int count = 0;                    for (int j = 0; j < numOfFaces; j++) {                        indices[count] = faces[j].vertIndex[0];                        count++;                        indices[count] = faces[j].vertIndex[1];                        count++;                        indices[count] = faces[j].vertIndex[2];                        count++;                    }                    triMesh[i].setIndexBuffer(0, BufferUtils.createIntBuffer(indices));                    triMesh[i].setTextureBuffer(0, BufferUtils.createFloatBuffer(texCoords2));                    controller.setMorphingMesh(triMesh[i]);                }   // End if (i==0)                triMesh[i].setVertexBuffer(0, BufferUtils.createFloatBuffer(verts));                triMesh[i].setNormalBuffer(0, BufferUtils.createFloatBuffer(computeNormals(faces, verts)));                if (i!=0) controller.setKeyframe(i-1,triMesh[i]);            }            //build controller. Attach everything.//            this.attachChild(triMesh[0]);//            triMesh[0].addController(controller);            this.addController(controller);        }