Example usage for javax.media.j3d RenderingAttributes GREATER

List of usage examples for javax.media.j3d RenderingAttributes GREATER

Introduction

In this page you can find the example usage for javax.media.j3d RenderingAttributes GREATER.

Prototype

int GREATER

To view the source code for javax.media.j3d RenderingAttributes GREATER.

Click Source Link

Document

Specifies that pixels are drawn if the source/reference value is greater than the destination/test value.

Usage

From source file:ffx.potential.MolecularAssembly.java

/**
 * <p>/*from  w  w  w  .j  a v a2  s.  co  m*/
 * createBox</p>
 */
public void createBox() {
    int vertices = 8;
    LineArray la = new LineArray(4 * vertices,
            GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
    la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
    la.setCapability(LineArray.ALLOW_COORDINATE_READ);
    la.setCapability(LineArray.ALLOW_COLOR_WRITE);
    la.setCapability(LineArray.ALLOW_COUNT_READ);
    la.setCapability(LineArray.ALLOW_INTERSECT);
    la.setCapability(LineArray.ALLOW_FORMAT_READ);
    // Create a normal
    // for (ListIterator li = bondlist.listIterator(); li.hasNext(); ){
    // la.setCoordinate(i, a1);
    // la.setColor(i, col);
    // la.setNormal(i++, a1);
    // }
    ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
    Appearance app = new Appearance();
    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(RendererCache.bondwidth);
    lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttributes.setLineAntialiasingEnable(true);
    app.setLineAttributes(lineAttributes);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    RenderingAttributes ra = new RenderingAttributes();
    ra.setAlphaTestValue(0.1f);
    ra.setAlphaTestFunction(RenderingAttributes.GREATER);
    ra.setDepthBufferEnable(true);
    ra.setDepthBufferWriteEnable(true);
    app.setRenderingAttributes(ra);
    app.setColoringAttributes(cola);
    Shape3D wireframe = new Shape3D(la, app);
    // PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
    wireframe.setUserData(this);
    wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 10.0));
    try {
        wireframe.setBoundsAutoCompute(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    // return wire;
}

From source file:AppearanceTest.java

public void onGREATER() {
    getRenderingAttributes().setAlphaTestFunction(RenderingAttributes.GREATER);
}

From source file:ffx.potential.MolecularAssembly.java

private Shape3D renderWire() {
    ArrayList<ROLS> bonds = getBondList();
    int numbonds = bonds.size();
    if (numbonds < 1) {
        return null;
    }//ww w  .j a v  a 2 s  .  c  om

    Vector3d bondmidpoint = new Vector3d();
    double[] mid = { 0, 0, 0 };
    Vector3d v1 = new Vector3d();
    Vector3d v2 = new Vector3d();
    float[] a1 = { 0, 0, 0 };
    float[] a2 = { 0, 0, 0 };
    float[] col = new float[4];
    Bond bond;

    Atom atom1, atom2;
    LineArray la = new LineArray(4 * numbonds,
            GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
    la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
    la.setCapability(LineArray.ALLOW_COORDINATE_READ);
    la.setCapability(LineArray.ALLOW_COLOR_WRITE);
    la.setCapability(LineArray.ALLOW_COUNT_READ);
    la.setCapability(LineArray.ALLOW_INTERSECT);
    la.setCapability(LineArray.ALLOW_FORMAT_READ);
    atomLookUp = new Atom[4 * numbonds];
    int i = 0;
    col[3] = 0.9f;
    for (ListIterator li = bonds.listIterator(); li.hasNext();) {
        bond = (Bond) li.next();
        bond.setWire(la, i);
        atom1 = bond.getAtom(0);
        atom2 = bond.getAtom(1);
        atom1.getV3D(v1);
        atom2.getV3D(v2);
        a1[0] = (float) v1.x;
        a1[1] = (float) v1.y;
        a1[2] = (float) v1.z;
        a2[0] = (float) v2.x;
        a2[1] = (float) v2.y;
        a2[2] = (float) v2.z;
        // Find the bond center
        bondmidpoint.add(v1, v2);
        bondmidpoint.scale(0.5d);
        bondmidpoint.get(mid);
        // Atom #1
        Atom.AtomColor.get(atom1.getAtomicNumber()).get(col);
        atomLookUp[i] = atom1;
        la.setCoordinate(i, a1);
        la.setColor(i, col);
        la.setNormal(i, a2);
        i++;

        atomLookUp[i] = atom1;
        la.setCoordinate(i, mid);
        la.setColor(i, col);
        la.setNormal(i, a2);
        i++;
        // Atom #2

        Atom.AtomColor.get(atom2.getAtomicNumber()).get(col);
        atomLookUp[i] = atom2;
        la.setCoordinate(i, a2);
        la.setColor(i, col);
        la.setNormal(i, a1);
        i++;

        atomLookUp[i] = atom2;
        la.setCoordinate(i, mid);
        la.setColor(i, col);
        la.setNormal(i, a1);
        i++;

    }

    ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
    Appearance app = new Appearance();
    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(RendererCache.bondwidth);
    lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttributes.setLineAntialiasingEnable(true);
    app.setLineAttributes(lineAttributes);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    RenderingAttributes ra = new RenderingAttributes();
    ra.setAlphaTestValue(0.1f);
    ra.setAlphaTestFunction(RenderingAttributes.GREATER);
    ra.setDepthBufferEnable(true);
    ra.setDepthBufferWriteEnable(true);
    app.setRenderingAttributes(ra);
    app.setColoringAttributes(cola);
    Shape3D wireframe = new Shape3D(la, app);
    // PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
    wireframe.setUserData(this);
    wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 1000.0));
    try {
        wireframe.setBoundsAutoCompute(false);
    } catch (Exception e) {
        e.printStackTrace();
    }

    wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    wireframe.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
    return wireframe;
}

From source file:AppearanceExplorer.java

RenderingAttributesEditor(RenderingAttributes init) {
    renderingAttr = init;/*from www.j  a v a 2 s  .  c  o m*/
    visible = renderingAttr.getVisible();
    depthBufferEnable = renderingAttr.getDepthBufferEnable();
    depthBufferWriteEnable = renderingAttr.getDepthBufferWriteEnable();
    ignoreVertexColors = renderingAttr.getIgnoreVertexColors();
    rasterOpEnable = renderingAttr.getRasterOpEnable();
    rasterOp = renderingAttr.getRasterOp();
    alphaTestFunction = renderingAttr.getAlphaTestFunction();
    alphaTestValue = renderingAttr.getAlphaTestValue();

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JCheckBox visibleCheckBox = new JCheckBox("Visible", visible);
    visibleCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            visible = checkbox.isSelected();
            renderingAttr.setVisible(visible);
        }
    });
    // add the checkbox to the panel
    add(new LeftAlignComponent(visibleCheckBox));

    JCheckBox ignoreVertexColorsCheckBox = new JCheckBox("Ignore Vertex Colors", ignoreVertexColors);
    ignoreVertexColorsCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            ignoreVertexColors = checkbox.isSelected();
            renderingAttr.setIgnoreVertexColors(ignoreVertexColors);
        }
    });
    // add the checkbox to the panel
    add(new LeftAlignComponent(ignoreVertexColorsCheckBox));

    JCheckBox depthBufferEnableCheckBox = new JCheckBox("Depth Buffer Enable", depthBufferEnable);
    depthBufferEnableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            depthBufferEnable = checkbox.isSelected();
            renderingAttr.setDepthBufferEnable(depthBufferEnable);
        }
    });
    // add the checkbox to the panel
    add(new LeftAlignComponent(depthBufferEnableCheckBox));
    // no cap bit for depth buffer enable
    depthBufferEnableCheckBox.setEnabled(false);

    JCheckBox depthBufferWriteEnableCheckBox = new JCheckBox("Depth Buffer Write Enable",
            depthBufferWriteEnable);
    depthBufferWriteEnableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            depthBufferWriteEnable = checkbox.isSelected();
            renderingAttr.setDepthBufferWriteEnable(depthBufferWriteEnable);
        }
    });
    // add the checkbox to the panel
    add(new LeftAlignComponent(depthBufferWriteEnableCheckBox));
    // no cap bit for depth buffer enable
    depthBufferWriteEnableCheckBox.setEnabled(false);

    JCheckBox rasterOpEnableCheckBox = new JCheckBox("Raster Operation Enable", rasterOpEnable);
    rasterOpEnableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            rasterOpEnable = checkbox.isSelected();
            renderingAttr.setRasterOpEnable(rasterOpEnable);
        }
    });
    // add the checkbox to the panel
    add(new LeftAlignComponent(rasterOpEnableCheckBox));

    String[] rasterOpNames = { "ROP_COPY", "ROP_XOR", };
    int[] rasterOpValues = { RenderingAttributes.ROP_COPY, RenderingAttributes.ROP_XOR, };
    IntChooser rasterOpChooser = new IntChooser("Raster Operation:", rasterOpNames, rasterOpValues, rasterOp);
    rasterOpChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            rasterOp = event.getValue();
            renderingAttr.setRasterOp(rasterOp);
        }
    });
    add(rasterOpChooser);

    String[] alphaTestFunctionNames = { "ALWAYS", "NEVER", "EQUAL", "NOT_EQUAL", "LESS", "LESS_OR_EQUAL",
            "GREATER", "GREATER_OR_EQUAL", };
    int[] alphaTestFunctionValues = { RenderingAttributes.ALWAYS, RenderingAttributes.NEVER,
            RenderingAttributes.EQUAL, RenderingAttributes.NOT_EQUAL, RenderingAttributes.LESS,
            RenderingAttributes.LESS_OR_EQUAL, RenderingAttributes.GREATER,
            RenderingAttributes.GREATER_OR_EQUAL, };
    IntChooser alphaTestFunctionChooser = new IntChooser("Alpha Test Function:", alphaTestFunctionNames,
            alphaTestFunctionValues, alphaTestFunction);
    alphaTestFunctionChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            alphaTestFunction = event.getValue();
            renderingAttr.setAlphaTestFunction(alphaTestFunction);
        }
    });
    add(alphaTestFunctionChooser);

    FloatLabelJSlider alphaTestValueSlider = new FloatLabelJSlider("Alpha Test Value: ", 0.1f, 0.0f, 1.0f,
            alphaTestValue);
    alphaTestValueSlider.setMajorTickSpacing(1.0f);
    alphaTestValueSlider.setPaintTicks(true);
    alphaTestValueSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            alphaTestValue = e.getValue();
            renderingAttr.setAlphaTestValue(alphaTestValue);
        }
    });
    add(alphaTestValueSlider);

}