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

📄 ms3drendering.java

📁 Java 3D Game SDK.老外做的.
💻 JAVA
字号:
/* * MS3DRendering.java */package org.java3dgamesdk.samples.III;import javax.media.j3d.*;import javax.vecmath.*;import org.java3dgamesdk.core.*;import org.java3dgamesdk.core.util.*;import org.java3dgamesdk.graphics.*;import org.java3dgamesdk.graphics.MS3D.*;/** * This sample application demonstrates how to load and render a MS3D model. * This class has also the GameFrame as super class. * * @author  Norbert Nopper */public class MS3DRendering extends GameFrame {        private static int  JEEPS = 2;        /**     * Jeep.     */    private MS3DModel[]  jeep;        /**     * Index of the jeep to display.     */    private int          currentJeep;        /**     * Variable to remember the last time.     */        private long        lastTime;    /**     * Rotation speed.     */        private double      rotate;        public static void main(String[] argv) {        // create the object                MS3DRendering ms3dRendering = new MS3DRendering();                // create the object and pass the game frame to it ...        RenderSelection renderSelection = new RenderSelection(ms3dRendering);        // ... rest is done by the dialog        renderSelection.show();            }    /**     * The game mouse is enabled here and also the cursor is changed as well.     */    protected void initGame() {        // enable the game mouse        gameMouse = true;        // make an invisible cursor        canvas3d.setCursor(GameMouse.CURSOR_TRANSPARENT);        // load MS3D model        MS3DLoader loader = new MS3DLoader();        jeep = new MS3DModel[JEEPS];        jeep[0] = loader.loadModel("JeepOne", "jeep1.ms3d");        jeep[0].worldZ = -40;        jeep[1] = loader.loadModel("JeepTwo", "jeep2.ms3d");        jeep[1].worldZ = -40;        currentJeep = 0;        // add light to the scene        gc3D.addLight(new AmbientLight());    }        /**     * For this sample we do not need the method right now.     *     *@param currentTime the current game time in miliseconds, starting with 0     */    protected void updateGame(long currentTime) {        if(gameKeys[27])            exit();        else if(mouseWheel != 0) {            currentJeep += mouseWheel;            if(currentJeep < 0)                currentJeep = JEEPS-1;            else if(currentJeep >= JEEPS)                currentJeep = 0;        }        // calculate the rotation depending on the time        rotate = (double)(currentTime-lastTime)/1000.0;         // rotate if the mouse was moved horizontal        jeep[currentJeep].rotY += rotate*(double)deltaX;        // rotate if the mouse was moved vertical        jeep[currentJeep].rotX += rotate*(double)deltaY;                // remember the last time        lastTime = currentTime;            }        /**     * Whenever a scene has to be rendered, the surface has to be cleaned first.     */    protected void renderGame() {        gc3D.clear();                // draw the MS3D model        jeep[currentJeep].draw(gc3D);    }        /**     * Set up the old cursor.     */    protected void exitGame() {        // go back to the default cursor        canvas3d.setCursor(GameMouse.CURSOR_DEFAULT);    }        }

⌨️ 快捷键说明

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