public void update() { if (!isPlaying || !updateVertices) return; currentTime = System.currentTimeMillis(); KeyFrame currentFrame = frames[currentFrameIndex]; KeyFrame nextFrame = frames[(currentFrameIndex + 1) % numFrames]; if (currentFrameName != null && !currentFrameName.equals(currentFrame.getName())) { if (!loop) stop(); else currentFrameIndex = loopStartIndex; return; } float[] currentVerts = currentFrame.getVertices(); float[] nextVerts = nextFrame.getVertices(); float[] currentNormals = currentFrame.getNormals(); float[] nextNormals = nextFrame.getNormals(); int numVerts = currentVerts.length; float[] interPolatedVerts = new float[numVerts]; float[] interPolatedNormals = new float[numVerts]; for (int i = 0; i < numVerts; i += 3) { interPolatedVerts[i] = currentVerts[i] + interpolation * (nextVerts[i] - currentVerts[i]); interPolatedVerts[i + 1] = currentVerts[i + 1] + interpolation * (nextVerts[i + 1] - currentVerts[i + 1]); interPolatedVerts[i + 2] = currentVerts[i + 2] + interpolation * (nextVerts[i + 2] - currentVerts[i + 2]); interPolatedNormals[i] = currentNormals[i] + interpolation * (nextNormals[i] - currentNormals[i]); interPolatedNormals[i + 1] = currentNormals[i + 1] + interpolation * (nextNormals[i + 1] - currentNormals[i + 1]); interPolatedNormals[i + 2] = currentNormals[i + 2] + interpolation * (nextNormals[i + 2] - currentNormals[i + 2]); } interpolation += fps * (currentTime - startTime) / 1000; vertices().overwriteNormals(interPolatedNormals); vertices().overwriteVerts(interPolatedVerts); if (interpolation > 1) { interpolation = 0; currentFrameIndex++; if (currentFrameIndex >= numFrames) currentFrameIndex = 0; } startTime = System.currentTimeMillis(); }