PageRenderTime 277ms CodeModel.GetById 266ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llwaterparamset.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 150 lines | 49 code | 29 blank | 72 comment | 3 complexity | db15e7161863e9a5451e89f7fbd1c292 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llwlparamset.h
  3. * @brief Interface for the LLWaterParamSet 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_WATER_PARAM_SET_H
  27. #define LL_WATER_PARAM_SET_H
  28. #include <string>
  29. #include <map>
  30. #include "v4math.h"
  31. #include "v4color.h"
  32. #include "llviewershadermgr.h"
  33. class LLWaterParamSet;
  34. /// A class representing a set of parameter values for the Water shaders.
  35. class LLWaterParamSet
  36. {
  37. friend class LLWaterParamManager;
  38. public:
  39. std::string mName;
  40. private:
  41. LLSD mParamValues;
  42. public:
  43. LLWaterParamSet();
  44. /// Bind this set of parameter values to the uniforms of a particular shader.
  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 getVector4(const std::string& paramName, bool& error);
  88. /// Get a float3 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. LLVector3 getVector3(const std::string& paramName, bool& error);
  92. /// Get a float2 parameter.
  93. /// \param paramName The name of the parameter to set.
  94. /// \param error A flag to set if it's not the proper return type
  95. LLVector2 getVector2(const std::string& paramName, bool& error);
  96. /// Get an integer parameter
  97. /// \param paramName The name of the parameter to set.
  98. /// \param error A flag to set if it's not the proper return type
  99. F32 getFloat(const std::string& paramName, bool& error);
  100. /// interpolate two parameter sets
  101. /// \param src The parameter set to start with
  102. /// \param dest The parameter set to end with
  103. /// \param weight The amount to interpolate
  104. void mix(LLWaterParamSet& src, LLWaterParamSet& dest,
  105. F32 weight);
  106. };
  107. inline void LLWaterParamSet::setAll(const LLSD& val)
  108. {
  109. if(val.isMap()) {
  110. LLSD::map_const_iterator mIt = val.beginMap();
  111. for(; mIt != val.endMap(); mIt++)
  112. {
  113. mParamValues[mIt->first] = mIt->second;
  114. }
  115. }
  116. }
  117. inline const LLSD& LLWaterParamSet::getAll()
  118. {
  119. return mParamValues;
  120. }
  121. #endif // LL_WaterPARAM_SET_H