30 using System.Reflection;
31 using System.Collections.Generic;
33 using OpenSim.Framework;
36 namespace OpenSim.
Region.Framework.Scenes
45 public static class CollisionSounds
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 private const int MaxMaterials = 7;
52 private static UUID snd_StoneStone =
new UUID(
"be7295c0-a158-11e1-b3dd-0800200c9a66");
53 private static UUID snd_StoneMetal =
new UUID(
"be7295c0-a158-11e1-b3dd-0800201c9a66");
54 private static UUID snd_StoneGlass =
new UUID(
"be7295c0-a158-11e1-b3dd-0800202c9a66");
55 private static UUID snd_StoneWood =
new UUID(
"be7295c0-a158-11e1-b3dd-0800203c9a66");
56 private static UUID snd_StoneFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0800204c9a66");
57 private static UUID snd_StonePlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0800205c9a66");
58 private static UUID snd_StoneRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0800206c9a66");
60 private static UUID snd_MetalMetal =
new UUID(
"be7295c0-a158-11e1-b3dd-0801201c9a66");
61 private static UUID snd_MetalGlass =
new UUID(
"be7295c0-a158-11e1-b3dd-0801202c9a66");
62 private static UUID snd_MetalWood =
new UUID(
"be7295c0-a158-11e1-b3dd-0801203c9a66");
63 private static UUID snd_MetalFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0801204c9a66");
64 private static UUID snd_MetalPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0801205c9a66");
65 private static UUID snd_MetalRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0801206c9a66");
67 private static UUID snd_GlassGlass =
new UUID(
"be7295c0-a158-11e1-b3dd-0802202c9a66");
68 private static UUID snd_GlassWood =
new UUID(
"be7295c0-a158-11e1-b3dd-0802203c9a66");
69 private static UUID snd_GlassFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0802204c9a66");
70 private static UUID snd_GlassPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0802205c9a66");
71 private static UUID snd_GlassRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0802206c9a66");
73 private static UUID snd_WoodWood =
new UUID(
"be7295c0-a158-11e1-b3dd-0803203c9a66");
74 private static UUID snd_WoodFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0803204c9a66");
75 private static UUID snd_WoodPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0803205c9a66");
76 private static UUID snd_WoodRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0803206c9a66");
78 private static UUID snd_FleshFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0804204c9a66");
79 private static UUID snd_FleshPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0804205c9a66");
80 private static UUID snd_FleshRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0804206c9a66");
82 private static UUID snd_PlasticPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0805205c9a66");
83 private static UUID snd_PlasticRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0805206c9a66");
85 private static UUID snd_RubberRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0806206c9a66");
88 private static UUID snd_TerrainStone =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
89 private static UUID snd_TerrainMetal =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
90 private static UUID snd_TerrainGlass =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
91 private static UUID snd_TerrainWood =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
92 private static UUID snd_TerrainFlesh =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
93 private static UUID snd_TerrainPlastic =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
94 private static UUID snd_TerrainRubber =
new UUID(
"be7295c0-a158-11e1-b3dd-0807200c9a66");
96 public static UUID[] m_TerrainPart = {
107 public static UUID[] m_PartPart = {
108 snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber,
109 snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber,
110 snd_StoneGlass, snd_MetalGlass, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber,
111 snd_StoneWood, snd_MetalWood, snd_GlassWood, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber,
112 snd_StoneFlesh, snd_MetalFlesh, snd_GlassFlesh, snd_WoodFlesh, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber,
113 snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber,
114 snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber
117 public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist)
119 if (collidersinfolist.Count == 0 || part == null)
122 if (part.VolumeDetectActive || (part.Flags &
PrimFlags.Physics) == 0)
125 if (part.ParentGroup == null)
128 if (part.CollisionSoundType < 0)
132 bool HaveSound =
false;
134 UUID soundID = part.CollisionSound;
136 if (part.CollisionSoundType > 0)
139 volume = part.CollisionSoundVolume;
145 bool doneownsound =
false;
147 int thisMaterial = (int)part.Material;
148 if (thisMaterial >= MaxMaterials)
150 int thisMatScaled = thisMaterial * MaxMaterials;
152 CollisionForSoundInfo colInfo;
155 for(
int i = 0; i< collidersinfolist.Count; i++)
157 colInfo = collidersinfolist[i];
159 id = colInfo.colliderID;
166 volume = Math.Abs(colInfo.relativeVel);
170 volume *= volume * .0625f;
174 soundID = m_TerrainPart[thisMaterial];
176 part.SendCollisionSound(soundID, volume, colInfo.position);
182 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id);
183 if (otherPart != null)
185 if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive)
190 if (otherPart.CollisionSoundType > 0)
192 soundID = otherPart.CollisionSound;
193 volume = otherPart.CollisionSoundVolume;
199 volume = Math.Abs(colInfo.relativeVel);
203 volume *= volume * .0625f;
207 int otherMaterial = (int)otherPart.Material;
208 if (otherMaterial >= MaxMaterials)
211 soundID = m_PartPart[thisMatScaled + otherMaterial];
216 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
219 part.SendCollisionSound(soundID, volume, colInfo.position);
226 public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist)
228 if (collidersinfolist.Count == 0 || av == null)
234 int thisMaterial = 4;
236 int thisMatScaled = thisMaterial * MaxMaterials;
240 CollisionForSoundInfo colInfo;
244 for(
int i = 0; i< collidersinfolist.Count; i++)
246 colInfo = collidersinfolist[i];
248 id = colInfo.colliderID;
259 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
260 if (otherPart != null)
262 if (otherPart.CollisionSoundType < 0)
264 if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f)
265 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
268 volume = Math.Abs(colInfo.relativeVel);
277 volume *= volume * .0125f;
280 otherMaterial = (int)otherPart.Material;
281 if (otherMaterial >= MaxMaterials)
284 soundID = m_PartPart[thisMatScaled + otherMaterial];
285 otherPart.SendCollisionSound(soundID, volume, colInfo.position);