llmaterialtable.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLMATERIALTABLE_H
00033 #define LL_LLMATERIALTABLE_H
00034 
00035 #include "lluuid.h"
00036 #include "llstring.h"
00037 
00038 #include <list>
00039 
00040 const U32 LLMATERIAL_INFO_NAME_LENGTH = 256;
00041 
00042 // We've moved toward more reasonable mass values for the Havok4 engine.
00043 // The LEGACY_DEFAULT_OBJECT_DENSITY is used to maintain support for
00044 // legacy scripts code (llGetMass()) and script energy consumption.
00045 const F32 DEFAULT_OBJECT_DENSITY = 1000.0f;                     // per m^3
00046 const F32 LEGACY_DEFAULT_OBJECT_DENSITY = 10.0f;
00047 
00048 // Avatars density depends on the collision shape used.  The approximate
00049 // legacy volumes of avatars are:
00050 // Body_Length Body_Width Body_Fat Leg_Length  Volume(m^3)
00051 // -------------------------------------------------------
00052 //    min     |   min    |  min   |    min    |   0.123   |
00053 //    max     |   max    |  max   |    max    |   0.208   |
00054 //
00055 // Either the avatar shape must be tweaked to match those volumes
00056 // or the DEFAULT_AVATAR_DENSITY must be adjusted to achieve the 
00057 // legacy mass.
00058 //
00059 // The current density appears to be low because the mass and
00060 // inertia are computed as if the avatar were a cylinder which
00061 // has more volume than the actual collision shape of the avatar.
00062 // See the physics engine mass properties code for more info.
00063 const F32 DEFAULT_AVATAR_DENSITY = 445.3f;              // was 444.24f;
00064 
00065 
00066 class LLMaterialInfo
00067 {
00068 public:
00069         U8                  mMCode;
00070         char            mName[LLMATERIAL_INFO_NAME_LENGTH];     /* Flawfinder: ignore */
00071         LLUUID          mDefaultTextureID;
00072         LLUUID          mShatterSoundID;
00073         F32         mDensity;           // kg/m^3
00074         F32         mFriction;
00075         F32         mRestitution;
00076 
00077         // damage and energy constants
00078         F32                     mHPModifier;            // modifier on mass based HP total
00079         F32                     mDamageModifier;        // modifier on KE based damage
00080         F32                     mEPModifier;            // modifier on mass based EP total
00081 
00082         LLMaterialInfo(U8 mcode, char* name, const LLUUID &uuid)
00083         {
00084                 init(mcode,name,uuid);
00085         };
00086 
00087         void init(U8 mcode, char* name, const LLUUID &uuid)
00088         {
00089                 mName[0] = 0;
00090                 mDensity = 1000.f;             // default to 1000.0 (water)
00091                 mHPModifier = 1.f;
00092                 mDamageModifier = 1.f;
00093                 mEPModifier = 1.f;
00094 
00095                 mMCode = mcode;
00096                 if (name)
00097                 {
00098                         LLString::copy(mName,name,LLMATERIAL_INFO_NAME_LENGTH);
00099                 }
00100                 mDefaultTextureID = uuid;               
00101         };
00102 
00103         ~LLMaterialInfo()
00104         {
00105         };
00106 
00107 };
00108 
00109 class LLMaterialTable
00110 {
00111 public:
00112         static const F32 FRICTION_MIN;
00113         static const F32 FRICTION_GLASS;
00114         static const F32 FRICTION_LIGHT;
00115         static const F32 FRICTION_METAL;
00116         static const F32 FRICTION_PLASTIC;
00117         static const F32 FRICTION_WOOD;
00118         static const F32 FRICTION_LAND;
00119         static const F32 FRICTION_STONE;
00120         static const F32 FRICTION_FLESH;
00121         static const F32 FRICTION_RUBBER;
00122         static const F32 FRICTION_MAX;
00123 
00124         static const F32 RESTITUTION_MIN;
00125         static const F32 RESTITUTION_LAND;
00126         static const F32 RESTITUTION_FLESH;
00127         static const F32 RESTITUTION_STONE;
00128         static const F32 RESTITUTION_METAL;
00129         static const F32 RESTITUTION_WOOD;
00130         static const F32 RESTITUTION_GLASS;
00131         static const F32 RESTITUTION_PLASTIC;
00132         static const F32 RESTITUTION_LIGHT;
00133         static const F32 RESTITUTION_RUBBER;
00134         static const F32 RESTITUTION_MAX;
00135 
00136         typedef std::list<LLMaterialInfo*> info_list_t;
00137         info_list_t mMaterialInfoList;
00138 
00139         LLUUID *mCollisionSoundMatrix;
00140         LLUUID *mSlidingSoundMatrix;
00141         LLUUID *mRollingSoundMatrix;
00142 
00143         static const F32 DEFAULT_FRICTION;
00144         static const F32 DEFAULT_RESTITUTION;
00145 
00146 public:
00147         LLMaterialTable();
00148         LLMaterialTable(U8);  // cheat with an overloaded constructor to build our basic table
00149         ~LLMaterialTable();
00150 
00151         void initBasicTable();
00152 
00153         BOOL add(U8 mcode, char* name, const LLUUID &uuid);                      
00154         BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
00155         BOOL addSlidingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
00156         BOOL addRollingSound(U8 mcode, U8 mcode2, const LLUUID &uuid);
00157         BOOL addShatterSound(U8 mcode, const LLUUID &uuid);
00158         BOOL addDensity(U8 mcode, const F32 &density);
00159         BOOL addFriction(U8 mcode, const F32 &friction);
00160         BOOL addRestitution(U8 mcode, const F32 &restitution);
00161         BOOL addDamageAndEnergy(U8 mcode, const F32 &hp_mod, const F32 &damage_mod, const F32 &ep_mod);
00162 
00163         LLUUID getDefaultTextureID(char* name);                                 // LLUUID::null if not found
00164         LLUUID getDefaultTextureID(U8 mcode);                                   // LLUUID::null if not found
00165         U8     getMCode(const char* name);                                              // 0 if not found
00166         char*  getName(U8 mcode);
00167 
00168         F32 getDensity(U8 mcode);                                                       // kg/m^3, 0 if not found
00169         F32 getFriction(U8 mcode);                                                      // physics values
00170         F32 getRestitution(U8 mcode);                                               // physics values
00171         F32 getHPMod(U8 mcode);
00172         F32 getDamageMod(U8 mcode);
00173         F32 getEPMod(U8 mcode);
00174 
00175         LLUUID getCollisionSoundUUID(U8 mcode, U8 mcode2); 
00176         LLUUID getSlidingSoundUUID(U8 mcode, U8 mcode2); 
00177         LLUUID getRollingSoundUUID(U8 mcode, U8 mcode2); 
00178         LLUUID getShatterSoundUUID(U8 mcode);                                   // LLUUID::null if not found
00179 
00180         LLUUID getGroundCollisionSoundUUID(U8 mcode);
00181         LLUUID getGroundSlidingSoundUUID(U8 mcode);
00182         LLUUID getGroundRollingSoundUUID(U8 mcode);
00183         LLUUID getCollisionParticleUUID(U8 mcode, U8 mcode2);
00184         LLUUID getGroundCollisionParticleUUID(U8 mcode);
00185 
00186         static LLMaterialTable basic;
00187 };
00188 
00189 #endif
00190 

Generated on Fri May 16 08:32:45 2008 for SecondLife by  doxygen 1.5.5