terrMaterial.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /// The TerrainMaterial class orginizes the material settings
  28. /// for a single terrain material layer.
  29. class TerrainMaterial : public SimObject
  30. {
  31. typedef SimObject Parent;
  32. protected:
  33. ///
  34. FileName mDiffuseMap;
  35. /// The size of the diffuse base map in meters
  36. /// used to generate its texture coordinates.
  37. F32 mDiffuseSize;
  38. ///
  39. FileName mNormalMap;
  40. ///
  41. FileName mDetailMap;
  42. /// The size of the detail map in meters used
  43. /// to generate the texture coordinates for the
  44. /// detail and normal maps.
  45. F32 mDetailSize;
  46. ///
  47. F32 mDetailStrength;
  48. ///
  49. F32 mDetailDistance;
  50. /// Normally the detail is projected on to the xy
  51. /// coordinates of the terrain. If this flag is true
  52. /// then this detail is projected along the xz and yz
  53. /// planes.
  54. bool mSideProjection;
  55. FileName mMacroMap;
  56. F32 mMacroSize;
  57. F32 mMacroStrength;
  58. F32 mMacroDistance;
  59. ///
  60. F32 mParallaxScale;
  61. public:
  62. TerrainMaterial();
  63. virtual ~TerrainMaterial();
  64. bool onAdd();
  65. static void initPersistFields();
  66. DECLARE_CONOBJECT( TerrainMaterial );
  67. /// This method locates the TerrainMaterial if it exists, tries
  68. /// to create a new one if a valid texture path was passed, or
  69. /// returns a debug material if all else fails.
  70. static TerrainMaterial* findOrCreate( const char *nameOrPath );
  71. /// Returns the default warning terrain material used when
  72. /// a material is not found or defined.
  73. static TerrainMaterial* getWarningMaterial();
  74. const String& getDiffuseMap() const { return mDiffuseMap; }
  75. F32 getDiffuseSize() const { return mDiffuseSize; }
  76. const String& getNormalMap() const { return mNormalMap; }
  77. const String& getDetailMap() const { return mDetailMap; }
  78. const String& getMacroMap() const { return mMacroMap; }
  79. F32 getDetailSize() const { return mDetailSize; }
  80. F32 getDetailStrength() const { return mDetailStrength; }
  81. F32 getDetailDistance() const { return mDetailDistance; }
  82. F32 getMacroSize() const { return mMacroSize; }
  83. F32 getMacroDistance() const { return mMacroDistance; }
  84. F32 getMacroStrength() const { return mMacroStrength; }
  85. bool useSideProjection() const { return mSideProjection; }
  86. F32 getParallaxScale() const { return mParallaxScale; }
  87. };
  88. #endif // _TERRMATERIAL_H_