2
0

tsMaterialList.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _TSMATERIALLIST_H_
  23. #define _TSMATERIALLIST_H_
  24. #ifndef _MATERIALLIST_H_
  25. #include "materials/materialList.h"
  26. #endif
  27. #ifndef _PATH_H_
  28. #include "core/util/path.h"
  29. #endif
  30. /// Specialized material list for 3space objects.
  31. class TSMaterialList : public MaterialList
  32. {
  33. typedef MaterialList Parent;
  34. Vector<U32> mFlags;
  35. Vector<U32> mReflectanceMaps;
  36. Vector<U32> mBumpMaps;
  37. Vector<U32> mDetailMaps;
  38. Vector<F32> mDetailScales;
  39. Vector<F32> mReflectionAmounts;
  40. bool mNamesTransformed;
  41. void allocate(U32 sz);
  42. public:
  43. enum
  44. {
  45. S_Wrap = BIT(0),
  46. T_Wrap = BIT(1),
  47. Translucent = BIT(2),
  48. Additive = BIT(3),
  49. Subtractive = BIT(4),
  50. SelfIlluminating = BIT(5),
  51. NeverEnvMap = BIT(6),
  52. NoMipMap = BIT(7),
  53. MipMap_ZeroBorder = BIT(8),
  54. AuxiliaryMap = BIT(27) | BIT(28) | BIT(29) | BIT(30) | BIT(31) // DEPRECATED
  55. };
  56. TSMaterialList(U32 materialCount, const char **materialNames, const U32 * materialFlags,
  57. const U32 * reflectanceMaps, const U32 * bumpMaps, const U32 * detailMaps,
  58. const F32 * detailScales, const F32 * reflectionAmounts);
  59. TSMaterialList();
  60. TSMaterialList(const TSMaterialList*);
  61. ~TSMaterialList();
  62. void free();
  63. U32 getFlags(U32 index);
  64. void setFlags(U32 index, U32 value);
  65. bool renameMaterial(U32 index, const String& newName); // use to support reskinning
  66. /// pre-load only
  67. void push_back(const String &name, U32 flags,
  68. U32 a=0xFFFFFFFF, U32 b=0xFFFFFFFF, U32 c=0xFFFFFFFF,
  69. F32 dm=1.0f, F32 em=1.0f);
  70. void push_back(const char * name, U32 flags, Material* mat);
  71. /// @name IO
  72. /// Functions for reading/writing to/from streams
  73. /// @{
  74. bool write(Stream &);
  75. bool read(Stream &);
  76. /// @}
  77. protected:
  78. virtual void mapMaterial( U32 index );
  79. };
  80. #endif // _TSMATERIALLIST_H_