example7.java

来自「J2ME手机游戏开发技术详解随书光盘」· Java 代码 · 共 43 行

JAVA
43
字号

import javax.microedition.m3g.*;

/**
 * Light test.
 *
 * Scene consists of three balls and two lights. One of the lights
 * rotates around the balls. Highlights etc. should be visible.
 *
 */

public class Example7 extends ExampleBase
{
    private static final String FILE_NAME = "pallot";

    private Light iLight0;
    private World iWorld;

    public Example7()
    {
        super(SHOW_RENDER_TIME);
        iWorld = null;
    }

    protected void render(int time)
    {
        Transform transform = new Transform();
        transform.postRotate(((float)time)/10.f,
                            0.0f, 1.0f, 0.0f);   // rotate around this axis
        iLight0.setTransform(transform);
        Graphics3D.getInstance().render(iWorld);
    }

    protected void initialize()
    {
        iWorld = (World)load(FILE_NAME)[0];
        iLight0 = new Light();
        iLight0.setMode(Light.DIRECTIONAL);
        iWorld.addChild(iLight0);
        iWorld.align(null);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?