Example usage for javax.media.j3d GeometryArray setCoordRefFloat

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

Introduction

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

Prototype

public void setCoordRefFloat(float[] coords) 

Source Link

Document

Sets the float coordinate array reference to the specified array.

Usage

From source file:GeometryByReferenceTest.java

public GeometryArray createGeometry(int type) {
    GeometryArray tetra = null;
    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);//  w  ww.ja v a2  s .  c o m
        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;
}

From source file:GeometryByReferenceTest.java

public void actionPerformed(ActionEvent e) {
    Object target = e.getSource();
    GeometryArray geo;
    boolean setColor = false, setVertex = false;
    if (target == geomType) {
        geo = geoArrays[geomType.getSelectedIndex()];
        // Set everything to null, and set it later ..
        geo.setColorRefFloat(null);// w w  w  .j av  a2 s . c om
        geo.setColorRef3f(null);
        geo.setCoordRefFloat(null);
        geo.setCoordRef3f(null);
        shape.setGeometry(geoArrays[geomType.getSelectedIndex()]);

        setColor = true;
        setVertex = true;

    } else if (target == transparency) {
        if (transparency.isSelected()) {
            transp.setTransparencyMode(TransparencyAttributes.BLENDED);
        } else {
            transp.setTransparencyMode(TransparencyAttributes.NONE);
        }

    } else if (target == updates) {
        updateIndex = updates.getSelectedIndex();
        if (updateIndex == 1) {
            System.out.println("Doing coordinate update");
            ((GeometryArray) (shape.getGeometry())).updateData(this);
        } else if (updateIndex == 2) {
            System.out.println("Doing color update");
            ((GeometryArray) (shape.getGeometry())).updateData(this);
        }

    } else if (target == vertexType) {
        geo = ((GeometryArray) shape.getGeometry());
        if (vertexIndex == 0) {
            geo.setCoordRefFloat(null);
        } else if (vertexIndex == 1) {
            geo.setCoordRef3f(null);
        }
        vertexIndex = vertexType.getSelectedIndex();
        setVertex = true;
    } else if (target == colorType) {
        geo = (GeometryArray) shape.getGeometry();
        if (colorIndex == 0) {
            geo.setColorRefFloat(null);
        } else if (colorIndex == 1) {
            geo.setColorRef3f(null);
        }
        colorIndex = colorType.getSelectedIndex();
        setColor = true;
    }

    if (setVertex) {
        geo = (GeometryArray) shape.getGeometry();
        if (vertexIndex == 0) {
            if (geo instanceof IndexedGeometryArray)
                geo.setCoordRefFloat(indexedFloatVerts);
            else
                geo.setCoordRefFloat(floatVerts);
        } else if (vertexIndex == 1) {
            if (geo instanceof IndexedGeometryArray)
                geo.setCoordRef3f(indexedP3fVerts);
            else
                geo.setCoordRef3f(p3fVerts);
        }

    }
    if (setColor) {
        geo = (GeometryArray) shape.getGeometry();
        if (colorIndex == 0) {
            if (geo instanceof IndexedGeometryArray)
                geo.setColorRefFloat(indexedFloatClrs);
            else
                geo.setColorRefFloat(floatClrs);
        } else if (colorIndex == 1) {
            if (geo instanceof IndexedGeometryArray)
                geo.setColorRef3f(indexedC3fClrs);
            else
                geo.setColorRef3f(c3fClrs);
        }
    }

}