lltreeparams.cpp 4.0 KB

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