⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example4.java

📁 J2ME手机游戏开发技术详解随书光盘
💻 JAVA
字号:
import javax.microedition.m3g.*;

/**
 * M3G import and show test.
 *
 * The example loads the FILE_NAME file and takes the first object
 * contained in the file. The object is assumed to be of type World.
 * The world is first animated and then rendered. The actions of the
 * camera depend on the contents of the file.
 */
public class Example4 extends ExampleBase
{


    private static final String FILE_NAME = "cartrack";

    private World iWorld;

    public Example4()
    {
        super(SHOW_RENDER_TIME);
    }

    protected void render(int time)
    {
        iWorld.animate(time);
        iWorld.align(null);
//      iWorld.setAlphaFactor((float)Math.cos(time * 0.001f) * 0.45f + 0.5f);
        Graphics3D.getInstance().render(iWorld);
    }

    protected void initialize()
    {
        iWorld = (World)load(FILE_NAME)[0];
        traverse(iWorld);
    }

    private void traverse(Node aNode)
    {
        if (aNode instanceof Mesh)
        {
            Mesh mesh = (Mesh)aNode;
            for (int i = 0; i < mesh.getSubmeshCount(); i++)
            {
                Appearance app = mesh.getAppearance(i);
                CompositingMode cm = new CompositingMode();
                cm.setBlending(CompositingMode.ALPHA_ADD);
                app.setCompositingMode(cm);
                app.setTexture(0, null);
                Material mat = new Material();
                mat.setColor(Material.AMBIENT | Material.DIFFUSE | Material.SPECULAR, 0xff000000);
                mat.setColor(Material.EMISSIVE, 0xff444444);
                app.setMaterial(mat);
            }
        }
        if (aNode instanceof Group)
        {
            Group group = (Group)aNode;
            for (int i = 0; i < group.getChildCount(); i++)
            {
                traverse(group.getChild(i));
            }
        }
    }

}

⌨️ 快捷键说明

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