aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/llmaterialtable.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llprimitive/llmaterialtable.cpp676
1 files changed, 676 insertions, 0 deletions
diff --git a/linden/indra/llprimitive/llmaterialtable.cpp b/linden/indra/llprimitive/llmaterialtable.cpp
new file mode 100644
index 0000000..201d0c9
--- /dev/null
+++ b/linden/indra/llprimitive/llmaterialtable.cpp
@@ -0,0 +1,676 @@
1/**
2 * @file llmaterialtable.cpp
3 * @brief Table of material names and IDs for viewer
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29
30#include "llmaterialtable.h"
31#include "material_codes.h"
32#include "sound_ids.h"
33#include "imageids.h"
34
35LLMaterialTable LLMaterialTable::basic(1);
36
37F32 const LLMaterialTable::DEFAULT_FRICTION = 0.5f;
38F32 const LLMaterialTable::DEFAULT_RESTITUTION = 0.4f;
39
40LLMaterialTable::LLMaterialTable()
41{
42}
43
44LLMaterialTable::LLMaterialTable(U8 isBasic)
45{
46 initBasicTable();
47}
48
49LLMaterialTable::~LLMaterialTable()
50{
51 if (mCollisionSoundMatrix)
52 {
53 delete [] mCollisionSoundMatrix;
54 mCollisionSoundMatrix = NULL;
55 }
56
57 if (mSlidingSoundMatrix)
58 {
59 delete [] mSlidingSoundMatrix;
60 mSlidingSoundMatrix = NULL;
61 }
62
63 if (mRollingSoundMatrix)
64 {
65 delete [] mRollingSoundMatrix;
66 mRollingSoundMatrix = NULL;
67 }
68
69 mMaterialInfoList.deleteAllData();
70}
71
72void LLMaterialTable::initBasicTable()
73{
74 add(LL_MCODE_STONE,"Stone", LL_DEFAULT_STONE_UUID);
75 add(LL_MCODE_METAL,"Metal", LL_DEFAULT_METAL_UUID);
76 add(LL_MCODE_GLASS,"Glass", LL_DEFAULT_GLASS_UUID);
77 add(LL_MCODE_WOOD,"Wood", LL_DEFAULT_WOOD_UUID);
78 add(LL_MCODE_FLESH,"Flesh", LL_DEFAULT_FLESH_UUID);
79 add(LL_MCODE_PLASTIC,"Plastic", LL_DEFAULT_PLASTIC_UUID);
80 add(LL_MCODE_RUBBER,"Rubber", LL_DEFAULT_RUBBER_UUID);
81 add(LL_MCODE_LIGHT,"Light", LL_DEFAULT_LIGHT_UUID);
82
83 // specify densities for these materials. . .
84 // these were taken from http://www.mcelwee.net/html/densities_of_various_materials.html
85
86 addDensity(LL_MCODE_STONE,30.f);
87 addDensity(LL_MCODE_METAL,50.f);
88 addDensity(LL_MCODE_GLASS,20.f);
89 addDensity(LL_MCODE_WOOD,10.f);
90 addDensity(LL_MCODE_FLESH,10.f);
91 addDensity(LL_MCODE_PLASTIC,5.f);
92 addDensity(LL_MCODE_RUBBER,0.5f); //
93 addDensity(LL_MCODE_LIGHT,20.f); //
94
95 // add damage and energy values
96 addDamageAndEnergy(LL_MCODE_STONE, 1.f, 1.f, 1.f); // concrete
97 addDamageAndEnergy(LL_MCODE_METAL, 1.f, 1.f, 1.f); // steel
98 addDamageAndEnergy(LL_MCODE_GLASS, 1.f, 1.f, 1.f); // borosilicate glass
99 addDamageAndEnergy(LL_MCODE_WOOD, 1.f, 1.f, 1.f); // southern pine
100 addDamageAndEnergy(LL_MCODE_FLESH, 1.f, 1.f, 1.f); // saltwater
101 addDamageAndEnergy(LL_MCODE_PLASTIC, 1.f, 1.f, 1.f); // HDPE
102 addDamageAndEnergy(LL_MCODE_RUBBER, 1.f, 1.f, 1.f); //
103 addDamageAndEnergy(LL_MCODE_LIGHT, 1.f, 1.f, 1.f); //
104
105 addFriction(LL_MCODE_STONE,0.8f); // concrete
106 addFriction(LL_MCODE_METAL,0.3f); // steel
107 addFriction(LL_MCODE_GLASS,0.2f); // borosilicate glass
108 addFriction(LL_MCODE_WOOD,0.6f); // southern pine
109 addFriction(LL_MCODE_FLESH,0.9f); // saltwater
110 addFriction(LL_MCODE_PLASTIC,0.4f); // HDPE
111 addFriction(LL_MCODE_RUBBER,0.9f); //
112 addFriction(LL_MCODE_LIGHT,0.2f); //
113
114 addRestitution(LL_MCODE_STONE,0.4f); // concrete
115 addRestitution(LL_MCODE_METAL,0.4f); // steel
116 addRestitution(LL_MCODE_GLASS,0.7f); // borosilicate glass
117 addRestitution(LL_MCODE_WOOD,0.5f); // southern pine
118 addRestitution(LL_MCODE_FLESH,0.3f); // saltwater
119 addRestitution(LL_MCODE_PLASTIC,0.7f); // HDPE
120 addRestitution(LL_MCODE_RUBBER,0.9f); //
121 addRestitution(LL_MCODE_LIGHT,0.7f); //
122
123 addShatterSound(LL_MCODE_STONE,LLUUID("ea296329-0f09-4993-af1b-e6784bab1dc9"));
124 addShatterSound(LL_MCODE_METAL,LLUUID("d1375446-1c4d-470b-9135-30132433b678"));
125 addShatterSound(LL_MCODE_GLASS,LLUUID("85cda060-b393-48e6-81c8-2cfdfb275351"));
126 addShatterSound(LL_MCODE_WOOD,LLUUID("6f00669f-15e0-4793-a63e-c03f62fee43a"));
127 addShatterSound(LL_MCODE_FLESH,LLUUID("2d8c6f51-149e-4e23-8413-93a379b42b67"));
128 addShatterSound(LL_MCODE_PLASTIC,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
129 addShatterSound(LL_MCODE_RUBBER,LLUUID("212b6d1e-8d9c-4986-b3aa-f3c6df8d987d"));
130 addShatterSound(LL_MCODE_LIGHT,LLUUID("d55c7f3c-e1c3-4ddc-9eff-9ef805d9190e"));
131
132 // CollisionSounds
133 mCollisionSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
134 if (mCollisionSoundMatrix)
135 {
136 addCollisionSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_STONE_STONE);
137 addCollisionSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_STONE_METAL);
138 addCollisionSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_STONE_GLASS);
139 addCollisionSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_STONE_WOOD);
140 addCollisionSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_STONE_FLESH);
141 addCollisionSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_STONE_PLASTIC);
142 addCollisionSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_STONE_RUBBER);
143 addCollisionSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_STONE_PLASTIC);
144
145 addCollisionSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_METAL_METAL);
146 addCollisionSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_METAL_GLASS);
147 addCollisionSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_METAL_WOOD);
148 addCollisionSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_METAL_FLESH);
149 addCollisionSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_METAL_PLASTIC);
150 addCollisionSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_METAL_PLASTIC);
151 addCollisionSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_METAL_RUBBER);
152
153 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_GLASS_GLASS);
154 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_GLASS_WOOD);
155 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_GLASS_FLESH);
156 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_GLASS_PLASTIC);
157 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_GLASS_RUBBER);
158 addCollisionSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_GLASS_PLASTIC);
159
160 addCollisionSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_WOOD_WOOD);
161 addCollisionSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_WOOD_FLESH);
162 addCollisionSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_WOOD_PLASTIC);
163 addCollisionSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_WOOD_RUBBER);
164 addCollisionSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_WOOD_PLASTIC);
165
166 addCollisionSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_FLESH_FLESH);
167 addCollisionSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_FLESH_PLASTIC);
168 addCollisionSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_FLESH_RUBBER);
169 addCollisionSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_FLESH_PLASTIC);
170
171 addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_RUBBER_RUBBER);
172 addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_RUBBER_PLASTIC);
173 addCollisionSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_RUBBER_PLASTIC);
174
175 addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_PLASTIC_PLASTIC);
176 addCollisionSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
177
178 addCollisionSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_PLASTIC_PLASTIC);
179 }
180
181 // Sliding Sounds
182 mSlidingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
183 if (mSlidingSoundMatrix)
184 {
185 addSlidingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_SLIDE_STONE_STONE);
186 addSlidingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
187 addSlidingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
188 addSlidingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_SLIDE_STONE_WOOD);
189 addSlidingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
190 addSlidingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_SLIDE_STONE_PLASTIC);
191 addSlidingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_RUBBER);
192 addSlidingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_SLIDE_STONE_PLASTIC);
193
194 addSlidingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_METAL_METAL);
195 addSlidingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_SLIDE_METAL_GLASS);
196 addSlidingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_SLIDE_METAL_WOOD);
197 addSlidingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_METAL_FLESH);
198 addSlidingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
199 addSlidingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_METAL_RUBBER);
200 addSlidingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
201
202 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
203 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_SLIDE_STONE_STONE_01);
204 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
205 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
206 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
207 addSlidingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
208
209 addSlidingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_SLIDE_WOOD_WOOD);
210 addSlidingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_SLIDE_WOOD_FLESH);
211 addSlidingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_SLIDE_WOOD_PLASTIC);
212 addSlidingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
213 addSlidingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_SLIDE_WOOD_PLASTIC);
214
215 addSlidingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_FLESH_FLESH);
216 addSlidingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
217 addSlidingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
218 addSlidingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
219
220 addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
221 addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_RUBBER_PLASTIC);
222 addSlidingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_RUBBER_PLASTIC);
223
224 addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
225 addSlidingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
226
227 addSlidingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
228 }
229
230 // Rolling Sounds
231 mRollingSoundMatrix = new LLUUID[LL_MCODE_END*LL_MCODE_END];
232 if (mRollingSoundMatrix)
233 {
234 addRollingSound(LL_MCODE_STONE, LL_MCODE_STONE, SND_ROLL_STONE_STONE);
235 addRollingSound(LL_MCODE_STONE, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
236 addRollingSound(LL_MCODE_STONE, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
237 addRollingSound(LL_MCODE_STONE, LL_MCODE_WOOD, SND_ROLL_STONE_WOOD);
238 addRollingSound(LL_MCODE_STONE, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
239 addRollingSound(LL_MCODE_STONE, LL_MCODE_PLASTIC, SND_ROLL_STONE_PLASTIC);
240 addRollingSound(LL_MCODE_STONE, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
241 addRollingSound(LL_MCODE_STONE, LL_MCODE_LIGHT, SND_ROLL_STONE_PLASTIC);
242
243 addRollingSound(LL_MCODE_METAL, LL_MCODE_METAL, SND_SLIDE_STONE_STONE_01);
244 addRollingSound(LL_MCODE_METAL, LL_MCODE_GLASS, SND_ROLL_METAL_GLASS);
245 addRollingSound(LL_MCODE_METAL, LL_MCODE_WOOD, SND_ROLL_METAL_WOOD);
246 addRollingSound(LL_MCODE_METAL, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
247 addRollingSound(LL_MCODE_METAL, LL_MCODE_PLASTIC, SND_ROLL_METAL_WOOD);
248 addRollingSound(LL_MCODE_METAL, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
249 addRollingSound(LL_MCODE_METAL, LL_MCODE_LIGHT, SND_ROLL_METAL_WOOD);
250
251 addRollingSound(LL_MCODE_GLASS, LL_MCODE_GLASS, SND_SLIDE_STONE_STONE_01);
252 addRollingSound(LL_MCODE_GLASS, LL_MCODE_WOOD, SND_ROLL_GLASS_WOOD);
253 addRollingSound(LL_MCODE_GLASS, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
254 addRollingSound(LL_MCODE_GLASS, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
255 addRollingSound(LL_MCODE_GLASS, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
256 addRollingSound(LL_MCODE_GLASS, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
257
258 addRollingSound(LL_MCODE_WOOD, LL_MCODE_WOOD, SND_ROLL_WOOD_WOOD);
259 addRollingSound(LL_MCODE_WOOD, LL_MCODE_FLESH, SND_ROLL_WOOD_FLESH);
260 addRollingSound(LL_MCODE_WOOD, LL_MCODE_PLASTIC, SND_ROLL_WOOD_PLASTIC);
261 addRollingSound(LL_MCODE_WOOD, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
262 addRollingSound(LL_MCODE_WOOD, LL_MCODE_LIGHT, SND_ROLL_WOOD_PLASTIC);
263
264 addRollingSound(LL_MCODE_FLESH, LL_MCODE_FLESH, SND_SLIDE_STONE_STONE_01);
265 addRollingSound(LL_MCODE_FLESH, LL_MCODE_PLASTIC, SND_ROLL_FLESH_PLASTIC);
266 addRollingSound(LL_MCODE_FLESH, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
267 addRollingSound(LL_MCODE_FLESH, LL_MCODE_LIGHT, SND_ROLL_FLESH_PLASTIC);
268
269 addRollingSound(LL_MCODE_RUBBER, LL_MCODE_RUBBER, SND_SLIDE_STONE_STONE_01);
270 addRollingSound(LL_MCODE_RUBBER, LL_MCODE_PLASTIC, SND_SLIDE_STONE_STONE_01);
271 addRollingSound(LL_MCODE_RUBBER, LL_MCODE_LIGHT, SND_SLIDE_STONE_STONE_01);
272
273 addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_PLASTIC, SND_ROLL_PLASTIC_PLASTIC);
274 addRollingSound(LL_MCODE_PLASTIC, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
275
276 addRollingSound(LL_MCODE_LIGHT, LL_MCODE_LIGHT, SND_ROLL_PLASTIC_PLASTIC);
277 }
278}
279
280BOOL LLMaterialTable::add(U8 mcode, char* name, const LLUUID &uuid)
281{
282 LLMaterialInfo *infop;
283
284 infop = new LLMaterialInfo(mcode,name,uuid);
285 if (!infop) return FALSE;
286
287 // Add at the end so the order in menus matches the order in this
288 // file. JNC 11.30.01
289 mMaterialInfoList.addDataAtEnd(infop);
290
291 return TRUE;
292}
293
294BOOL LLMaterialTable::addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
295{
296 if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
297 {
298 mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
299 if (mcode != mcode2)
300 {
301 mCollisionSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
302 }
303 }
304 return TRUE;
305}
306
307BOOL LLMaterialTable::addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
308{
309 if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
310 {
311 mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
312 if (mcode != mcode2)
313 {
314 mSlidingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
315 }
316 }
317 return TRUE;
318}
319
320BOOL LLMaterialTable::addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid)
321{
322 if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
323 {
324 mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2] = uuid;
325 if (mcode != mcode2)
326 {
327 mRollingSoundMatrix[mcode2 * LL_MCODE_END + mcode] = uuid;
328 }
329 }
330 return TRUE;
331}
332
333BOOL LLMaterialTable::addShatterSound(U8 mcode, const LLUUID &uuid)
334{
335 LLMaterialInfo *infop;
336
337 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
338 {
339 if (mcode == infop->mMCode)
340 {
341 infop->mShatterSoundID = uuid;
342 return TRUE;
343 }
344 }
345
346 return FALSE;
347}
348
349BOOL LLMaterialTable::addDensity(U8 mcode, const F32 &density)
350{
351 LLMaterialInfo *infop;
352
353 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
354 {
355 if (mcode == infop->mMCode)
356 {
357 infop->mDensity = density;
358 return TRUE;
359 }
360 }
361
362 return FALSE;
363}
364
365BOOL LLMaterialTable::addRestitution(U8 mcode, const F32 &restitution)
366{
367 LLMaterialInfo *infop;
368
369 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
370 {
371 if (mcode == infop->mMCode)
372 {
373 infop->mRestitution = restitution;
374 return TRUE;
375 }
376 }
377
378 return FALSE;
379}
380
381BOOL LLMaterialTable::addFriction(U8 mcode, const F32 &friction)
382{
383 LLMaterialInfo *infop;
384
385 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
386 {
387 if (mcode == infop->mMCode)
388 {
389 infop->mFriction = friction;
390 return TRUE;
391 }
392 }
393
394 return FALSE;
395}
396
397BOOL LLMaterialTable::addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod)
398{
399 LLMaterialInfo *infop;
400
401 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
402 {
403 if (mcode == infop->mMCode)
404 {
405 infop->mHPModifier = hp_mod;
406 infop->mDamageModifier = damage_mod;
407 infop->mEPModifier = ep_mod;
408 return TRUE;
409 }
410 }
411
412 return FALSE;
413}
414
415LLUUID LLMaterialTable::getDefaultTextureID(char* name)
416{
417 LLMaterialInfo *infop;
418
419 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
420 {
421 if (!strcmp(name, infop->mName))
422 {
423 return infop->mDefaultTextureID;
424 }
425 }
426
427 return LLUUID::null;
428}
429
430
431LLUUID LLMaterialTable::getDefaultTextureID(U8 mcode)
432{
433 LLMaterialInfo *infop;
434
435 mcode &= LL_MCODE_MASK;
436
437 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
438 {
439 if (mcode == infop->mMCode)
440 {
441 return infop->mDefaultTextureID;
442 }
443 }
444
445 return LLUUID::null;
446}
447
448
449U8 LLMaterialTable::getMCode(const char* name)
450{
451 LLMaterialInfo *infop;
452
453 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
454 {
455 if (!strcmp(name, infop->mName))
456 {
457 return infop->mMCode;
458 }
459 }
460
461 return 0;
462}
463
464
465char* LLMaterialTable::getName(U8 mcode)
466{
467 LLMaterialInfo *infop;
468
469 mcode &= LL_MCODE_MASK;
470
471 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
472 {
473 if (mcode == infop->mMCode)
474 {
475 return infop->mName;
476 }
477 }
478
479 return NULL;
480}
481
482
483LLUUID LLMaterialTable::getCollisionSoundUUID(U8 mcode, U8 mcode2)
484{
485 mcode &= LL_MCODE_MASK;
486 mcode2 &= LL_MCODE_MASK;
487
488 //llinfos << "code 1: " << ((U32) mcode) << " code 2:" << ((U32) mcode2) << llendl;
489 if (mCollisionSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
490 {
491 return(mCollisionSoundMatrix[mcode * LL_MCODE_END + mcode2]);
492 }
493 else
494 {
495 //llinfos << "Null Sound" << llendl;
496 return(SND_NULL);
497 }
498}
499
500LLUUID LLMaterialTable::getSlidingSoundUUID(U8 mcode, U8 mcode2)
501{
502 mcode &= LL_MCODE_MASK;
503 mcode2 &= LL_MCODE_MASK;
504
505 if (mSlidingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
506 {
507 return(mSlidingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
508 }
509 else
510 {
511 return(SND_NULL);
512 }
513}
514
515LLUUID LLMaterialTable::getRollingSoundUUID(U8 mcode, U8 mcode2)
516{
517 mcode &= LL_MCODE_MASK;
518 mcode2 &= LL_MCODE_MASK;
519
520 if (mRollingSoundMatrix && (mcode < LL_MCODE_END) && (mcode2 < LL_MCODE_END))
521 {
522 return(mRollingSoundMatrix[mcode * LL_MCODE_END + mcode2]);
523 }
524 else
525 {
526 return(SND_NULL);
527 }
528}
529
530LLUUID LLMaterialTable::getGroundCollisionSoundUUID(U8 mcode)
531{
532 // Create material appropriate sounds for collisions with the ground
533 // For now, simply return a single sound for all materials
534 return SND_STONE_DIRT_02;
535}
536
537LLUUID LLMaterialTable::getGroundSlidingSoundUUID(U8 mcode)
538{
539 // Create material-specific sound for sliding on ground
540 // For now, just return a single sound
541 return SND_SLIDE_STONE_STONE_01;
542}
543
544LLUUID LLMaterialTable::getGroundRollingSoundUUID(U8 mcode)
545{
546 // Create material-specific sound for rolling on ground
547 // For now, just return a single sound
548 return SND_SLIDE_STONE_STONE_01;
549}
550
551LLUUID LLMaterialTable::getCollisionParticleUUID(U8 mcode, U8 mcode2)
552{
553 // Returns an appropriate UUID to use as sprite at collision betweeen objects
554 // For now, just return a single image
555 return IMG_SHOT;
556}
557
558LLUUID LLMaterialTable::getGroundCollisionParticleUUID(U8 mcode)
559{
560 // Returns an appropriate
561 // For now, just return a single sound
562 return IMG_SMOKE_POOF;
563}
564
565
566F32 LLMaterialTable::getDensity(U8 mcode)
567{
568 LLMaterialInfo *infop;
569
570 mcode &= LL_MCODE_MASK;
571 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
572 {
573 if (mcode == infop->mMCode)
574 {
575 return infop->mDensity;
576 }
577 }
578
579 return 0.f;
580}
581
582F32 LLMaterialTable::getRestitution(U8 mcode)
583{
584 LLMaterialInfo *infop;
585
586 mcode &= LL_MCODE_MASK;
587 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
588 {
589 if (mcode == infop->mMCode)
590 {
591 return infop->mRestitution;
592 }
593 }
594
595 return LLMaterialTable::DEFAULT_RESTITUTION;
596}
597
598F32 LLMaterialTable::getFriction(U8 mcode)
599{
600 LLMaterialInfo *infop;
601
602 mcode &= LL_MCODE_MASK;
603 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
604 {
605 if (mcode == infop->mMCode)
606 {
607 return infop->mFriction;
608 }
609 }
610
611 return LLMaterialTable::DEFAULT_FRICTION;
612}
613
614F32 LLMaterialTable::getHPMod(U8 mcode)
615{
616 LLMaterialInfo *infop;
617
618 mcode &= LL_MCODE_MASK;
619 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
620 {
621 if (mcode == infop->mMCode)
622 {
623 return infop->mHPModifier;
624 }
625 }
626
627 return 1.f;
628}
629
630F32 LLMaterialTable::getDamageMod(U8 mcode)
631{
632 LLMaterialInfo *infop;
633
634 mcode &= LL_MCODE_MASK;
635 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
636 {
637 if (mcode == infop->mMCode)
638 {
639 return infop->mDamageModifier;
640 }
641 }
642
643 return 1.f;
644}
645
646F32 LLMaterialTable::getEPMod(U8 mcode)
647{
648 LLMaterialInfo *infop;
649
650 mcode &= LL_MCODE_MASK;
651 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
652 {
653 if (mcode == infop->mMCode)
654 {
655 return infop->mEPModifier;
656 }
657 }
658
659 return 1.f;
660}
661
662LLUUID LLMaterialTable::getShatterSoundUUID(U8 mcode)
663{
664 LLMaterialInfo *infop;
665
666 mcode &= LL_MCODE_MASK;
667 for (infop = mMaterialInfoList.getFirstData(); infop != NULL; infop = mMaterialInfoList.getNextData() )
668 {
669 if (mcode == infop->mMCode)
670 {
671 return infop->mShatterSoundID;
672 }
673 }
674
675 return SND_NULL;
676}