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

📄 ms3danimating.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 MS3DAnimating extends GameFrame {        /**     * Dog.     */    private MS3DModel    dog;        /**     * Index of the jeep to display.     */    private int          currentAnimation;        /**     * Variable to remember the last time.     */        private long        lastTime;    /**     * Rotation speed.     */        private double      rotate;        public static void main(String[] argv) {        // create the object                MS3DAnimating ms3dAnimating = new MS3DAnimating();                // create the object and pass the game frame to it ...        RenderSelection renderSelection = new RenderSelection(ms3dAnimating);        // ... 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();        dog = loader.loadModel("Dog", "dog.ms3d");        dog.scale = 0.1;        dog.worldZ = -20;                MS3DModel model = (MS3DModel)dog;        model.addAnimation(new MS3DAnimation(2, 13));        model.addAnimation(new MS3DAnimation(16, 23));        model.addAnimation(new MS3DAnimation(26, 58));        currentAnimation = 0;        model.currentAnimation = currentAnimation;        // add light to the scene        gc3D.addLight(new DirectionalLight());    }        /**     * 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) {            MS3DModel model = (MS3DModel)dog;            currentAnimation += mouseWheel;            if(currentAnimation < 0)                currentAnimation = dog.numberAnimations()-1;            else if(currentAnimation >= dog.numberAnimations())                currentAnimation = 0;                        dog.currentAnimation = currentAnimation;            dog.reset();        }        dog.updateModel(currentTime);                // calculate the rotation depending on the time        rotate = (double)(currentTime-lastTime)/1000.0;         // rotate if the mouse was moved horizontal        dog.rotY += rotate*(double)deltaX;        // rotate if the mouse was moved vertical        dog.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        dog.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 + -