亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? m3gcanvas.java

?? 這是有關J2ME 3D編程的源程序
?? JAVA
字號:
import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.m3g.Background;
import javax.microedition.m3g.Camera;
import javax.microedition.m3g.Graphics3D;
import javax.microedition.m3g.Group;
import javax.microedition.m3g.Light;
import javax.microedition.m3g.Loader;
import javax.microedition.m3g.Mesh;
import javax.microedition.m3g.Object3D;
import javax.microedition.m3g.PolygonMode;
import javax.microedition.m3g.Transform;
import javax.microedition.m3g.World;

public class M3GCanvas
extends GameCanvas
implements Runnable {
    // Thread-control
    boolean running = false;
    boolean done = true;
    
    // If the game should end
    public static boolean gameOver = false;
    
    // Rendering hints
    public static final int STRONG_RENDERING_HINTS = Graphics3D.ANTIALIAS | Graphics3D.TRUE_COLOR | Graphics3D.DITHER;
    public static final int WEAK_RENDERING_HINTS = 0;
    public static int RENDERING_HINTS = STRONG_RENDERING_HINTS;
    
    // Key array
    boolean[] key = new boolean[5];
    
    // Key constants
    public static final int FIRE = 0;
    public static final int UP = FIRE + 1;
    public static final int DOWN = UP + 1;
    public static final int LEFT = DOWN + 1;
    public static final int RIGHT = LEFT + 1;
    
    // Global identity matrix
    Transform identity = new Transform();
    
    // Global Graphics3D object
    Graphics3D g3d = null;
    
    // The background
    Background back = null;
    
    // The global camera object
    Camera cam = null;
    
    // The particle system
    ParticleSystem ps = null;
    FountainEffect fx = null;
    
    // The playing field
    Mesh paddle;
    Group playingField;
    Ball ball;
    
    // Transforms
    Transform trLeftWall, trRightWall, trTopWall, trBottomWall;
    Transform trPaddle;
    Transform trCam = new Transform();
    
    // Paddle's coords
    float[] paddleCoords = {0.0f, 0.0f, -5.0f};
    
    // Wall constants
    public static final int TOP_WALL = 0;
    public static final int LEFT_WALL = 1;
    public static final int RIGHT_WALL = 2;
    public static final int BOTTOM_WALL = 3;
    public static final int PADDLE_WALL = 4;
    public static final int PLAYING_FIELD = 5;
    
    // Vectors for our walls
    // Explanation: Each wall holds two vectors that
    // define the plane (See linear algebra) and
    // the wall's normal vector.
    float[][][] wallVec = new float[PLAYING_FIELD][3][3];
    
    /** Constructs the canvas
     */
    public M3GCanvas(int fps)
    {
        // We don't want to capture keys normally
        super(true);
        
        // We want a fullscreen canvas
        setFullScreenMode(true);
        
        // Create our playing field
        createField();
        
        // Load our camera
        loadCamera();
        
        // Load our background
        loadBackground();
        
        // Set up graphics 3d
        setUp();
    }
    
    /** Prepares the Graphics3D engine for immediate mode rendering by adding a light */
    private void setUp()
    {
        // Get the instance
        g3d = Graphics3D.getInstance();
        
        // Add a light to our scene, so we can see something
        g3d.addLight(createAmbientLight(), identity);
    }
    
    
    /** Creates a simple ambient light */
    private Light createAmbientLight()
    {
        Light l = new Light();
        l.setMode(Light.AMBIENT);
        l.setIntensity(1.0f);
        return l;
    }

    /** When fullscreen mode is set, some devices will call
     * this method to notify us of the new width/height.
     * However, we don't really care about the width/height
     * in this tutorial so we just let it be
     */
    public void sizeChanged(int newWidth, int newHeight)
    {
        
    }
    
    /** Loads our camera */
    private void loadCamera()
    {
        // Create a new camera
        cam = new Camera();
        
        // Set the perspective of our camera (choose a pretty wide FoV for a nifty tube effect)
        cam.setPerspective(130.0f, (float)getWidth() / (float)getHeight(), 0.1f, 50.0f);
    }
    
    /** Loads the background */
    private void loadBackground()
    {
        // Create a new background, set bg color to black
        back = new Background();
        back.setColor(0);
    }
    
    /** Creates our playing field. It will instantiate the ball and the three
     * walls (fourth wall is the "screen"
     */
    private void createField()
    {
        try
        {
            loadBall();
            
            createPaddle();
            
            createWalls();  
        }
        catch(IOException e)
        {
            System.out.println("Loading error: " + e);
        }
    }

    /**
     * 
     */
    private void createWalls() {
        // Create all planes with our nifty MeshFactory class (we need several for collision)
        Mesh wall1 = MeshFactory.createPlane("/res/wall.png", PolygonMode.CULL_BACK);
        Mesh wall2 = MeshFactory.createPlane("/res/wall.png", PolygonMode.CULL_BACK);
        Mesh wall3 = MeshFactory.createPlane("/res/wall.png", PolygonMode.CULL_BACK);
        Mesh wall4 = MeshFactory.createPlane("/res/wall.png", PolygonMode.CULL_BACK);
        
        // We want nice perspective correction here
        MeshOperator.setPerspectiveCorrection(wall1, true);
        MeshOperator.setPerspectiveCorrection(wall2, true);
        MeshOperator.setPerspectiveCorrection(wall3, true);
        MeshOperator.setPerspectiveCorrection(wall4, true);
        
        // Set the left wall at its true position
        trLeftWall = new Transform();         
        trLeftWall.postTranslate(-4.0f, 0.0f, -5.0f);
        trLeftWall.postRotate(90, 0.0f, 1.0f, 0.0f);
        trLeftWall.postScale(5.0f, 5.0f, 5.0f);     
        wall1.setTransform(trLeftWall);
        
        // Make its vectors
        float[] v = VectorOps.vector(0.0f, 1.0f, 0.0f);
        float[] u = VectorOps.vector(0.0f, 0.0f, 1.0f);
        float[] normVec = VectorOps.calcNormal(v, u);
        wallVec[LEFT_WALL][0] = v;
        wallVec[LEFT_WALL][1] = u;
        wallVec[LEFT_WALL][2] = normVec;
        
        // Set the right wall at its true position
        trRightWall = new Transform();         
        trRightWall.postTranslate(4.0f, 0.0f, -5.0f);
        trRightWall.postRotate(-90, 0.0f, 1.0f, 0.0f);
        trRightWall.postRotate(180, 0.0f, 0.0f, 1.0f);
        trRightWall.postScale(5.0f, 5.0f, 5.0f);
        wall2.setTransform(trRightWall);
        
        // Same vectors as the left wall
        wallVec[RIGHT_WALL][0] = v;
        wallVec[RIGHT_WALL][1] = u;
        wallVec[RIGHT_WALL][2] = normVec;
        
        // Set the top wall at its true position
        trTopWall = new Transform();
        trTopWall.postTranslate(0.0f, 4.0f, -5.0f);
        trTopWall.postRotate(90, 1.0f, 0.0f, 0.0f);
        trTopWall.postRotate(-90, 0.0f, 0.0f, 1.0f);
        trTopWall.postScale(5.0f, 5.0f, 5.0f);
        wall3.setTransform(trTopWall);
        
        // Make its vectors
        v = VectorOps.vector(1.0f, 0.0f, 0.0f);
        u = VectorOps.vector(0.0f, 0.0f, 1.0f);
        normVec = VectorOps.calcNormal(v, u);
        wallVec[TOP_WALL][0] = v;
        wallVec[TOP_WALL][1] = u;
        wallVec[TOP_WALL][2] = normVec;
        
        // Set the bottom wall at its true position
        trBottomWall = new Transform();
        trBottomWall.postTranslate(0.0f, -4.0f, -5.0f);
        trBottomWall.postRotate(-90, 1.0f, 0.0f, 0.0f);
        trBottomWall.postRotate(90, 0.0f, 0.0f, 1.0f);
        trBottomWall.postScale(5.0f, 5.0f, 5.0f);
        wall4.setTransform(trBottomWall);
        
        // Same vectors as top wall
        wallVec[BOTTOM_WALL][0] = v;
        wallVec[BOTTOM_WALL][1] = u;
        wallVec[BOTTOM_WALL][2] = normVec;
        
        // So we can recognize them later
        wall1.setUserID(LEFT_WALL);
        wall2.setUserID(RIGHT_WALL);
        wall3.setUserID(TOP_WALL);
        wall4.setUserID(BOTTOM_WALL);
        
        // Make sure we can collide with them
        wall1.setPickingEnable(true);
        wall2.setPickingEnable(true);
        wall3.setPickingEnable(true);
        wall4.setPickingEnable(true);
        
        // Add walls to field group        
        playingField.addChild(wall1);
        playingField.addChild(wall2);
        playingField.addChild(wall3);
        playingField.addChild(wall4);
    }

    /**
     * 
     */
    private void createPaddle()
    {
        // Create a plane using our nifty MeshFactory class
        paddle = MeshFactory.createPlane("/res/paddle.png", PolygonMode.CULL_BACK);
        
        // Set the paddle at its initial position
        trPaddle = new Transform();
        trPaddle.postTranslate(paddleCoords[0], paddleCoords[1], paddleCoords[2]);
        paddle.setTransform(trPaddle);
        
        // Make sure it's collidable
        paddle.setPickingEnable(true);
        paddle.setUserID(PADDLE_WALL);
        
        // Add to the playing field
        playingField = new Group();
        playingField.setUserID(PLAYING_FIELD);
        playingField.addChild(paddle);
        
        // Create its vector
        float[] v = {0.0f, 1.0f, 0.0f};
        float[] u = {1.0f, 0.0f, 0.0f};
        float[] normVec = VectorOps.calcNormal(v, u);
        wallVec[PADDLE_WALL][0] = v;
        wallVec[PADDLE_WALL][1] = u;
        wallVec[PADDLE_WALL][2] = normVec;
    }

    /**
     * Loads our ball
     */
    private void loadBall() throws IOException
    {
        // Simply allocate an instance of the Ball class
        ball = new Ball();
    }

    /** Draws to screen
     */    
    private void draw(Graphics g)
    {
        // Envelop all in a try/catch block just in case
        try
        {            
            // Get the Graphics3D context
            g3d = Graphics3D.getInstance();
            
	        // First bind the graphics object. We use our pre-defined rendering hints.
	        g3d.bindTarget(g, true, RENDERING_HINTS);
	        
	        // Clear background
	        g3d.clear(back);
	        
	        // Bind camera at fixed position in origo
	        g3d.setCamera(cam, trCam);
	        
	        // Render the playing field and ball
	        g3d.render(playingField, identity);
	        ball.render(g3d, playingField, wallVec, paddleCoords);
	        
	        // Check controls for paddle movement
	        if(key[UP])
	        {
	            paddleCoords[1] += 0.2f;
	            if(paddleCoords[1] > 3.0f)
	                paddleCoords[1] = 3.0f;
	        }
	        if(key[DOWN])
	        {
	            paddleCoords[1] -= 0.2f;
	            if(paddleCoords[1] < -3.0f)
	                paddleCoords[1] = -3.0f;
	        }
	        if(key[LEFT])
	        {
	            paddleCoords[0] -= 0.2f;
	            if(paddleCoords[0] < -3.0f)
	                paddleCoords[0] = -3.0f;
	        }
	        if(key[RIGHT])
	        {
	            paddleCoords[0] += 0.2f;
	            if(paddleCoords[0] > 3.0f)
	                paddleCoords[0] = 3.0f;
	        }
	        
	        // Set paddle's coords
	        trPaddle.setIdentity();
	        trPaddle.postTranslate(paddleCoords[0], paddleCoords[1], paddleCoords[2]);
	        paddle.setTransform(trPaddle);
	        
	        // Quit if user presses fire
	        if(key[FIRE])
	            ball.start();
        }
        catch(Exception e)
        {
            reportException(e);
        }
        finally
        {
            // Always remember to release!
            g3d.releaseTarget();
        }
        
        // Do some old-fashioned 2D drawing        
        if(!ball.isMoving())
        {
            g.setColor(0);
            g.drawString("Press fire to start!", 2, 2, Graphics.TOP | Graphics.LEFT);
        }
        else
        {
            int red = Math.min(255, ball.getBounces() * 12);
            g.setColor(red, 0, 0);
            g.drawString("Score: " + ball.getBounces(), 2, 2, Graphics.TOP | Graphics.LEFT);
        }
    }

    /** Starts the canvas by firing up a thread
     */
    public void start() {
        Thread myThread = new Thread(this);
        
        // Make sure we know we are running
        running = true;
        done = false;
        
        // Start
        myThread.start();
    }
    
    /** Run, runs the whole thread. Also keeps track of FPS
     */
    public void run() {
        while(running) {
            try {                
                // Call the process method (computes keys)
                process();
                
                // Draw everything
                draw(getGraphics());
                flushGraphics();
                
                // Sleep to prevent starvation
                try{ Thread.sleep(30); } catch(Exception e) {}
            }
            catch(Exception e) {
                reportException(e);
            }
        }
        
        // Notify completion
        done = true;
    }
    
    /**
     * @param e
     */
    private void reportException(Exception e) {
        System.out.println(e.getMessage());
        System.out.println(e);
        e.printStackTrace();
    }

    /** Pauses the game
     */
    public void pause() {}
    
    /** Stops the game
     */
    public void stop() { running = false; }
    
    /** Processes keys
     */
    protected void process()
    {
        int keys = getKeyStates();
        
        if((keys & GameCanvas.FIRE_PRESSED) != 0)
            key[FIRE] = true;
        else
            key[FIRE] = false;
        
        if((keys & GameCanvas.UP_PRESSED) != 0)
            key[UP] = true;
        else
            key[UP] = false;
        
        if((keys & GameCanvas.DOWN_PRESSED) != 0)
            key[DOWN] = true;
        else
            key[DOWN] = false;
        
        if((keys & GameCanvas.LEFT_PRESSED) != 0)
            key[LEFT] = true;
        else
            key[LEFT] = false;
        
        if((keys & GameCanvas.RIGHT_PRESSED) != 0)
            key[RIGHT] = true;
        else
            key[RIGHT] = false;
    }
    
    /** Checks if thread is running
     */
    public boolean isRunning() { return running; }
    
    /** checks if thread has finished its execution completely
     */
    public boolean isDone() { return done; }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区精品| 亚洲乱码中文字幕| 亚洲一区免费观看| 国产一区二区三区| 欧美三级蜜桃2在线观看| 国产精品全国免费观看高清| 日韩电影在线一区二区三区| 91老司机福利 在线| 国产欧美日韩在线视频| 久久国产麻豆精品| 欧美日韩中文字幕一区二区| 亚洲精品日日夜夜| 95精品视频在线| 国产精品美日韩| 成人午夜电影久久影院| 欧美tk丨vk视频| 蜜桃视频在线一区| 欧美日韩高清影院| 亚洲资源中文字幕| 91久久精品网| 亚洲午夜羞羞片| 欧洲精品中文字幕| 亚洲一区二区三区四区在线观看| 成人高清免费观看| 亚洲欧洲另类国产综合| 成人中文字幕在线| 国产精品久久久久影视| 成人开心网精品视频| 国产三级精品视频| av在线不卡电影| 综合激情网...| 日本韩国欧美在线| 午夜视频一区在线观看| 欧美一区二区视频在线观看2020| 日本伊人色综合网| 精品少妇一区二区三区日产乱码 | 亚洲亚洲精品在线观看| 91久久免费观看| 日韩国产高清影视| 日韩美女在线视频| 精品无人区卡一卡二卡三乱码免费卡| 久久影音资源网| 不卡在线视频中文字幕| 一区二区三区欧美视频| 欧美日韩高清在线| 狠狠色狠狠色综合系列| 国产农村妇女毛片精品久久麻豆 | 国产精品第13页| 色先锋资源久久综合| 五月婷婷激情综合网| 欧美xxxxx裸体时装秀| 大胆亚洲人体视频| 亚洲国产人成综合网站| 欧美不卡视频一区| 成a人片亚洲日本久久| 亚洲第一综合色| 久久久久久久久久久久久夜| 99国产精品久久| 免费在线观看一区二区三区| 久久久影院官网| 欧美中文字幕一区二区三区亚洲 | 成人做爰69片免费看网站| 亚洲精品菠萝久久久久久久| 日韩欧美一级二级三级久久久| 粉嫩久久99精品久久久久久夜| 亚洲成人免费影院| 日本一区二区动态图| 欧美日韩免费电影| 成人av小说网| 久久99精品久久久久久国产越南| 中文字幕乱码日本亚洲一区二区 | 视频在线观看91| 国产日韩欧美高清| 91精品国产麻豆| 不卡在线视频中文字幕| 久久精品国产亚洲5555| 一区二区三区在线观看网站| 精品久久久久久综合日本欧美| 日本乱人伦一区| 国产毛片一区二区| 免费观看日韩电影| 亚洲国产精品麻豆| ●精品国产综合乱码久久久久| 日韩一区二区三区四区| 欧美无乱码久久久免费午夜一区 | 丁香激情综合国产| 日韩电影在线看| 一区二区三区不卡在线观看| 日本一区二区久久| 久久久欧美精品sm网站| 91精品国产综合久久久蜜臀图片| 日本道精品一区二区三区| 成人高清免费观看| 国产黄色91视频| 精品一区二区三区久久久| 三级久久三级久久| 亚洲欧美日韩在线播放| 国产日韩欧美精品在线| 久久亚洲二区三区| 日韩欧美一级二级三级久久久| 欧美日韩国产电影| 欧美日韩国产成人在线91 | 成人午夜电影网站| 国产精品一区二区视频| 国产美女娇喘av呻吟久久| 精品一区二区三区不卡| 精彩视频一区二区三区| 久久国产精品72免费观看| 麻豆成人91精品二区三区| 麻豆成人在线观看| 老司机一区二区| 精品一区二区综合| 99精品视频在线播放观看| 国产91精品免费| 成人看片黄a免费看在线| 不卡的av中国片| 一本色道**综合亚洲精品蜜桃冫| 97精品超碰一区二区三区| av色综合久久天堂av综合| 色综合久久久久| 欧美日韩精品免费观看视频 | 国产亚洲午夜高清国产拍精品| 精品美女一区二区三区| 2欧美一区二区三区在线观看视频| 久久综合九色综合欧美就去吻| 久久丝袜美腿综合| 中文字幕中文字幕一区二区| 亚洲日本欧美天堂| 香蕉久久夜色精品国产使用方法 | 欧美精品一区二区高清在线观看| 欧美草草影院在线视频| 国产欧美一区二区精品性色| 麻豆国产精品官网| 成人一区二区三区| 色成人在线视频| 欧美大黄免费观看| 国产女主播视频一区二区| 亚洲欧美另类综合偷拍| 天堂成人国产精品一区| 国产精品一二一区| 91啦中文在线观看| 日韩精品一区二区三区四区| 欧美国产97人人爽人人喊| 一区二区三区欧美在线观看| 久久精品国产久精国产| caoporn国产一区二区| 欧美精品一二三四| 中国色在线观看另类| 亚洲高清不卡在线| 成人永久aaa| 欧美剧在线免费观看网站| 国产午夜精品久久| 天堂午夜影视日韩欧美一区二区| 国产成人在线电影| 欧美精品在线一区二区| 中文字幕av在线一区二区三区| 亚洲chinese男男1069| 成人手机在线视频| 日韩一区二区三区在线视频| 亚洲人成网站在线| 国产乱人伦精品一区二区在线观看| 91免费视频网址| 久久久影视传媒| 日产国产高清一区二区三区| 99久久精品久久久久久清纯| 日韩欧美成人一区| 亚洲一区二区三区四区在线免费观看| 国产精品亚洲第一| 欧美一区在线视频| 亚洲一本大道在线| 一本色道久久综合亚洲aⅴ蜜桃| 日韩免费电影网站| 亚洲va国产天堂va久久en| 99久久精品国产精品久久| 久久综合久久综合久久| 日本欧美一区二区三区乱码| 在线视频一区二区三| 国产精品久久久久久久久免费桃花| 午夜av一区二区| 欧美优质美女网站| 亚洲免费色视频| jiyouzz国产精品久久| 久久久精品国产免大香伊| 久久av老司机精品网站导航| 在线播放91灌醉迷j高跟美女| 亚洲精品第一国产综合野| www.日韩大片| 中文字幕一区二区视频| 国产成人精品网址| 久久精品人人做人人综合| 久久se精品一区精品二区| 日韩欧美激情一区| 久草这里只有精品视频| 欧美一级片在线看| 看片的网站亚洲| 精品国产青草久久久久福利| 美女视频网站久久| 亚洲精品一区二区三区在线观看| 精品一区二区三区在线播放视频| 欧美大片在线观看一区二区|