Example usage for javax.media.j3d GraphicsContext3D addLight

List of usage examples for javax.media.j3d GraphicsContext3D addLight

Introduction

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

Prototype

public void addLight(Light light) 

Source Link

Document

Appends the specified light to this graphics context's list of lights.

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 ww w  . ja  v a2  s  .  c o  m*/
        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();
    }
}