PageRenderTime 28ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llprimitive/llmaterialtable.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 188 lines | 112 code | 32 blank | 44 comment | 0 complexity | 873b7d47cf028896ac25539ef9e0c2f4 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmaterialtable.h
  3. * @brief Table of material information for the viewer UI
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLMATERIALTABLE_H
  27. #define LL_LLMATERIALTABLE_H
  28. #include "lluuid.h"
  29. #include "llstring.h"
  30. #include <list>
  31. class LLMaterialInfo;
  32. const U32 LLMATERIAL_INFO_NAME_LENGTH = 256;
  33. // We've moved toward more reasonable mass values for the Havok4 engine.
  34. // The LEGACY_DEFAULT_OBJECT_DENSITY is used to maintain support for
  35. // legacy scripts code (llGetMass()) and script energy consumption.
  36. const F32 DEFAULT_OBJECT_DENSITY = 1000.0f; // per m^3
  37. const F32 LEGACY_DEFAULT_OBJECT_DENSITY = 10.0f;
  38. // Avatars density depends on the collision shape used. The approximate
  39. // legacy volumes of avatars are:
  40. // Body_Length Body_Width Body_Fat Leg_Length Volume(m^3)
  41. // -------------------------------------------------------
  42. // min | min | min | min | 0.123 |
  43. // max | max | max | max | 0.208 |
  44. //
  45. // Either the avatar shape must be tweaked to match those volumes
  46. // or the DEFAULT_AVATAR_DENSITY must be adjusted to achieve the
  47. // legacy mass.
  48. //
  49. // The current density appears to be low because the mass and
  50. // inertia are computed as if the avatar were a cylinder which
  51. // has more volume than the actual collision shape of the avatar.
  52. // See the physics engine mass properties code for more info.
  53. const F32 DEFAULT_AVATAR_DENSITY = 445.3f; // was 444.24f;
  54. class LLMaterialTable
  55. {
  56. public:
  57. static const F32 FRICTION_MIN;
  58. static const F32 FRICTION_GLASS;
  59. static const F32 FRICTION_LIGHT;
  60. static const F32 FRICTION_METAL;
  61. static const F32 FRICTION_PLASTIC;
  62. static const F32 FRICTION_WOOD;
  63. static const F32 FRICTION_LAND;
  64. static const F32 FRICTION_STONE;
  65. static const F32 FRICTION_FLESH;
  66. static const F32 FRICTION_RUBBER;
  67. static const F32 FRICTION_MAX;
  68. static const F32 RESTITUTION_MIN;
  69. static const F32 RESTITUTION_LAND;
  70. static const F32 RESTITUTION_FLESH;
  71. static const F32 RESTITUTION_STONE;
  72. static const F32 RESTITUTION_METAL;
  73. static const F32 RESTITUTION_WOOD;
  74. static const F32 RESTITUTION_GLASS;
  75. static const F32 RESTITUTION_PLASTIC;
  76. static const F32 RESTITUTION_LIGHT;
  77. static const F32 RESTITUTION_RUBBER;
  78. static const F32 RESTITUTION_MAX;
  79. typedef std::list<LLMaterialInfo*> info_list_t;
  80. info_list_t mMaterialInfoList;
  81. LLUUID *mCollisionSoundMatrix;
  82. LLUUID *mSlidingSoundMatrix;
  83. LLUUID *mRollingSoundMatrix;
  84. static const F32 DEFAULT_FRICTION;
  85. static const F32 DEFAULT_RESTITUTION;
  86. public:
  87. LLMaterialTable();
  88. LLMaterialTable(U8); // cheat with an overloaded constructor to build our basic table
  89. ~LLMaterialTable();
  90. void initBasicTable();
  91. void initTableTransNames(std::map<std::string, std::string> namemap);
  92. BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid);
  93. BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
  94. BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
  95. BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
  96. BOOL addShatterSound(U8 mcode, const LLUUID &uuid);
  97. BOOL addDensity(U8 mcode, const F32 &density);
  98. BOOL addFriction(U8 mcode, const F32 &friction);
  99. BOOL addRestitution(U8 mcode, const F32 &restitution);
  100. BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod);
  101. LLUUID getDefaultTextureID(const std::string& name); // LLUUID::null if not found
  102. LLUUID getDefaultTextureID(U8 mcode); // LLUUID::null if not found
  103. U8 getMCode(const std::string& name); // 0 if not found
  104. std::string getName(U8 mcode);
  105. F32 getDensity(U8 mcode); // kg/m^3, 0 if not found
  106. F32 getFriction(U8 mcode); // physics values
  107. F32 getRestitution(U8 mcode); // physics values
  108. F32 getHPMod(U8 mcode);
  109. F32 getDamageMod(U8 mcode);
  110. F32 getEPMod(U8 mcode);
  111. LLUUID getCollisionSoundUUID(U8 mcode, U8 mcode2);
  112. LLUUID getSlidingSoundUUID(U8 mcode, U8 mcode2);
  113. LLUUID getRollingSoundUUID(U8 mcode, U8 mcode2);
  114. LLUUID getShatterSoundUUID(U8 mcode); // LLUUID::null if not found
  115. LLUUID getGroundCollisionSoundUUID(U8 mcode);
  116. LLUUID getGroundSlidingSoundUUID(U8 mcode);
  117. LLUUID getGroundRollingSoundUUID(U8 mcode);
  118. LLUUID getCollisionParticleUUID(U8 mcode, U8 mcode2);
  119. LLUUID getGroundCollisionParticleUUID(U8 mcode);
  120. static LLMaterialTable basic;
  121. };
  122. class LLMaterialInfo
  123. {
  124. public:
  125. U8 mMCode;
  126. std::string mName;
  127. LLUUID mDefaultTextureID;
  128. LLUUID mShatterSoundID;
  129. F32 mDensity; // kg/m^3
  130. F32 mFriction;
  131. F32 mRestitution;
  132. // damage and energy constants
  133. F32 mHPModifier; // modifier on mass based HP total
  134. F32 mDamageModifier; // modifier on KE based damage
  135. F32 mEPModifier; // modifier on mass based EP total
  136. LLMaterialInfo(U8 mcode, const std::string& name, const LLUUID &uuid)
  137. {
  138. init(mcode,name,uuid);
  139. };
  140. void init(U8 mcode, const std::string& name, const LLUUID &uuid)
  141. {
  142. mDensity = 1000.f; // default to 1000.0 (water)
  143. mFriction = LLMaterialTable::DEFAULT_FRICTION;
  144. mRestitution = LLMaterialTable::DEFAULT_RESTITUTION;
  145. mHPModifier = 1.f;
  146. mDamageModifier = 1.f;
  147. mEPModifier = 1.f;
  148. mMCode = mcode;
  149. mName = name;
  150. mDefaultTextureID = uuid;
  151. };
  152. ~LLMaterialInfo()
  153. {
  154. };
  155. };
  156. #endif