I'm finally implementing 3D model animation and am interpolating between keyframes. I'm just wondering if I'm using java FloatBuffers correctly for this.
Each frame, I need to update the VBO coordinates and normals data. I thought I could loop through the floatBuffer doing something like this:
for (int i=0;i<coordinates.length;i++) {
float newcoordinate = coordinates[i];
floatBuffer.put(i, newcoordinate);
}
But that gives me a java.lang.IndexOutOfBoundsException (either 0, with the above example, or the high number with "i" reaches it's limit), so instead I'm doing this:
floatBuffer.clear();
for (int i=0;i<coordinates.length;i++) {
float newcoordinate = coordinates[i];
floatBuffer.put(newcoordinate);
}
I'm mostly worried about the overhead of clearing the FloatBuffer every frame. Or is this just the way it's meant to be done?
Any help is appreciated! Thanks!
clear() doesn't have any overhead, it just resets a couple of pointers.
Cas :)
Well that's good news. That means I'm done. ;D
Always a good feeling.
Thanks!