llmaterialtable.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:25k
源码类别:

游戏引擎

开发平台:

C++ Builder

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