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

📄 modelrendering.java

📁 Java 3D Game SDK.老外做的.
💻 JAVA
字号:
/* * ModelRendering.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.util.*;/** * This sample application demonstrates how render a simple model. * This class has also the GameFrame as super class. * * @author  Norbert Nopper */public class ModelRendering extends GameFrame {        /**     * X Axis.     */    private LineVector  red;    /**     * Y Axis.     */    private LineVector  green;    /**     * Z Axis.     */    private LineVector  blue;        /**     * Variable to remember the last time.     */        private long        lastTime;    /**     * Rotation speed.     */        private double      rotate;        public static void main(String[] argv) {        // create the object                ModelRendering modelRendering = new ModelRendering();                // create the object and pass the game frame to it ...        RenderSelection renderSelection = new RenderSelection(modelRendering);        // ... 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);        red = new LineVector(new Point3d(1.0, 0.0, 0.0), LineVector.RED);        red.worldZ = -5;        green = new LineVector(new Point3d(0.0, 1.0, 0.0), LineVector.GREEN);        green.worldZ = -5;        blue = new LineVector(new Point3d(0.0, 0.0, 1.0), LineVector.BLUE);        blue.worldZ = -5;        // 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();        // calculate the rotation depending on the time        rotate = (double)(currentTime-lastTime)/1000.0;         // rotate if the mouse was moved horizontal        red.rotY += rotate*(double)deltaX;        green.rotY += rotate*(double)deltaX;        blue.rotY += rotate*(double)deltaX;        // rotate if the mouse was moved vertical        red.rotX += rotate*(double)deltaY;        green.rotX += rotate*(double)deltaY;        blue.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 all the lines        red.draw(gc3D);        green.draw(gc3D);        blue.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 + -