Question about floatbuffers for HelloKeyInput tutorial

Hello, ive just started playing with jme (cool so far :smiley: ) and stumpled across a little problem when running through the HelloKeyInput tutorial.



First the TriMesh creation has to be fixed as it doesn’t use FloatBuffers, so my question is first, is this the way:

      
FloatBuffer vertices = BufferUtils.createFloatBuffer(new Vector3f[] {
      new Vector3f(0,0,0),
      new Vector3f(1,0,0),
      new Vector3f(0,1,0),
      new Vector3f(1,1,0)
});


It works, but is it the "right" way (Might as well get it right the first time)

Next, later in the tutorial code this appears:


Vector2f[] texes=square.getTextures();
texes[1].set(coordDelta,0);
texes[2].set(0,coordDelta);
texes[3].set(coordDelta,coordDelta);
square.updateTextureBuffer();


This should update the texture, but can no longer be used, so instead I tried this:


FloatBuffer texes = square.getTextureBuffer();
BufferUtils.setInBuffer(new Vector2f(coordDelta,0),texes, 1);
BufferUtils.setInBuffer(new Vector2f(0,coordDelta),texes, 2);
BufferUtils.setInBuffer(new Vector2f(coordDelta,coordDelta),texes, 3);
square.setTextureBuffer(texes);


Again it works, but it looks much like the second way to update texture with the deprecated setTexture method from TriMesh as a new Vector2f is created each time. So is it the proper way, the old?

Also the TextureManager.textureLoad method has a field called anisoLevel which is omitted in the tutorials - I found it in java docs, but it doesn't explain which values are possible?

Think Im gonna note the errors/deprecations I find in the tutorials and create a thread with them once ive done with it, as it seems there are quite a few of them after 0.9
Garfi said:

It works, but is it the "right" way (Might as well get it right the first time)


It's fine since it is only run once and is very readable.  Alternatively you can use createVector3Buffer(4)  or createFloatBuffer(12) and simply vertices.put(x) your individual vector items in one by one to avoid object creation...  or reuse a single Vector3f object and BufferUtils.setInBuffer(myVector, vertices, index) - a very useful method of construction when you are doing calculations and not just popping in static values.

Garfi said:

Again it works, but it looks much like the second way to update texture with the deprecated setTexture method from TriMesh as a new Vector2f is created each time. So is it the proper way, the old?


Same deal as above, in this case I might use a single Vector3f object and replace your new Vector3f(x, y, z) with myVect.set(x, y, z).

Garfi said:

Also the TextureManager.textureLoad method has a field called anisoLevel which is omitted in the tutorials - I found it in java docs, but it doesn't explain which values are possible?


The aniso value is the amount of anisotropic filtering to use.  The possible values vary from card to card, but you can grab the max value from a TextureState object via the method getMaxAnisotropic().  The possible values are 1.0f -> max.  See here for gory details: http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_filter_anisotropic.txt

Garfi said:

Think Im gonna note the errors/deprecations I find in the tutorials and create a thread with them once ive done with it, as it seems there are quite a few of them after 0.9


Cool.  That'd be great.