aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/CollisionSounds.cs271
1 files changed, 271 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
new file mode 100644
index 0000000..5d43027
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -0,0 +1,271 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
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 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27// Ubit 2012
28
29using System;
30using System.Collections.Generic;
31using OpenMetaverse;
32using OpenSim.Framework;
33
34namespace OpenSim.Region.Framework.Scenes
35{
36 public static class CollisionSounds
37 {
38 // defines for cases
39 // only know one UUID for now (woodflesh)
40
41 private const int MaxMaterials = 7;
42 // part part
43 private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
44 private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
45 private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
46 private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
47 private static UUID snd_StoneFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
48 private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
49 private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
50
51 private static UUID snd_MetalStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
52 private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
53 private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
54 private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
55 private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
56 private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
57 private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
58
59 private static UUID snd_GlassStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
60 private static UUID snd_GlassMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
61 private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
62 private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
63 private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
64 private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
65 private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
66
67 private static UUID snd_WoodStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
68 private static UUID snd_WoodMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
69 private static UUID snd_WoodGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
70 private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
71 private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
72 private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
73 private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
74
75 private static UUID snd_FleshStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
76 private static UUID snd_FleshMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
77 private static UUID snd_FleshGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
78 private static UUID snd_FleshWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
79 private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
80 private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
81 private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
82
83 private static UUID snd_PlasticStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
84 private static UUID snd_PlasticMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
85 private static UUID snd_PlasticGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
86 private static UUID snd_PlasticWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
87 private static UUID snd_PlasticFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
88 private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
89 private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
90
91 private static UUID snd_RubberStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
92 private static UUID snd_RubberMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
93 private static UUID snd_RubberGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
94 private static UUID snd_RubberWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
95 private static UUID snd_RubberFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
96 private static UUID snd_RubberPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
97 private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
98
99 // terrain part
100 private static UUID snd_TerrainStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
101 private static UUID snd_TerrainMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
102 private static UUID snd_TerrainGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
103 private static UUID snd_TerrainWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
104 private static UUID snd_TerrainFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
105 private static UUID snd_TerrainPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
106 private static UUID snd_TerrainRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a");
107
108 public static UUID[] m_TerrainPart = {
109 snd_TerrainStone,
110 snd_TerrainMetal,
111 snd_TerrainGlass,
112 snd_TerrainWood,
113 snd_TerrainFlesh,
114 snd_TerrainPlastic,
115 snd_TerrainRubber
116 };
117
118 public static UUID[] m_PartPart = {
119 snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber,
120 snd_MetalStone, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber,
121 snd_GlassStone, snd_GlassMetal, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber,
122 snd_WoodStone, snd_WoodMetal, snd_WoodGlass, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber,
123 snd_FleshStone, snd_FleshMetal, snd_FleshGlass, snd_FleshWood, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber,
124 snd_PlasticStone, snd_PlasticMetal, snd_PlasticGlass, snd_PlasticWood, snd_PlasticFlesh, snd_PlasticPlastic, snd_PlasticRubber,
125 snd_RubberStone, snd_RubberMetal, snd_RubberGlass, snd_RubberWood, snd_RubberFlesh, snd_RubberPlastic, snd_RubberRubber
126 };
127
128 public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders)
129 {
130 if(Colliders.Count == 0 || part == null)
131 return;
132
133 if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0)
134 return;
135
136 if (part.ParentGroup == null)
137 return;
138
139 if (part.CollisionSound == part.invalidCollisionSoundUUID)
140 return;
141
142 UUID soundID;
143 int otherMaterial;
144
145 Vector3 position = part.AbsolutePosition;
146
147 if (part.CollisionSound != UUID.Zero)
148 {
149 if (part.CollisionSoundVolume > 0.0f)
150 part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position);
151 return;
152 }
153
154 int thisMaterial = (int) part.Material;
155 if (thisMaterial >= MaxMaterials)
156 thisMaterial = 3;
157
158 int thisMatScaled = thisMaterial * MaxMaterials;
159 int index;
160
161 bool doneownsound = false;
162
163 foreach (uint Id in Colliders)
164 {
165 if (Id == 0)
166 {
167 if (!doneownsound)
168 {
169 soundID = m_TerrainPart[thisMaterial];
170 part.SendCollisionSound(soundID, 1.0, position);
171 doneownsound = true;
172 }
173 continue;
174 }
175
176 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id);
177 if (otherPart != null)
178 {
179 if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive)
180 continue;
181 if (otherPart.CollisionSound != UUID.Zero)
182 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position);
183 else
184 {
185 otherMaterial = (int)otherPart.Material;
186 if (otherMaterial >= MaxMaterials)
187 otherMaterial = 3;
188 index = thisMatScaled + otherMaterial;
189 soundID = m_PartPart[index];
190 if (doneownsound)
191 otherPart.SendCollisionSound(soundID, 1.0, position);
192 else
193 {
194 part.SendCollisionSound(soundID, 1.0, position);
195 doneownsound = true;
196 }
197 }
198 }
199/* avatars get notification let them trigger the sound
200 else if (!doneownsound)
201 {
202 ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id);
203 if (av != null && (!av.IsChildAgent))
204 {
205 index = thisMatScaled + 4; // flesh
206 soundID = m_PartPart[index];
207 part.SendCollisionSound(soundID, 1.0);
208 doneownsound = true;
209 }
210 }
211 */
212 }
213 }
214
215 public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders)
216 {
217 if (Colliders.Count == 0 || av == null)
218 return;
219
220 UUID soundID;
221 int otherMaterial;
222
223 int thisMaterial = 3;
224
225 int thisMatScaled = thisMaterial * MaxMaterials;
226 int index;
227// bool doneownsound = false;
228
229 Vector3 position = av.AbsolutePosition;
230
231 foreach (uint Id in Colliders)
232 {
233 if (Id == 0)
234 {
235 continue;
236 }
237
238 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id);
239 if (otherPart != null)
240 {
241 if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID)
242 continue;
243 if (otherPart.CollisionSound != UUID.Zero)
244 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position);
245 else
246 {
247 otherMaterial = (int)otherPart.Material;
248 if (otherMaterial >= MaxMaterials)
249 otherMaterial = 3;
250 index = thisMatScaled + otherMaterial;
251 soundID = m_PartPart[index];
252 otherPart.SendCollisionSound(soundID, 1.0, position);
253 }
254 }
255/*
256 else if (!doneownsound)
257 {
258 ScenePresence otherav = av.Scene.GetScenePresence(Id);
259 if (otherav != null && (!otherav.IsChildAgent))
260 {
261 soundID = snd_FleshFlesh;
262 av.SendCollisionSound(soundID, 1.0);
263 doneownsound = true;
264 }
265 }
266 */
267 }
268 }
269
270 }
271} \ No newline at end of file