Example usage for javax.media.j3d ColoringAttributes NICEST

List of usage examples for javax.media.j3d ColoringAttributes NICEST

Introduction

In this page you can find the example usage for javax.media.j3d ColoringAttributes NICEST.

Prototype

int NICEST

To view the source code for javax.media.j3d ColoringAttributes NICEST.

Click Source Link

Document

Use the nicest available method for shading.

Usage

From source file:MixedTest.java

public void renderField(int fieldDesc) {
    super.renderField(fieldDesc);

    GraphicsContext3D g = getGraphicsContext3D();

    // first time initialization
    if (m_nRender == 0) {
        // set the start time
        m_StartTime = System.currentTimeMillis();

        // add a light to the graphics context
        DirectionalLight light = new DirectionalLight();
        light.setEnable(true);//from   w ww.j  a  va  2 s. c om
        g.addLight((Light) light);

        // create the material for the points
        Appearance a = new Appearance();
        Material mat = new Material();
        mat.setLightingEnable(true);
        mat.setAmbientColor(0.5f, 1.0f, 1.0f);
        a.setMaterial(mat);
        a.setColoringAttributes(new ColoringAttributes(1.0f, 0.5f, 0.5f, ColoringAttributes.NICEST));

        // enlarge the points
        a.setPointAttributes(new PointAttributes(4, true));

        // make the appearance current in the graphics context
        g.setAppearance(a);
    }

    // set the current transformation for the graphics context
    g.setModelTransform(m_t3d);

    // finally render the PointArray
    g.draw(m_PointArray);

    // calculate and display the Frames Per Second for the
    // Immediate Mode rendering of the PointArray
    m_nRender++;

    if ((m_nRender % m_kReportInterval) == 0) {
        float fps = (float) 1000.0f / ((System.currentTimeMillis() - m_StartTime) / (float) m_kReportInterval);
        System.out.println("FPS:\t" + fps);

        m_StartTime = System.currentTimeMillis();
    }
}

From source file:AppearanceTest.java

public void onNicest() {
    getColoringAttributes().setShadeModel(ColoringAttributes.NICEST);
}

From source file:AppearanceExplorer.java

public ColoringAttributesEditor(ColoringAttributes init) {
    super(BoxLayout.Y_AXIS);
    coloringAttr = init;//w ww.  j a  va  2s  . c o  m
    coloringAttr.getColor(color);
    coloringShadeModel = coloringAttr.getShadeModel();

    String[] shadeNames = { "SHADE_FLAT", "SHADE_GOURAUD", "NICEST", "FASTEST" };
    int[] shadeValues = { ColoringAttributes.SHADE_FLAT, ColoringAttributes.SHADE_GOURAUD,
            ColoringAttributes.NICEST, ColoringAttributes.FASTEST };

    IntChooser shadeChooser = new IntChooser("Shade model:", shadeNames, shadeValues, coloringShadeModel);
    shadeChooser.addIntListener(new IntListener() {
        public void intChanged(IntEvent event) {
            int value = event.getValue();
            coloringAttr.setShadeModel(value);
        }
    });
    add(shadeChooser);

    Color3fEditor colorEditor = new Color3fEditor("Color", color);
    colorEditor.addColor3fListener(new Color3fListener() {
        public void colorChanged(Color3fEvent event) {
            event.getValue(color);
            coloringAttr.setColor(color);
        }
    });
    add(colorEditor);
}