Main repository of MikuMikuStudio
修订版 | b95658d277b4ae00390661a0602967f7baeb9a4a (tree) |
---|---|
时间 | 2003-11-14 04:23:16 |
作者 | mojomonkey <mojomonkey@75d0...> |
Commiter | mojomonkey |
no longer needed.
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@152 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -1,297 +0,0 @@ | ||
1 | -/* | |
2 | - * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
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 | - * Redistributions of source code must retain the above copyright notice, this | |
9 | - * list of conditions and the following disclaimer. | |
10 | - * | |
11 | - * Redistributions in binary form must reproduce the above copyright notice, | |
12 | - * this list of conditions and the following disclaimer in the documentation | |
13 | - * and/or other materials provided with the distribution. | |
14 | - * | |
15 | - * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | - * names of its contributors may be used to endorse or promote products derived | |
17 | - * from this software without specific prior written permission. | |
18 | - * | |
19 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | - * POSSIBILITY OF SUCH DAMAGE. | |
30 | - * | |
31 | - */ | |
32 | -package com.jme.test.sound.action; | |
33 | - | |
34 | -import com.jme.app.AbstractGame; | |
35 | -import com.jme.input.InputController; | |
36 | -import com.jme.input.InputSystem; | |
37 | -import com.jme.input.KeyBindingManager; | |
38 | -import com.jme.input.KeyInput; | |
39 | -import com.jme.math.Vector3f; | |
40 | -import com.jme.renderer.Camera; | |
41 | -import com.jme.renderer.ColorRGBA; | |
42 | -import com.jme.scene.BoundingSphere; | |
43 | -import com.jme.scene.Line; | |
44 | -import com.jme.scene.Node; | |
45 | -import com.jme.scene.Point; | |
46 | -import com.jme.scene.TriMesh; | |
47 | -import com.jme.sound.SoundRenderer; | |
48 | -import com.jme.sound.SoundSystem; | |
49 | -import com.jme.sound.action.SoundForwardAction; | |
50 | -import com.jme.system.DisplaySystem; | |
51 | -import com.jme.system.JmeException; | |
52 | - | |
53 | -/** | |
54 | - * <code>TestForwardAction</code> | |
55 | - * @author Mark Powell | |
56 | - * @version | |
57 | - */ | |
58 | -public class TestSoundForwardAction extends AbstractGame { | |
59 | - private Node scene; | |
60 | - private Camera cam; | |
61 | - private Line l; | |
62 | - private Point p; | |
63 | - private TriMesh t; | |
64 | - private TriMesh t2; | |
65 | - private InputController input; | |
66 | - | |
67 | - /** | |
68 | - * Nothing to update. | |
69 | - * @see com.jme.app.AbstractGame#update() | |
70 | - */ | |
71 | - protected void update() { | |
72 | - input.update(1); | |
73 | - } | |
74 | - | |
75 | - /** | |
76 | - * Render the scene | |
77 | - * @see com.jme.app.AbstractGame#render() | |
78 | - */ | |
79 | - protected void render() { | |
80 | - display.getRenderer().clearBuffers(); | |
81 | - display.getRenderer().draw(scene); | |
82 | - } | |
83 | - | |
84 | - /** | |
85 | - * set up the display system and camera. | |
86 | - * @see com.jme.app.AbstractGame#initSystem() | |
87 | - */ | |
88 | - protected void initSystem() { | |
89 | - try { | |
90 | - display = DisplaySystem.getDisplaySystem(properties.getRenderer()); | |
91 | - display.createWindow( | |
92 | - properties.getWidth(), | |
93 | - properties.getHeight(), | |
94 | - properties.getDepth(), | |
95 | - properties.getFreq(), | |
96 | - properties.getFullscreen()); | |
97 | - cam = | |
98 | - display.getRenderer().getCamera( | |
99 | - properties.getWidth(), | |
100 | - properties.getHeight()); | |
101 | - | |
102 | - } catch (JmeException e) { | |
103 | - e.printStackTrace(); | |
104 | - System.exit(1); | |
105 | - } | |
106 | - ColorRGBA blackColor = new ColorRGBA(); | |
107 | - blackColor.r = 0; | |
108 | - blackColor.g = 0; | |
109 | - blackColor.b = 0; | |
110 | - display.getRenderer().setBackgroundColor(blackColor); | |
111 | - cam.setFrustum(1.0f, 1000.0f, -0.55f, 0.55f, 0.4125f, -0.4125f); | |
112 | - Vector3f loc = new Vector3f(4.0f, 0.0f, 0.0f); | |
113 | - Vector3f left = new Vector3f(0.0f, -1.0f, 0.0f); | |
114 | - Vector3f up = new Vector3f(0.0f, 0.0f, 1.0f); | |
115 | - Vector3f dir = new Vector3f(-1.0f, 0f, 0.0f); | |
116 | - cam.setFrame(loc, left, up, dir); | |
117 | - | |
118 | - display.getRenderer().setCamera(cam); | |
119 | - | |
120 | - input = new InputController(); | |
121 | - KeyBindingManager keyboard = KeyBindingManager.getKeyBindingManager(); | |
122 | - InputSystem.createInputSystem("LWJGL"); | |
123 | - SoundSystem system=SoundSystem.getSoundSystem("LWJGL"); | |
124 | - SoundRenderer soundRenderer = system.getRenderer(); | |
125 | - soundRenderer.addSoundPlayer("NPC"); | |
126 | - soundRenderer.addSoundPlayer("A"); | |
127 | - soundRenderer.loadSoundAs("walk", "data/sound/walk.wav"); | |
128 | - soundRenderer.loadSoundAs("do", "data/sound/03.mp3"); | |
129 | - soundRenderer.getSoundPlayer("A").play("do"); | |
130 | - soundRenderer.getSoundPlayer("A").setNumberOfBuffers(100); | |
131 | - keyboard.setKeyInput(InputSystem.getKeyInput()); | |
132 | - keyboard.set("forward", KeyInput.KEY_W); | |
133 | - input.setKeyBindingManager(keyboard); | |
134 | - SoundForwardAction forward = new SoundForwardAction(cam, 0.5f, soundRenderer.getSoundPlayer("NPC"), "walk"); | |
135 | - forward.setKey("forward"); | |
136 | - input.addAction(forward); | |
137 | - | |
138 | - | |
139 | - } | |
140 | - | |
141 | - /** | |
142 | - * set up the scene | |
143 | - * @see com.jme.app.AbstractGame#initGame() | |
144 | - */ | |
145 | - protected void initGame() { | |
146 | - Vector3f[] vertex = new Vector3f[1000]; | |
147 | - ColorRGBA[] color = new ColorRGBA[1000]; | |
148 | - for (int i = 0; i < 1000; i++) { | |
149 | - vertex[i] = new Vector3f(); | |
150 | - vertex[i].x = (float) Math.random() * 50; | |
151 | - vertex[i].y = (float) Math.random() * 50; | |
152 | - vertex[i].z = (float) Math.random() * 50; | |
153 | - color[i] = new ColorRGBA(); | |
154 | - color[i].r = (float) Math.random(); | |
155 | - color[i].g = (float) Math.random(); | |
156 | - color[i].b = (float) Math.random(); | |
157 | - color[i].a = 1.0f; | |
158 | - } | |
159 | - | |
160 | - l = new Line(vertex, null, color, null); | |
161 | - l.setLocalTranslation(new Vector3f(-200.0f, -25, -25)); | |
162 | - l.setModelBound(new BoundingSphere()); | |
163 | - l.updateModelBound(); | |
164 | - | |
165 | - Vector3f[] vertex2 = new Vector3f[1000]; | |
166 | - ColorRGBA[] color2 = new ColorRGBA[1000]; | |
167 | - for (int i = 0; i < 1000; i++) { | |
168 | - vertex2[i] = new Vector3f(); | |
169 | - vertex2[i].x = (float) Math.random() * -100 - 50; | |
170 | - vertex2[i].y = (float) Math.random() * 50 - 25; | |
171 | - vertex2[i].z = (float) Math.random() * 50 - 25; | |
172 | - | |
173 | - color2[i] = new ColorRGBA(); | |
174 | - color2[i].r = (float) Math.random(); | |
175 | - color2[i].g = (float) Math.random(); | |
176 | - color2[i].b = (float) Math.random(); | |
177 | - color2[i].a = 1.0f; | |
178 | - } | |
179 | - | |
180 | - p = new Point(vertex2, null, color2, null); | |
181 | - p.setLocalTranslation(new Vector3f(0.0f, 25, 0)); | |
182 | - p.setModelBound(new BoundingSphere()); | |
183 | - p.updateModelBound(); | |
184 | - Node pointNode = new Node(); | |
185 | - pointNode.attachChild(p); | |
186 | - | |
187 | - Vector3f[] verts = new Vector3f[3]; | |
188 | - ColorRGBA[] color3 = new ColorRGBA[3]; | |
189 | - | |
190 | - verts[0] = new Vector3f(); | |
191 | - verts[0].x = -50; | |
192 | - verts[0].y = 0; | |
193 | - verts[0].z = 0; | |
194 | - verts[1] = new Vector3f(); | |
195 | - verts[1].x = -50; | |
196 | - verts[1].y = 25; | |
197 | - verts[1].z = 25; | |
198 | - verts[2] = new Vector3f(); | |
199 | - verts[2].x = -50; | |
200 | - verts[2].y = 25; | |
201 | - verts[2].z = 0; | |
202 | - | |
203 | - color3[0] = new ColorRGBA(); | |
204 | - color3[0].r = 1; | |
205 | - color3[0].g = 0; | |
206 | - color3[0].b = 0; | |
207 | - color3[0].a = 1; | |
208 | - color3[1] = new ColorRGBA(); | |
209 | - color3[1].r = 0; | |
210 | - color3[1].g = 1; | |
211 | - color3[1].b = 0; | |
212 | - color3[1].a = 1; | |
213 | - color3[2] = new ColorRGBA(); | |
214 | - color3[2].r = 0; | |
215 | - color3[2].g = 0; | |
216 | - color3[2].b = 1; | |
217 | - color3[2].a = 1; | |
218 | - int[] indices = { 0, 1, 2 }; | |
219 | - | |
220 | - t = new TriMesh(verts, null, color3, null, indices); | |
221 | - t.setLocalTranslation(new Vector3f(-150, 0, 0)); | |
222 | - t.setModelBound(new BoundingSphere()); | |
223 | - t.updateModelBound(); | |
224 | - | |
225 | - pointNode.attachChild(t); | |
226 | - pointNode.setLocalTranslation(new Vector3f(0, -50, 0)); | |
227 | - | |
228 | - //should be culled: | |
229 | - | |
230 | - Vector3f[] verts2 = new Vector3f[3]; | |
231 | - ColorRGBA[] color4 = new ColorRGBA[3]; | |
232 | - | |
233 | - verts2[0] = new Vector3f(); | |
234 | - verts2[0].x = -50; | |
235 | - verts2[0].y = 0; | |
236 | - verts2[0].z = 0; | |
237 | - verts2[1] = new Vector3f(); | |
238 | - verts2[1].x = -50; | |
239 | - verts2[1].y = 25; | |
240 | - verts2[1].z = 25; | |
241 | - verts2[2] = new Vector3f(); | |
242 | - verts2[2].x = -50; | |
243 | - verts2[2].y = 25; | |
244 | - verts2[2].z = 0; | |
245 | - | |
246 | - color4[0] = new ColorRGBA(); | |
247 | - color4[0].r = 1; | |
248 | - color4[0].g = 0; | |
249 | - color4[0].b = 0; | |
250 | - color4[0].a = 1; | |
251 | - color4[1] = new ColorRGBA(); | |
252 | - color4[1].r = 0; | |
253 | - color4[1].g = 1; | |
254 | - color4[1].b = 0; | |
255 | - color4[1].a = 1; | |
256 | - color4[2] = new ColorRGBA(); | |
257 | - color4[2].r = 0; | |
258 | - color4[2].g = 0; | |
259 | - color4[2].b = 1; | |
260 | - color4[2].a = 1; | |
261 | - int[] indices2 = { 0, 1, 2 }; | |
262 | - | |
263 | - t2 = new TriMesh(verts2, null, color4, null, indices2); | |
264 | - t2.setLocalTranslation(new Vector3f(150, 0, 0)); | |
265 | - t2.setModelBound(new BoundingSphere()); | |
266 | - t2.updateModelBound(); | |
267 | - | |
268 | - scene = new Node(); | |
269 | - scene.attachChild(l); | |
270 | - scene.attachChild(pointNode); | |
271 | - scene.attachChild(t2); | |
272 | - cam.update(); | |
273 | - | |
274 | - scene.updateGeometricState(0.0f, true); | |
275 | - | |
276 | - } | |
277 | - | |
278 | - /** | |
279 | - * not used. | |
280 | - * @see com.jme.app.AbstractGame#reinit() | |
281 | - */ | |
282 | - protected void reinit() { | |
283 | - } | |
284 | - | |
285 | - /** | |
286 | - * not used. | |
287 | - * @see com.jme.app.AbstractGame#cleanup() | |
288 | - */ | |
289 | - protected void cleanup() { | |
290 | - } | |
291 | - | |
292 | - public static void main(String[] args) { | |
293 | - TestSoundForwardAction app = new TestSoundForwardAction(); | |
294 | - app.useDialogAlways(true); | |
295 | - app.start(); | |
296 | - } | |
297 | -} |