Example usage for javax.media.j3d GeometryArray setColorRef3f

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

Introduction

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

Prototype

public void setColorRef3f(Color3f[] colors) 

Source Link

Usage

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 ww.  j  a  va 2  s  .co  m
        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);
        }
    }

}