• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

Revision097b4cf056b7ffdb9e40432f39ecb4cff97bdc45 (tree)
Time2003-10-27 20:28:56
AuthorAnakan <Anakan@75d0...>
CommiterAnakan

Log Message

Test the sound movement

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@115 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Change Summary

Incremental Difference

--- /dev/null
+++ b/src/com/jme/test/sound/TestSoundMove.java
@@ -0,0 +1,235 @@
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+
33+/*
34+ * Created on 26 oct. 2003
35+ *
36+ */
37+package com.jme.test.sound;
38+import com.jme.app.AbstractGame;
39+import com.jme.image.Texture;
40+import com.jme.input.RelativeMouse;
41+import com.jme.input.InputSystem;
42+import com.jme.math.Vector3f;
43+import com.jme.renderer.Camera;
44+import com.jme.renderer.ColorRGBA;
45+import com.jme.renderer.LWJGLCamera;
46+import com.jme.scene.Node;
47+import com.jme.scene.Text;
48+import com.jme.scene.state.AlphaState;
49+import com.jme.scene.state.TextureState;
50+import com.jme.system.JmeException;
51+import com.jme.system.LWJGLDisplaySystem;
52+import com.jme.util.TextureManager;
53+
54+import com.jme.sound.SoundSystem;
55+import com.jme.sound.SoundRenderer;
56+/**
57+ * @author Arman Ozcelik
58+ *
59+ */
60+public class TestSoundMove extends AbstractGame {
61+
62+ private Text text;
63+ private Camera cam;
64+ private Node scene;
65+ private SoundRenderer soundRenderer;
66+ private RelativeMouse mouse;
67+ float x;
68+ float y;
69+
70+ public static void main(String[] args) {
71+ TestSoundMove app = new TestSoundMove();
72+ app.useDialogAlways(true);
73+ app.start();
74+ }
75+
76+ /**
77+ * Not used.
78+ * @see com.jme.app.AbstractGame#update()
79+ */
80+ protected void update() {
81+ mouse.update();
82+
83+ if (!soundRenderer.getSoundPlayer("NPC").isPlaying()) {
84+ soundRenderer.getSoundPlayer("NPC").play("bored");
85+
86+ } else {
87+ if (mouse.getLocalTranslation().x > 0) {
88+ x+=0.05f;
89+ } else if (mouse.getLocalTranslation().x < 0) {
90+ x-= 0.5f;
91+ }
92+ if (mouse.getLocalTranslation().y > 0) {
93+ y+=0.05f;
94+ } else if (mouse.getLocalTranslation().y < 0) {
95+ y-=0.05f;
96+ }
97+ soundRenderer.getSoundPlayer("NPC").updatePosition(x, y, 0);
98+ text.print("Position: x=" + x + " , y=" +
99+ y);
100+ }
101+ }
102+
103+ /**
104+ * draws the scene graph
105+ * @see com.jme.app.AbstractGame#render()
106+ */
107+ protected void render() {
108+ display.getRenderer().clearBuffers();
109+
110+ display.getRenderer().draw(scene);
111+
112+ }
113+
114+ /**
115+ * initializes the display and camera.
116+ * @see com.jme.app.AbstractGame#initSystem()
117+ */
118+ protected void initSystem() {
119+ try {
120+ if ("LWJGL".equalsIgnoreCase(properties.getRenderer())) {
121+ display = new LWJGLDisplaySystem();
122+ display.createWindow(
123+ properties.getWidth(),
124+ properties.getHeight(),
125+ properties.getDepth(),
126+ properties.getFreq(),
127+ properties.getFullscreen());
128+ cam = new LWJGLCamera(properties.getWidth(), properties.getHeight());
129+ }
130+ } catch (JmeException e) {
131+ e.printStackTrace();
132+ System.exit(1);
133+ }
134+ InputSystem.createInputSystem(properties.getRenderer());
135+ SoundSystem system = SoundSystem.getSoundSystem("LWJGL");
136+ soundRenderer = system.getRenderer();
137+
138+ ColorRGBA blueColor = new ColorRGBA();
139+ blueColor.r = 0;
140+ blueColor.g = 0;
141+ display.getRenderer().setBackgroundColor(blueColor);
142+ cam.setFrustum(1.0f, 1000.0f, -0.55f, 0.55f, 0.4125f, -0.4125f);
143+ Vector3f loc = new Vector3f(4.0f, 0.0f, 0.0f);
144+ Vector3f left = new Vector3f(0.0f, -1.0f, 0.0f);
145+ Vector3f up = new Vector3f(0.0f, 0.0f, 1.0f);
146+ Vector3f dir = new Vector3f(-1.0f, 0f, 0.0f);
147+ cam.setFrame(loc, left, up, dir);
148+
149+ display.getRenderer().setCamera(cam);
150+
151+ }
152+
153+ /**
154+ * initializes the scene
155+ * @see com.jme.app.AbstractGame#initGame()
156+ */
157+ protected void initGame() {
158+ mouse = new RelativeMouse();
159+ TextureState cursor = display.getRenderer().getTextureState();
160+ cursor.setEnabled(true);
161+ cursor.setTexture(
162+ TextureManager.loadTexture(
163+ "data/cursor/test.PNG",
164+ Texture.MM_LINEAR,
165+ Texture.FM_LINEAR,
166+ true));
167+ mouse.setRenderState(cursor);
168+ mouse.setMouseInput(InputSystem.getMouseInput());
169+ text = new Text("Testing Sound move");
170+ text.setLocalTranslation(new Vector3f(1, 60, 0));
171+ TextureState ts = display.getRenderer().getTextureState();
172+ ts.setEnabled(true);
173+ ts.setTexture(
174+ TextureManager.loadTexture(
175+ "data/Font/font.png",
176+ Texture.MM_LINEAR,
177+ Texture.FM_LINEAR,
178+ true));
179+ text.setRenderState(ts);
180+ AlphaState as1 = display.getRenderer().getAlphaState();
181+ as1.setBlendEnabled(true);
182+ as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
183+ as1.setDstFunction(AlphaState.DB_ONE);
184+ as1.setTestEnabled(true);
185+ as1.setTestFunction(AlphaState.TF_GREATER);
186+
187+ AlphaState as2 = display.getRenderer().getAlphaState();
188+ as2.setBlendEnabled(true);
189+ as2.setSrcFunction(AlphaState.SB_ONE);
190+ as2.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_COLOR);
191+ as2.setTestEnabled(true);
192+ as2.setTestFunction(AlphaState.TF_GREATER);
193+ text.setRenderState(as1);
194+ mouse.setRenderState(as1);
195+
196+ text.setRenderState(as1);
197+ scene = new Node();
198+ scene.attachChild(text);
199+ scene.attachChild(mouse);
200+ cam.update();
201+
202+ scene.updateGeometricState(0.0f, true);
203+
204+ soundRenderer.addSoundPlayer("MONSTER");
205+ soundRenderer.addSoundPlayer("NPC");
206+
207+ soundRenderer.loadSoundAs("music", "walk.wav");
208+ soundRenderer.loadSoundAs("bored", "03.mp3");
209+
210+ soundRenderer.getSoundPlayer("MONSTER").setNumberOfBuffers(1);
211+ soundRenderer.getSoundPlayer("NPC").setNumberOfBuffers(128);
212+
213+ soundRenderer.getSoundPlayer("MONSTER").updatePosition(0, 0, 0);
214+ soundRenderer.getSoundPlayer("NPC").updatePosition(0, 0, 0);
215+ soundRenderer.getSoundPlayer("NPC").updateVelocity(0, 0, 0);
216+
217+ }
218+
219+ /**
220+ * not used.
221+ * @see com.jme.app.AbstractGame#reinit()
222+ */
223+ protected void reinit() {
224+
225+ }
226+
227+ /**
228+ * not used.
229+ * @see com.jme.app.AbstractGame#cleanup()
230+ */
231+ protected void cleanup() {
232+
233+ }
234+
235+}
\ No newline at end of file