Example usage for javax.media.j3d GeometryArray setInterleavedVertexBuffer

List of usage examples for javax.media.j3d GeometryArray setInterleavedVertexBuffer

Introduction

In this page you can find the example usage for javax.media.j3d GeometryArray setInterleavedVertexBuffer.

Prototype

public void setInterleavedVertexBuffer(J3DBuffer vertexData) 

Source Link

Document

Sets the interleaved vertex buffer reference to the specified buffer object.

Usage

From source file:InterleavedNIOBuffer.java

public GeometryArray createGeometry(int type) {
    GeometryArray tetra = null;
    int texCoordSetMap[] = { 0, 0 };

    if (type == 1) {
        tetra = new TriangleArray(12, TriangleArray.COORDINATES | TriangleArray.COLOR_3 |
        /*/* w  ww . ja v a2 s  .  c  o  m*/
        * TriangleArray.NORMAL_3|
        */
                TriangleArray.TEXTURE_COORDINATE_2 | TriangleArray.INTERLEAVED | TriangleArray.BY_REFERENCE
                | TriangleArray.USE_NIO_BUFFER, 2, texCoordSetMap);

        tetra.setInterleavedVertexBuffer(interleavedBuffer);

    } else if (type == 2) {
        tetra = new TriangleStripArray(12, TriangleStripArray.COORDINATES | TriangleStripArray.COLOR_3 |
        /*
        * TriangleArray.NORMAL_3|
        */
                TriangleArray.TEXTURE_COORDINATE_2 | TriangleStripArray.INTERLEAVED
                | TriangleStripArray.BY_REFERENCE | TriangleStripArray.USE_NIO_BUFFER, 2, texCoordSetMap,
                stripVertexCounts);
        tetra.setInterleavedVertexBuffer(interleavedBuffer);

    } else if (type == 3) { // Indexed Geometry
        tetra = new IndexedTriangleArray(4, IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3 |
        /*
         * IndexedTriangleArray.NORMAL_3|
         */
                IndexedTriangleArray.TEXTURE_COORDINATE_2 | IndexedTriangleArray.INTERLEAVED
                | IndexedTriangleArray.BY_REFERENCE | IndexedTriangleArray.USE_NIO_BUFFER
                | IndexedTriangleArray.USE_COORD_INDEX_ONLY, 2, texCoordSetMap, 12);
        tetra.setInterleavedVertexBuffer(indexedInterleavedBuffer);
        ((IndexedTriangleArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleArray) tetra).setColorIndices(0, indices);
        ((IndexedTriangleArray) tetra).setTextureCoordinateIndices(0, 0, indices);
        ((IndexedTriangleArray) tetra).setTextureCoordinateIndices(1, 0, indices);
    } else if (type == 4) { // Indexed strip geometry
        tetra = new IndexedTriangleStripArray(4,
                IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.COLOR_3 |
                /*
                 * IndexedTriangleArray.NORMAL_3|
                 */
                        IndexedTriangleArray.TEXTURE_COORDINATE_2 | IndexedTriangleStripArray.INTERLEAVED
                        | IndexedTriangleStripArray.BY_REFERENCE | IndexedTriangleStripArray.USE_NIO_BUFFER,
                //IndexedTriangleStripArray.USE_COORD_INDEX_ONLY,
                2, texCoordSetMap, 12, stripVertexCounts);
        tetra.setInterleavedVertexBuffer(indexedInterleavedBuffer);
        ((IndexedTriangleStripArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleStripArray) tetra).setColorIndices(0, indices);
        ((IndexedTriangleStripArray) tetra).setTextureCoordinateIndices(0, 0, indices);
        ((IndexedTriangleStripArray) tetra).setTextureCoordinateIndices(1, 0, indices);
    } else if (type == 5) { // Interleaved array
    }
    return tetra;
}