I use a library to read PLY files, and build a Mesh. I read the data, fill float array, give them to a new mesh. I can render the mesh, it works perfectly.
Now, in another part of my program, I need to access those buffer, read them, and change them. Trying to access the position buffer give me this:
Exception in thread "main"
java.lang.UnsupportedOperationException at
java.nio.FloatBuffer.array(FloatBuffer.java:957)
[java]VertexBuffer v = mesh.getBuffer(Type.Position);
Buffer b = v.getData();
System.out.println(b.hasArray());[/java]
float[] array() Returns the float array that backs this buffer (optional operation).
Note: the optional operation part.
Also: Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array.
The problem:
Direct buffers (ie: native buffers) do not support modifying the underlying array directly because it is native memory and not Java managed memory. You have to go through the float buffer interface.