terrMaterial.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 _TERRMATERIAL_H_
  23. #define _TERRMATERIAL_H_
  24. #ifndef _SIMBASE_H_
  25. #include "console/simBase.h"
  26. #endif
  27. #include "T3D/assets/ImageAsset.h"
  28. /// The TerrainMaterial class orginizes the material settings
  29. /// for a single terrain material layer.
  30. class TerrainMaterial : public SimObject
  31. {
  32. typedef SimObject Parent;
  33. protected:
  34. ///
  35. DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, GFXStaticTextureSRGBProfile)
  36. /// The size of the diffuse base map in meters
  37. /// used to generate its texture coordinates.
  38. F32 mDiffuseSize;
  39. ///
  40. DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, GFXNormalMapProfile)
  41. ///
  42. DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, GFXStaticTextureProfile)
  43. /// The size of the detail map in meters used
  44. /// to generate the texture coordinates for the
  45. /// detail and normal maps.
  46. F32 mDetailSize;
  47. ///
  48. F32 mDetailStrength;
  49. ///
  50. F32 mDetailDistance;
  51. ///
  52. DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, GFXStaticTextureProfile)
  53. bool mIsSRGB;
  54. bool mInvertRoughness;
  55. /// Normally the detail is projected on to the xy
  56. /// coordinates of the terrain. If this flag is true
  57. /// then this detail is projected along the xz and yz
  58. /// planes.
  59. bool mSideProjection;
  60. DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, GFXStaticTextureProfile)
  61. F32 mMacroSize;
  62. F32 mMacroStrength;
  63. F32 mMacroDistance;
  64. ///
  65. F32 mParallaxScale;
  66. /// Depth for blending the textures using the new
  67. /// blending method. Higher numbers = larger blend
  68. /// radius.
  69. F32 mBlendDepth;
  70. F32 mBlendContrast;
  71. F32 mBlendHardness;
  72. public:
  73. TerrainMaterial();
  74. virtual ~TerrainMaterial();
  75. bool onAdd() override;
  76. static void initPersistFields();
  77. DECLARE_CONOBJECT( TerrainMaterial );
  78. /// This method locates the TerrainMaterial if it exists, tries
  79. /// to create a new one if a valid texture path was passed, or
  80. /// returns a debug material if all else fails.
  81. static TerrainMaterial* findOrCreate( const char *nameOrPath );
  82. /// Returns the default warning terrain material used when
  83. /// a material is not found or defined.
  84. static TerrainMaterial* getWarningMaterial();
  85. F32 getDiffuseSize() const { return mDiffuseSize; }
  86. F32 getDetailSize() const { return mDetailSize; }
  87. F32 getDetailStrength() const { return mDetailStrength; }
  88. F32 getDetailDistance() const { return mDetailDistance; }
  89. F32 getMacroSize() const { return mMacroSize; }
  90. F32 getMacroDistance() const { return mMacroDistance; }
  91. F32 getMacroStrength() const { return mMacroStrength; }
  92. bool useSideProjection() const { return mSideProjection; }
  93. F32 getParallaxScale() const { return mParallaxScale; }
  94. F32 getBlendDepth() const { return mBlendDepth; }
  95. F32 getBlendContrast() const { return mBlendContrast; }
  96. F32 getBlendHardness() const { return mBlendHardness; }
  97. bool getIsSRGB() const { return mIsSRGB; }
  98. bool getInvertRoughness() const { return mInvertRoughness; }
  99. };
  100. #endif // _TERRMATERIAL_H_