Hey guys,
This is a follow up question from http://stackoverflow.com/questions/3204189/add-contents-to-the-end-of-a-float-array-like-this . I'm looking to dynamically create 3D boxes. Here's my Questions
I want to add a box to the list e.g add....
// FRONT -2.0f, -1.5f, -6.0f, 2.0f, -1.5f, -6.0f, -2.0f, 1.5f, -6.0f, 2.0f, 1.5f, -6.0f, // BACK -2.0f, -1.5f, -10.0f, -2.0f, 1.5f, -10.0f, 2.0f, -1.5f, -10.0f, 2.0f, 1.5f, -10.0f, // LEFT -2.0f, -1.5f, -6.0f, -2.0f, 1.5f, -6.0f, -2.0f, -1.5f, -10.0f, -2.0f, 1.5f, -10.0f, // RIGHT 2.0f, -1.5f, -10.0f, 2.0f, 1.5f, -10.0f, 2.0f, -1.5f, -6.0f, 2.0f, 1.5f, -6.0f, // TOP -2.0f, 1.5f, -6.0f, 2.0f, 1.5f, -6.0f, -2.0f, 1.5f, -6.0f, 2.0f, 1.5f, -10.0f, // BOTTOM -2.0f, -1.5f, -6.0f, -2.0f, -1.5f, -10.0f, 2.0f, -1.5f, -6.0f, 2.0f, -1.5f, -10.0f,
The above values would make up 1 box, how would I do so?
I'd like to use
glDrawArrays()
to then draw the entire list (all of the boxes) how would I make it do so?FloatBuffer makeFloatBuffer(float[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length*4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb;
}
keep in mind, I'm sending everything through a floatbuffer. and then drawing like so..
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,12, 4);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,16, 4);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,20, 4);
I'm completely new to Point3D, OpenGL and graphics in general so any help would be greatly appreciated.
Thanks.