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

📄 example6.java

📁 3D J2ME 代码集合
💻 JAVA
字号:


import javax.microedition.m3g.*;

/**
 * Image, sprite and background test.
 *
 * The test moves a sprite back and forth in front of the camera. The
 * transition between different mipmap levels should be visible.
 *
 */
public class Example6 extends ExampleBase
{

    private static final int IMAGE_BASE_SIZE = 128;
//  private static final int IMAGE_BASE_SIZE = 256 - 13;

    private static final String TEXTURE_NAME = "/textures/pukki_small_cg2.png";
    
    private World iWorld;
    private Background iBackground;

    private Sprite3D iSprite;
    private Image2D iImage;
    
    public Example6()
    {
        super(SHOW_RENDER_TIME);
    }

    protected void render(int time)
    {


        double temp = Math.tan((1.0f - (float)Math.cos(time * 0.0005f))*0.5f);
        iSprite.setTranslation(0.0f, 0.0f, (float)(temp*temp*temp) * -100.0f + 30.0f);

        Graphics3D.getInstance().render(iWorld);
    }

    protected void initialize()
    {
        iWorld = new World();

        Camera camera = new Camera();
        camera.setPerspective(70.0f, 1.0f, 1.0f, 10000.0f);
        camera.setTranslation(0.0f, 0.0f, 40.0f);
        iWorld.addChild(camera);
        iWorld.setActiveCamera(camera);

        Light light = new Light();
        light.setTranslation(0.0f, 0.0f, 40.0f);
        iWorld.addChild(light);



        iImage = new Image2D(Image2D.RGBA, platformServices.loadImage(TEXTURE_NAME));


        iBackground = new Background();
        iBackground.setColor(0xffFFFFFF);
        iWorld.setBackground(iBackground);
        iSprite = new Sprite3D(true, iImage, new Appearance());
        iSprite.setScale(20.0f, 20.0f, 20.0f);
        iWorld.addChild(iSprite);
    }
    
}

⌨️ 快捷键说明

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