Example usage for javax.media.j3d ColoringAttributes ColoringAttributes

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

Introduction

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

Prototype

public ColoringAttributes(float red, float green, float blue, int shadeModel) 

Source Link

Document

Construct ColoringAttributes object with specified values.

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);// w  w w.ja  v  a2  s.  com
        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:SplineInterpolatorTest.java

public Group createLand(Group g) {
    Land land = new Land(this, g, ComplexObject.GEOMETRY | ComplexObject.TEXTURE);
    Group hiResGroup = land.createObject(new Appearance(), new Vector3d(),
            new Vector3d(LAND_WIDTH, 1, LAND_LENGTH), "boston.gif", null, null);

    Appearance app = new Appearance();
    app.setColoringAttributes(new ColoringAttributes(WATER_COLOR_RED / 255f, WATER_COLOR_GREEN / 255f,
            WATER_COLOR_BLUE / 255f, ColoringAttributes.FASTEST));

    Land base = new Land(this, hiResGroup, ComplexObject.GEOMETRY);
    base.createObject(app, new Vector3d(0, -5, 0), new Vector3d(4 * LAND_WIDTH, 1, 4 * LAND_LENGTH), null, null,
            null);/*ww  w . j  a  v a2  s .  com*/

    return hiResGroup;
}