llsettingswater.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /**
  2. * @file llsettingswater.h
  3. * @brief The water settings asset support class.
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2019, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_SETTINGSWATER_H
  33. #define LL_SETTINGSWATER_H
  34. #include "llsettingsbase.h"
  35. class LLSettingsWater : public LLSettingsBase
  36. {
  37. protected:
  38. LOG_CLASS(LLSettingsWater);
  39. LLSettingsWater();
  40. public:
  41. LLSettingsWater(const LLSD& data);
  42. ~LLSettingsWater() override {}
  43. typedef std::shared_ptr<LLSettingsWater> ptr_t;
  44. virtual ptr_t buildClone() const = 0;
  45. LL_INLINE LLSettingsBase::ptr_t buildDerivedClone() const override
  46. {
  47. return buildClone();
  48. }
  49. LL_INLINE std::string getSettingsType() const override
  50. {
  51. return "water";
  52. }
  53. LL_INLINE LLSettingsType::EType getSettingsTypeValue() const override
  54. {
  55. return LLSettingsType::ST_WATER;
  56. }
  57. // Settings status
  58. void blend(const LLSettingsBase::ptr_t& end, F64 blendf) override;
  59. void replaceSettings(const LLSD& settings) override;
  60. void replaceWithWater(LLSettingsWater::ptr_t other);
  61. static LLSD defaults(F32 position = 0.f);
  62. // Used to create a day cycle out of an existing sky setting. HB
  63. static void adjustTime(LLSD& settings, F32 position);
  64. LL_INLINE F32 getBlurMultiplier() const
  65. {
  66. update();
  67. return mBlurMultiplier;
  68. }
  69. LL_INLINE void setBlurMultiplier(F32 val)
  70. {
  71. setValue(SETTING_BLUR_MULTIPLIER, val);
  72. }
  73. LL_INLINE LLColor3 getWaterFogColor() const
  74. {
  75. update();
  76. return mWaterFogColor;
  77. }
  78. LL_INLINE void setWaterFogColor(LLColor3 val)
  79. {
  80. setValue(SETTING_FOG_COLOR, val);
  81. }
  82. LL_INLINE F32 getWaterFogDensity() const
  83. {
  84. update();
  85. return mWaterFogDensity;
  86. }
  87. F32 getModifiedWaterFogDensity(bool underwater) const;
  88. LL_INLINE void setWaterFogDensity(F32 val)
  89. {
  90. setValue(SETTING_FOG_DENSITY, val);
  91. }
  92. // NOTE: getFogMod() is not actually used for rendering... HB
  93. LL_INLINE F32 getFogMod() const
  94. {
  95. return mSettings[SETTING_FOG_MOD].asReal();
  96. }
  97. // NOTE: setFogMod() is not actually used for rendering... HB
  98. LL_INLINE void setFogMod(F32 val)
  99. {
  100. setValue(SETTING_FOG_MOD, val);
  101. }
  102. LL_INLINE F32 getFresnelOffset() const
  103. {
  104. update();
  105. return mFresnelOffset;
  106. }
  107. LL_INLINE void setFresnelOffset(F32 val)
  108. {
  109. setValue(SETTING_FRESNEL_OFFSET, val);
  110. }
  111. LL_INLINE F32 getFresnelScale() const
  112. {
  113. update();
  114. return mFresnelScale;
  115. }
  116. LL_INLINE void setFresnelScale(F32 val)
  117. {
  118. setValue(SETTING_FRESNEL_SCALE, val);
  119. }
  120. LL_INLINE LLUUID getTransparentTextureID() const
  121. {
  122. return mSettings[SETTING_TRANSPARENT_TEXTURE].asUUID();
  123. }
  124. LL_INLINE void setTransparentTextureID(const LLUUID& val)
  125. {
  126. setValue(SETTING_TRANSPARENT_TEXTURE, LLSD(val));
  127. }
  128. LLUUID getNormalMapID() const
  129. {
  130. return mSettings[SETTING_NORMAL_MAP].asUUID();
  131. }
  132. LL_INLINE void setNormalMapID(const LLUUID& val)
  133. {
  134. setValue(SETTING_NORMAL_MAP, LLSD(val));
  135. }
  136. LL_INLINE LLVector3 getNormalScale() const
  137. {
  138. update();
  139. return mNormalScale;
  140. }
  141. LL_INLINE void setNormalScale(LLVector3 val)
  142. {
  143. setValue(SETTING_NORMAL_SCALE, val);
  144. }
  145. LL_INLINE F32 getScaleAbove() const
  146. {
  147. update();
  148. return mScaleAbove;
  149. }
  150. LL_INLINE void setScaleAbove(F32 val)
  151. {
  152. setValue(SETTING_SCALE_ABOVE, val);
  153. }
  154. LL_INLINE F32 getScaleBelow() const
  155. {
  156. update();
  157. return mScaleBelow;
  158. }
  159. LL_INLINE void setScaleBelow(F32 val)
  160. {
  161. setValue(SETTING_SCALE_BELOW, val);
  162. }
  163. LL_INLINE LLVector2 getWave1Dir() const
  164. {
  165. update();
  166. return mWave1Dir;
  167. }
  168. LL_INLINE void setWave1Dir(LLVector2 val)
  169. {
  170. setValue(SETTING_WAVE1_DIR, val);
  171. }
  172. LL_INLINE LLVector2 getWave2Dir() const
  173. {
  174. update();
  175. return mWave2Dir;
  176. }
  177. LL_INLINE void setWave2Dir(LLVector2 val)
  178. {
  179. setValue(SETTING_WAVE2_DIR, val);
  180. }
  181. LL_INLINE LLUUID getNextNormalMapID() const
  182. {
  183. return mNextNormalMapID;
  184. }
  185. LL_INLINE LLUUID getNextTransparentTextureID() const
  186. {
  187. return mNextTransparentTextureID;
  188. }
  189. void updateSettings() override;
  190. const validation_list_t& getValidationList() const override;
  191. static const validation_list_t& validationList();
  192. static LLSD translateLegacySettings(const LLSD& legacy);
  193. static const LLUUID& getDefaultAssetId();
  194. static const LLUUID& getDefaultWaterNormalAssetId();
  195. static const LLUUID& getDefaultTransparentTextureAssetId();
  196. static const LLUUID& getDefaultOpaqueTextureAssetId();
  197. public:
  198. static const std::string SETTING_BLUR_MULTIPLIER;
  199. static const std::string SETTING_FOG_COLOR;
  200. static const std::string SETTING_FOG_DENSITY;
  201. static const std::string SETTING_FOG_MOD;
  202. static const std::string SETTING_FRESNEL_OFFSET;
  203. static const std::string SETTING_FRESNEL_SCALE;
  204. static const std::string SETTING_TRANSPARENT_TEXTURE;
  205. static const std::string SETTING_NORMAL_MAP;
  206. static const std::string SETTING_NORMAL_SCALE;
  207. static const std::string SETTING_SCALE_ABOVE;
  208. static const std::string SETTING_SCALE_BELOW;
  209. static const std::string SETTING_WAVE1_DIR;
  210. static const std::string SETTING_WAVE2_DIR;
  211. static const LLUUID DEFAULT_ASSET_ID;
  212. protected:
  213. static const std::string SETTING_LEGACY_BLUR_MULTIPLIER;
  214. static const std::string SETTING_LEGACY_FOG_COLOR;
  215. static const std::string SETTING_LEGACY_FOG_DENSITY;
  216. static const std::string SETTING_LEGACY_FOG_MOD;
  217. static const std::string SETTING_LEGACY_FRESNEL_OFFSET;
  218. static const std::string SETTING_LEGACY_FRESNEL_SCALE;
  219. static const std::string SETTING_LEGACY_NORMAL_MAP;
  220. static const std::string SETTING_LEGACY_NORMAL_SCALE;
  221. static const std::string SETTING_LEGACY_SCALE_ABOVE;
  222. static const std::string SETTING_LEGACY_SCALE_BELOW;
  223. static const std::string SETTING_LEGACY_WAVE1_DIR;
  224. static const std::string SETTING_LEGACY_WAVE2_DIR;
  225. LLUUID mNextTransparentTextureID;
  226. LLUUID mNextNormalMapID;
  227. private:
  228. LLColor3 mWaterFogColor;
  229. LLVector3 mNormalScale;
  230. LLVector2 mWave1Dir;
  231. LLVector2 mWave2Dir;
  232. F32 mWaterFogDensity;
  233. F32 mBlurMultiplier;
  234. F32 mFresnelOffset;
  235. F32 mFresnelScale;
  236. F32 mScaleAbove;
  237. F32 mScaleBelow;
  238. };
  239. #endif // LL_SETTINGSWATER_H