PageRenderTime 87ms CodeModel.GetById 28ms RepoModel.GetById 5ms app.codeStats 0ms

/indra/llprimitive/lltreeparams.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 205 lines | 120 code | 42 blank | 43 comment | 5 complexity | d8eb8adc57e3fb7e7d48eaa20c2c6b86 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltreeparams.cpp
  3. * @brief implementation of the LLTreeParams class.
  4. *
  5. * $LicenseInfo:firstyear=2001&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. //////////////////////////////////////////////////////////////////////
  27. #include "linden_common.h"
  28. #include "llmath.h"
  29. #include "lltreeparams.h"
  30. //////////////////////////////////////////////////////////////////////
  31. // Construction/Destruction
  32. //////////////////////////////////////////////////////////////////////
  33. LLTreeParams::LLTreeParams()
  34. {
  35. // llinfos << "TREE PARAMS INITIALIZED" << llendl;
  36. // init to basic something or other...
  37. mShape = SR_TEND_FLAME;
  38. mLevels = 1;
  39. mScale = 15;
  40. mScaleV = 0;
  41. mBaseSize = 0.3f;
  42. mRatio = 0.015f;
  43. mRatioPower = 1.3f;
  44. mLobes = 0;
  45. mLobeDepth = .1f;
  46. mFlare = 1.2f;
  47. mFlarePercentage = 0.1f;
  48. mFlareRes = 3;
  49. //mAttractionUp = .5f;
  50. mBaseSplits = 0;
  51. mScale0 = 2.0;
  52. mScaleV0 = 0.0;
  53. // level 0
  54. // scaling
  55. mLength[0] = 1.0f;
  56. mLengthV[0] = 0;
  57. mTaper[0] = 1.0f;
  58. // stem splits
  59. mSegSplits[0] = 0.15f;
  60. mSplitAngle[0] = 15.0f;
  61. mSplitAngleV[0] = 10.0f;
  62. mVertices[0] = 5;
  63. // curvature
  64. mCurveRes[0] = 4;
  65. mCurve[0] = 0;
  66. mCurveV[0] = 25;
  67. mCurveBack[0] = 0;
  68. // level 1
  69. // scaling
  70. mLength[1] = .3f;
  71. mLengthV[1] = 0.05f;
  72. mTaper[1] = 1.0f;
  73. // angle params
  74. mDownAngle[0] = 60.0f;
  75. mDownAngleV[0] = 20.0f;
  76. mRotate[0] = 140.0f;
  77. mRotateV[0] = 0.0f;
  78. mBranches[0] = 35;
  79. mVertices[1] = 3;
  80. // stem splits
  81. mSplitAngle[1] = 0.0f;
  82. mSplitAngleV[1] = 0.0f;
  83. mSegSplits[1] = 0.0f;
  84. // curvature
  85. mCurveRes[1] = 4;
  86. mCurve[1] = 0;
  87. mCurveV[1] = 0;
  88. mCurveBack[1] = 40;
  89. // level 2
  90. mLength[2] = .6f;
  91. mLengthV[2] = .1f;
  92. mTaper[2] = 1;
  93. mDownAngle[1] = 30;
  94. mDownAngleV[1] = 10;
  95. mRotate[1] = 140;
  96. mRotateV[1] = 0;
  97. mBranches[1] = 20;
  98. mVertices[2] = 3;
  99. mSplitAngle[2] = 0;
  100. mSplitAngleV[2] = 0;
  101. mSegSplits[2] = 0;
  102. mCurveRes[2] = 3;
  103. mCurve[2] = 10;
  104. mCurveV[2] = 150;
  105. mCurveBack[2] = 0;
  106. // level 3
  107. mLength[3] = .4f;
  108. mLengthV[3] = 0;
  109. mTaper[3] = 1;
  110. mDownAngle[2] = 45;
  111. mDownAngleV[2] = 10;
  112. mRotate[2] = 140;
  113. mRotateV[2] = 0;
  114. mBranches[2] = 5;
  115. mVertices[3] = 3;
  116. mSplitAngle[3] = 0;
  117. mSplitAngleV[3] = 0;
  118. mSegSplits[3] = 0;
  119. mCurveRes[3] = 2;
  120. mCurve[3] = 0;
  121. mCurveV[3] = 0;
  122. mCurveBack[3] = 0;
  123. mLeaves = 0;
  124. mLeafScaleX = 1.0f;
  125. mLeafScaleY = 1.0f;
  126. mLeafQuality = 1.25;
  127. }
  128. LLTreeParams::~LLTreeParams()
  129. {
  130. }
  131. F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio)
  132. {
  133. switch (shape) {
  134. case (SR_CONICAL):
  135. return (.2f + .8f * ratio);
  136. case (SR_SPHERICAL):
  137. return (.2f + .8f * sinf(F_PI*ratio));
  138. case (SR_HEMISPHERICAL):
  139. return (.2f + .8f * sinf(.5*F_PI*ratio));
  140. case (SR_CYLINDRICAL):
  141. return (1);
  142. case (SR_TAPERED_CYLINDRICAL):
  143. return (.5f + .5f * ratio);
  144. case (SR_FLAME):
  145. if (ratio <= .7f) {
  146. return ratio/.7f;
  147. } else {
  148. return ((1 - ratio)/.3f);
  149. }
  150. case (SR_INVERSE_CONICAL):
  151. return (1 - .8f * ratio);
  152. case (SR_TEND_FLAME):
  153. if (ratio <= .7) {
  154. return (.5f + .5f*(ratio/.7f));
  155. } else {
  156. return (.5f + .5f * (1 - ratio)/.3f);
  157. }
  158. case (SR_ENVELOPE):
  159. return 1;
  160. default:
  161. return 1;
  162. }
  163. }