Example usage for javax.media.j3d GeometryArray ALLOW_REF_DATA_WRITE

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

Introduction

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

Prototype

int ALLOW_REF_DATA_WRITE

To view the source code for javax.media.j3d GeometryArray ALLOW_REF_DATA_WRITE.

Click Source Link

Document

Specifies that this GeometryArray allows writing the geometry data reference information for this object.

Usage

From source file:GeometryByReferenceNIOBuffer.java

public GeometryArray createGeometry(int type) {
    GeometryArray tetra = null;//from   w ww.jav a  2 s  .  com
    if (type == 1) {
        tetra = new TriangleArray(12, TriangleArray.COORDINATES | TriangleArray.COLOR_3
                | TriangleArray.BY_REFERENCE | TriangleArray.USE_NIO_BUFFER);

        tetra.setCoordRefBuffer(floatBufferCoord);
        tetra.setColorRefBuffer(floatBufferColor);

    } else if (type == 2) {
        tetra = new TriangleStripArray(
                12, TriangleStripArray.COORDINATES | TriangleStripArray.COLOR_3
                        | TriangleStripArray.BY_REFERENCE | TriangleStripArray.USE_NIO_BUFFER,
                stripVertexCounts);
        tetra.setCoordRefBuffer(floatBufferCoord);
        tetra.setColorRefBuffer(floatBufferColor);

    } else if (type == 3) { // Indexed Geometry
        tetra = new IndexedTriangleArray(4,
                IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3
                        | IndexedTriangleArray.BY_REFERENCE | IndexedTriangleArray.USE_NIO_BUFFER,
                //IndexedTriangleStripArray.USE_COORD_INDEX_ONLY,
                12);
        tetra.setCoordRefBuffer(indexedFloatBufferCoord);
        tetra.setColorRefBuffer(indexedFloatBufferColor);
        ((IndexedTriangleArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleArray) tetra).setColorIndices(0, indices);
    } else if (type == 4) { // Indexed strip geometry
        tetra = new IndexedTriangleStripArray(4,
                IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.COLOR_3
                        | IndexedTriangleStripArray.BY_REFERENCE | IndexedTriangleStripArray.USE_NIO_BUFFER
                        | IndexedTriangleStripArray.USE_COORD_INDEX_ONLY,
                12, stripVertexCounts);
        tetra.setCoordRefBuffer(indexedFloatBufferCoord);
        tetra.setColorRefBuffer(indexedFloatBufferColor);
        ((IndexedTriangleStripArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleStripArray) tetra).setColorIndices(0, indices);
    }

    if (tetra != null)
        tetra.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
    return tetra;
}

From source file:GeometryByReferenceTest.java

public GeometryArray createGeometry(int type) {
    GeometryArray tetra = null;/*from w ww  . j a v  a  2s  .  c  o  m*/
    if (type == 1) {
        tetra = new TriangleArray(12,
                TriangleArray.COORDINATES | TriangleArray.COLOR_3 | TriangleArray.BY_REFERENCE);

        tetra.setCoordRefFloat(floatVerts);
        tetra.setColorRefFloat(floatClrs);

    } else if (type == 2) {
        tetra = new TriangleStripArray(12,
                TriangleStripArray.COORDINATES | TriangleStripArray.COLOR_3 | TriangleStripArray.BY_REFERENCE,
                stripVertexCounts);
        tetra.setCoordRefFloat(floatVerts);
        tetra.setColorRefFloat(floatClrs);

    } else if (type == 3) { // Indexed Geometry
        tetra = new IndexedTriangleArray(4, IndexedTriangleArray.COORDINATES | IndexedTriangleArray.COLOR_3
                | IndexedTriangleArray.BY_REFERENCE, 12);
        tetra.setCoordRefFloat(indexedFloatVerts);
        tetra.setColorRefFloat(indexedFloatClrs);
        ((IndexedTriangleArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleArray) tetra).setColorIndices(0, indices);
    } else if (type == 4) { // Indexed strip geometry
        tetra = new IndexedTriangleStripArray(4, IndexedTriangleStripArray.COORDINATES
                | IndexedTriangleStripArray.COLOR_3 | IndexedTriangleStripArray.BY_REFERENCE, 12,
                stripVertexCounts);
        tetra.setCoordRefFloat(indexedFloatVerts);
        tetra.setColorRefFloat(indexedFloatClrs);
        ((IndexedTriangleStripArray) tetra).setCoordinateIndices(0, indices);
        ((IndexedTriangleStripArray) tetra).setColorIndices(0, indices);
    }

    if (tetra != null)
        tetra.setCapability(GeometryArray.ALLOW_REF_DATA_WRITE);
    return tetra;
}