Main repository of MikuMikuStudio
Revision | a780dfbd050898b213d54982d21abc7d3b73bddb (tree) |
---|---|
Time | 2003-09-05 06:39:11 |
Author | mojomonkey <mojomonkey@75d0...> |
Commiter | mojomonkey |
not needed anymore
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@79 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -1,195 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2003 najgl Project | |
3 | - * All rights reserved. | |
4 | - * | |
5 | - * Redistribution and use in source and binary forms, with or without | |
6 | - * modification, are permitted provided that the following conditions are met: | |
7 | - * | |
8 | - * 1) Redistributions of source code must retain the above copyright | |
9 | - * notice, this list of conditions and the following disclaimer. | |
10 | - * | |
11 | - * 2) Redistributions in binary form must reproduce the above copyright | |
12 | - * notice, this list of conditions and the following disclaimer in the | |
13 | - * documentation and/or other materials provided with the distribution. | |
14 | - * | |
15 | - * 3) Neither the name of 'najgl' nor the names of its contributors | |
16 | - * may be used to endorse or promote products derived from this software | |
17 | - * without specific prior written permission. | |
18 | - * | |
19 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
20 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | |
23 | - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
24 | - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
25 | - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
26 | - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
27 | - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
28 | - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
29 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
30 | - */ | |
31 | - | |
32 | -package test.model.ms3dAscii; | |
33 | - | |
34 | -import jme.geometry.model.Model; | |
35 | -import jme.geometry.model.ms.MilkshapeModel; | |
36 | - | |
37 | -import org.lwjgl.Display; | |
38 | -import org.lwjgl.input.Keyboard; | |
39 | -import org.lwjgl.opengl.GL; | |
40 | -import org.lwjgl.opengl.GLCaps; | |
41 | -import org.lwjgl.opengl.GLU; | |
42 | -import org.lwjgl.opengl.Window; | |
43 | - | |
44 | -/** | |
45 | - * A basic lwjgl game skeleton. Starts up opengl. The game loop executes | |
46 | - * forever, or until the escape key is pressed or the window is closed. Can | |
47 | - * be run in windowed or fullscreen mode. | |
48 | - * | |
49 | - * The demo will load a Milkshape 3D model, rotate it around the y-axis, and | |
50 | - * play its animation. | |
51 | - * | |
52 | - * @author naj | |
53 | - * @version 0.1 | |
54 | - */ | |
55 | -public class TestAsciiMilkshape { | |
56 | - | |
57 | - private static final boolean WIREFRAME = false; | |
58 | - private static final boolean ANIMATED = true; | |
59 | - | |
60 | - private static boolean fullscreen = false; | |
61 | - private static String modelFilename = "data/run.txt"; | |
62 | -// private static String modelFilename = "data/diablo.txt"; | |
63 | - | |
64 | - private static boolean finished; | |
65 | - private static float yrot; | |
66 | - private static int count; | |
67 | - private static Model model; | |
68 | - | |
69 | - public static float dt = 0.2f; | |
70 | - | |
71 | - public static void main(String[] args) { | |
72 | - if (args.length == 1) { | |
73 | - modelFilename = args[0]; | |
74 | - } else if (args.length == 2) { | |
75 | - modelFilename = args[0]; | |
76 | - fullscreen = (args[1] != null && args[1].equalsIgnoreCase("fullscreen")) ? true : false; | |
77 | - } else { | |
78 | - System.out.println("Usage: java -jar example1.jar <filename> [fullscreen]"); | |
79 | - System.out.println(" - filename must be a ms3d ascii text file"); | |
80 | - System.out.println(" - add the optional word 'fullscreen' for fullscreen mode"); | |
81 | - System.exit(1); | |
82 | - } | |
83 | - model = new MilkshapeModel(ANIMATED); | |
84 | - try { | |
85 | - init(); | |
86 | - while (!finished) { | |
87 | - Keyboard.poll(); | |
88 | - mainLoop(); | |
89 | - render(); | |
90 | - Window.update(); | |
91 | - Window.paint(); | |
92 | - } | |
93 | - } catch (Throwable t) { | |
94 | - t.printStackTrace(); | |
95 | - } finally { | |
96 | - cleanup(); | |
97 | - } | |
98 | - } | |
99 | - | |
100 | - /** | |
101 | - * Start up and initialize OpenGL. | |
102 | - */ | |
103 | - private final static void init() throws Exception { | |
104 | - if (fullscreen) { | |
105 | - Window.create("Milkshape Model Animation (Fullscreen)", 16, 0, 8, 0); | |
106 | - } else { | |
107 | - Window.create("Milkshape Model Animation", 50, 50, 640, 480, 16, 0, 8, 0); | |
108 | - } | |
109 | - Keyboard.create(); | |
110 | - | |
111 | - model.load(modelFilename); | |
112 | - | |
113 | - if (WIREFRAME) { | |
114 | - GL.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE); | |
115 | - } else { | |
116 | - GL.glEnable(GL.GL_TEXTURE_2D); | |
117 | - GL.glShadeModel(GL.GL_SMOOTH); | |
118 | - } | |
119 | - GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
120 | - GL.glClearDepth(1.0); | |
121 | - GL.glEnable(GL.GL_DEPTH_TEST); | |
122 | - GL.glDepthFunc(GL.GL_LEQUAL); | |
123 | - | |
124 | - GL.glMatrixMode(GL.GL_PROJECTION); | |
125 | - GL.glLoadIdentity(); | |
126 | - | |
127 | - GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(), 100.0f, 2000.0f); | |
128 | - GL.glMatrixMode(GL.GL_MODELVIEW); | |
129 | - | |
130 | - GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
131 | - | |
132 | - GLCaps.determineAvailableExtensions(); | |
133 | - if (GLCaps.WGL_EXT_swap_control) { | |
134 | - GL.wglSwapIntervalEXT(1); | |
135 | - } | |
136 | - } | |
137 | - | |
138 | - /** | |
139 | - * Rendering method. | |
140 | - */ | |
141 | - private final static void render() { | |
142 | - if (!fullscreen && count++ > 20) { | |
143 | - Window.setTitle("Milkshape Model Animation"); | |
144 | - count = 0; | |
145 | - } | |
146 | - | |
147 | - GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
148 | - GL.glLoadIdentity(); | |
149 | - GLU.gluLookAt(50, 0, 300, 0, 0, 0, 0, 1, 0); | |
150 | - GL.glRotatef(yrot, 0.0f, 1.0f, 0.0f); | |
151 | - yrot += 0.3f; | |
152 | - model.render(); | |
153 | - } | |
154 | - | |
155 | - /** | |
156 | - * Main loop. | |
157 | - */ | |
158 | - private final static void mainLoop() { | |
159 | - processKeyboard(); | |
160 | - processWindow(); | |
161 | - } | |
162 | - | |
163 | - /** | |
164 | - * Process keyboard events. | |
165 | - */ | |
166 | - private final static void processKeyboard() { | |
167 | - if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { | |
168 | - finished = true; | |
169 | - } | |
170 | - if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { | |
171 | - dt += 0.01; | |
172 | - } | |
173 | - if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { | |
174 | - dt -= 0.01; dt = Math.max(0.05f, dt); | |
175 | - } | |
176 | - } | |
177 | - | |
178 | - /** | |
179 | - * Process window events. | |
180 | - */ | |
181 | - private final static void processWindow() { | |
182 | - if (Window.isCloseRequested()) { | |
183 | - finished = true; | |
184 | - } | |
185 | - } | |
186 | - | |
187 | - /** | |
188 | - * Cleanup. | |
189 | - */ | |
190 | - private final static void cleanup() { | |
191 | - Keyboard.destroy(); | |
192 | - Window.destroy(); | |
193 | - } | |
194 | - | |
195 | -} | |
\ No newline at end of file |