Example usage for javax.media.j3d PolygonAttributes CULL_FRONT

List of usage examples for javax.media.j3d PolygonAttributes CULL_FRONT

Introduction

In this page you can find the example usage for javax.media.j3d PolygonAttributes CULL_FRONT.

Prototype

int CULL_FRONT

To view the source code for javax.media.j3d PolygonAttributes CULL_FRONT.

Click Source Link

Document

Cull all front-facing polygons.

Usage

From source file:AppearanceTest.java

public void onFront() {
    getPolygonAttributes().setCullFace(PolygonAttributes.CULL_FRONT);
}

From source file:AppearanceExplorer.java

PolygonAttributesEditor(PolygonAttributes init) {
    super(BoxLayout.Y_AXIS);
    polygonAttr = init;//from  ww  w.  j a  v  a 2  s .c om
    polygonMode = polygonAttr.getPolygonMode();
    cullFace = polygonAttr.getCullFace();
    polygonOffset = polygonAttr.getPolygonOffset();
    polygonOffsetFactor = polygonAttr.getPolygonOffsetFactor();
    backFaceNormalFlip = polygonAttr.getBackFaceNormalFlip();

    String[] modeNames = { "POLYGON_POINT", "POLYGON_LINE", "POLYGON_FILL", };
    int[] modeValues = { PolygonAttributes.POLYGON_POINT, PolygonAttributes.POLYGON_LINE,
            PolygonAttributes.POLYGON_FILL, };
    IntChooser modeChooser = new IntChooser("Mode:", modeNames, modeValues, polygonMode);
    modeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            polygonMode = event.getValue();
            polygonAttr.setPolygonMode(polygonMode);
        }
    });
    add(modeChooser);

    String[] cullNames = { "CULL_NONE", "CULL_BACK", "CULL_FRONT", };
    int[] cullValues = { PolygonAttributes.CULL_NONE, PolygonAttributes.CULL_BACK,
            PolygonAttributes.CULL_FRONT, };
    IntChooser cullChooser = new IntChooser("Cull:", cullNames, cullValues, cullFace);
    cullChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            cullFace = event.getValue();
            polygonAttr.setCullFace(cullFace);
        }
    });
    add(cullChooser);

    FloatLabelJSlider polygonOffsetSlider = new FloatLabelJSlider("Offset", 0.1f, 0.0f, 2.0f, polygonOffset);
    polygonOffsetSlider.setMajorTickSpacing(1.0f);
    polygonOffsetSlider.setPaintTicks(true);
    polygonOffsetSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            polygonOffset = e.getValue();
            polygonAttr.setPolygonOffset(polygonOffset);
        }
    });
    add(polygonOffsetSlider);

    LogFloatLabelJSlider polygonOffsetFactorSlider = new LogFloatLabelJSlider("Offset Factor", 0.1f, 10000.0f,
            polygonOffsetFactor);
    polygonOffsetFactorSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            polygonOffsetFactor = e.getValue();
            polygonAttr.setPolygonOffsetFactor(polygonOffsetFactor);
        }
    });
    add(polygonOffsetFactorSlider);

    JCheckBox backFaceNormalFlipCheckBox = new JCheckBox("BackFaceNormalFlip", backFaceNormalFlip);
    backFaceNormalFlipCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox checkbox = (JCheckBox) e.getSource();
            backFaceNormalFlip = checkbox.isSelected();
            polygonAttr.setBackFaceNormalFlip(backFaceNormalFlip);
        }
    });
    // no ablity to change without replcing polygon attributes
    backFaceNormalFlipCheckBox.setEnabled(false);

    add(new LeftAlignComponent(backFaceNormalFlipCheckBox));
}