BufferUtils.populateFromBuffer(vector1, object.getVertexBuffer(0), object.faces[i].vertIndex[0]); BufferUtils.populateFromBuffer(vector2, object.getVertexBuffer(0), object.faces[i].vertIndex[1]); BufferUtils.populateFromBuffer(vector3, object.getVertexBuffer(0), object.faces[i].vertIndex[2]);
BufferUtils.populateFromBuffer(vector1, object.tm.getVertexBuffer(0), object.faces[i].vertIndex[0]); BufferUtils.populateFromBuffer(vector2, object.tm.getVertexBuffer(0), object.faces[i].vertIndex[1]); BufferUtils.populateFromBuffer(vector3, object.tm.getVertexBuffer(0), object.faces[i].vertIndex[2]);
        private void computeNormals() {            if (numOfObjects <= 0) {                return;            }            Vector3f vector1 = new Vector3f();            Vector3f vector2 = new Vector3f();            Vector3f vector3 = new Vector3f();            // Go through each of the objects to calculate their normals            for (int index = 0; index < numOfObjects; index++) {                // Get the current object                ASEObject object = (ASEObject) objectList.get(index);                // Here we allocate all the memory we need to calculate the normals                Vector3f[] tempNormals = new Vector3f[object.faces.length];                Vector3f[] normals = new Vector3f[object.getTotalVertices()];                // Go though all of the faces of this object                for (int i = 0; i < object.faces.length; i++) {                    BufferUtils.populateFromBuffer(vector1, object.getVertexBuffer(0), object.faces[i].vertIndex[0]);                    BufferUtils.populateFromBuffer(vector2, object.getVertexBuffer(0), object.faces[i].vertIndex[1]);                    BufferUtils.populateFromBuffer(vector3, object.getVertexBuffer(0), object.faces[i].vertIndex[2]);                                        vector1.subtractLocal(vector3);                                        tempNormals[i] = vector1.cross(vector3.subtract(vector2)).normalizeLocal();                }                Vector3f sum = new Vector3f();                int shared = 0;                for (int i = 0; i < object.getTotalVertices(); i++) {                    for (int j = 0; j < object.faces.length; j++) {                        if (object.faces[j].vertIndex[0] == i                            || object.faces[j].vertIndex[1] == i                            || object.faces[j].vertIndex[2] == i) {                            sum.addLocal(tempNormals[j]);                            shared++;                        }                    }                    normals[i] = sum.divide((float) (-shared)).normalizeLocal();                    sum.zero(); // Reset the sum                    shared = 0; // Reset the shared                }                object.setNormalBuffer(0, BufferUtils.createFloatBuffer(normals));            }        }