PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llwlparamset.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 238 lines | 94 code | 62 blank | 82 comment | 1 complexity | 83398e0250589eafe0d8e847ba90f75e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llwlparamset.h
  3. * @brief Interface for the LLWLParamSet class.
  4. *
  5. * $LicenseInfo:firstyear=2005&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_WLPARAM_SET_H
  27. #define LL_WLPARAM_SET_H
  28. #include <string>
  29. #include <map>
  30. #include "v4math.h"
  31. #include "v4color.h"
  32. class LLWLParamSet;
  33. class LLGLSLShader;
  34. /// A class representing a set of parameter values for the WindLight shaders.
  35. class LLWLParamSet {
  36. friend class LLWLParamManager;
  37. public:
  38. std::string mName;
  39. private:
  40. LLSD mParamValues;
  41. float mCloudScrollXOffset, mCloudScrollYOffset;
  42. public:
  43. LLWLParamSet();
  44. /// Update this set of shader uniforms from the parameter values.
  45. void update(LLGLSLShader * shader) const;
  46. /// set the total llsd
  47. void setAll(const LLSD& val);
  48. /// get the total llsd
  49. const LLSD& getAll();
  50. /// Set a float parameter.
  51. /// \param paramName The name of the parameter to set.
  52. /// \param x The float value to set.
  53. void set(const std::string& paramName, float x);
  54. /// Set a float2 parameter.
  55. /// \param paramName The name of the parameter to set.
  56. /// \param x The x component's value to set.
  57. /// \param y The y component's value to set.
  58. void set(const std::string& paramName, float x, float y);
  59. /// Set a float3 parameter.
  60. /// \param paramName The name of the parameter to set.
  61. /// \param x The x component's value to set.
  62. /// \param y The y component's value to set.
  63. /// \param z The z component's value to set.
  64. void set(const std::string& paramName, float x, float y, float z);
  65. /// Set a float4 parameter.
  66. /// \param paramName The name of the parameter to set.
  67. /// \param x The x component's value to set.
  68. /// \param y The y component's value to set.
  69. /// \param z The z component's value to set.
  70. /// \param w The w component's value to set.
  71. void set(const std::string& paramName, float x, float y, float z, float w);
  72. /// Set a float4 parameter.
  73. /// \param paramName The name of the parameter to set.
  74. /// \param val An array of the 4 float values to set the parameter to.
  75. void set(const std::string& paramName, const float * val);
  76. /// Set a float4 parameter.
  77. /// \param paramName The name of the parameter to set.
  78. /// \param val A struct of the 4 float values to set the parameter to.
  79. void set(const std::string& paramName, const LLVector4 & val);
  80. /// Set a float4 parameter.
  81. /// \param paramName The name of the parameter to set.
  82. /// \param val A struct of the 4 float values to set the parameter to.
  83. void set(const std::string& paramName, const LLColor4 & val);
  84. /// Get a float4 parameter.
  85. /// \param paramName The name of the parameter to set.
  86. /// \param error A flag to set if it's not the proper return type
  87. LLVector4 getVector(const std::string& paramName, bool& error);
  88. /// Get an integer parameter
  89. /// \param paramName The name of the parameter to set.
  90. /// \param error A flag to set if it's not the proper return type
  91. F32 getFloat(const std::string& paramName, bool& error);
  92. // specific getters and setters
  93. /// set the star's brightness
  94. /// \param val brightness value
  95. void setStarBrightness(F32 val);
  96. /// get the star brightness value;
  97. F32 getStarBrightness();
  98. void setSunAngle(F32 val);
  99. F32 getSunAngle();
  100. void setEastAngle(F32 val);
  101. F32 getEastAngle();
  102. /// set the cloud scroll x enable value
  103. /// \param val scroll x value
  104. void setEnableCloudScrollX(bool val);
  105. /// get the scroll x enable value;
  106. bool getEnableCloudScrollX();
  107. /// set the star's brightness
  108. /// \param val scroll y bool value
  109. void setEnableCloudScrollY(bool val);
  110. /// get the scroll enable y value;
  111. bool getEnableCloudScrollY();
  112. /// set the cloud scroll x enable value
  113. /// \param val scroll x value
  114. void setCloudScrollX(F32 val);
  115. /// get the scroll x enable value;
  116. F32 getCloudScrollX();
  117. /// set the star's brightness
  118. /// \param val scroll y bool value
  119. void setCloudScrollY(F32 val);
  120. /// get the scroll enable y value;
  121. F32 getCloudScrollY();
  122. /// interpolate two parameter sets
  123. /// \param src The parameter set to start with
  124. /// \param dest The parameter set to end with
  125. /// \param weight The amount to interpolate
  126. void mix(LLWLParamSet& src, LLWLParamSet& dest,
  127. F32 weight);
  128. void updateCloudScrolling(void);
  129. };
  130. inline void LLWLParamSet::setAll(const LLSD& val)
  131. {
  132. if(val.isMap()) {
  133. mParamValues = val;
  134. }
  135. }
  136. inline const LLSD& LLWLParamSet::getAll()
  137. {
  138. return mParamValues;
  139. }
  140. inline void LLWLParamSet::setStarBrightness(float val) {
  141. mParamValues["star_brightness"] = val;
  142. }
  143. inline F32 LLWLParamSet::getStarBrightness() {
  144. return (F32) mParamValues["star_brightness"].asReal();
  145. }
  146. inline F32 LLWLParamSet::getSunAngle() {
  147. return (F32) mParamValues["sun_angle"].asReal();
  148. }
  149. inline F32 LLWLParamSet::getEastAngle() {
  150. return (F32) mParamValues["east_angle"].asReal();
  151. }
  152. inline void LLWLParamSet::setEnableCloudScrollX(bool val) {
  153. mParamValues["enable_cloud_scroll"][0] = val;
  154. }
  155. inline bool LLWLParamSet::getEnableCloudScrollX() {
  156. return mParamValues["enable_cloud_scroll"][0].asBoolean();
  157. }
  158. inline void LLWLParamSet::setEnableCloudScrollY(bool val) {
  159. mParamValues["enable_cloud_scroll"][1] = val;
  160. }
  161. inline bool LLWLParamSet::getEnableCloudScrollY() {
  162. return mParamValues["enable_cloud_scroll"][1].asBoolean();
  163. }
  164. inline void LLWLParamSet::setCloudScrollX(F32 val) {
  165. mParamValues["cloud_scroll_rate"][0] = val;
  166. }
  167. inline F32 LLWLParamSet::getCloudScrollX() {
  168. return (F32) mParamValues["cloud_scroll_rate"][0].asReal();
  169. }
  170. inline void LLWLParamSet::setCloudScrollY(F32 val) {
  171. mParamValues["cloud_scroll_rate"][1] = val;
  172. }
  173. inline F32 LLWLParamSet::getCloudScrollY() {
  174. return (F32) mParamValues["cloud_scroll_rate"][1].asReal();
  175. }
  176. #endif // LL_WLPARAM_SET_H