PageRenderTime 39ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llprimitive/lltreeparams.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 201 lines | 47 code | 53 blank | 101 comment | 0 complexity | 8e89db13bf098ed6fc5967a367679153 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltreeparams.h
  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. #ifndef LL_LLTREEPARAMS_H
  27. #define LL_LLTREEPARAMS_H
  28. /* for information about formulas associated with each type
  29. * check the Weber + Penn paper
  30. */
  31. enum EShapeRatio { SR_CONICAL, SR_SPHERICAL, SR_HEMISPHERICAL,
  32. SR_CYLINDRICAL, SR_TAPERED_CYLINDRICAL, SR_FLAME,
  33. SR_INVERSE_CONICAL, SR_TEND_FLAME, SR_ENVELOPE};
  34. const U32 TREE_BLOCK_SIZE = 16;
  35. const U8 MAX_NUM_LEVELS = 4;
  36. class LLTreeParams
  37. {
  38. public:
  39. LLTreeParams();
  40. virtual ~LLTreeParams();
  41. static F32 ShapeRatio(EShapeRatio shape, F32 ratio);
  42. public:
  43. // Variables with an asterick (*) cannot be modified without a re-instancing the
  44. // trunk/branches
  45. // Variables with an exclamation point (!) should probably not be modified outside and instead
  46. // be tied directly to the species
  47. // Variables with a tilde (~) should be tied to a range specified by the
  48. // species type but still slightly controllable by the user
  49. // GENERAL
  50. //! determines length/radius of branches on tree -- ie: general 'shape'
  51. EShapeRatio mShape;
  52. //! number of recursive branch levels...limit to MAX_NUM_LEVELS
  53. U8 mLevels;
  54. //~ percentage of trunk at bottom without branches
  55. F32 mBaseSize;
  56. //~ the general scale + variance of tree
  57. F32 mScale, mScaleV;
  58. // general scale of tree
  59. F32 mScale0, mScaleV0;
  60. // LOBING
  61. //*! number of peaks in the radial distance about the perimeter
  62. U8 mLobes;
  63. // even numbers = obvius symmetry ... use odd numbers
  64. //*! magnitude of the variations as a fraction of the radius
  65. F32 mLobeDepth;
  66. // FLARE
  67. //*! causes exponential expansion near base of trunk
  68. F32 mFlare;
  69. // scales radius base by min 1 to '1 + flare'
  70. //*! percentage of the height of the trunk to flair -- likely less than baseSize
  71. F32 mFlarePercentage;
  72. //*! number of cross sections to make for the flair
  73. U8 mFlareRes;
  74. // LEAVES
  75. //~ number of leaves to make
  76. U8 mLeaves;
  77. //! scale of the leaves
  78. F32 mLeafScaleX, mLeafScaleY;
  79. // quality/density of leaves
  80. F32 mLeafQuality;
  81. // several params don't have level 0 values
  82. // BRANCHES
  83. //~ angle away from parent
  84. F32 mDownAngle[MAX_NUM_LEVELS - 1];
  85. F32 mDownAngleV[MAX_NUM_LEVELS - 1];
  86. //~ rotation around parent
  87. F32 mRotate[MAX_NUM_LEVELS - 1];
  88. F32 mRotateV[MAX_NUM_LEVELS - 1];
  89. //~ num branches to spawn
  90. U8 mBranches[MAX_NUM_LEVELS - 1];
  91. //~ fractional length of branch. 1 = same length as parent branch
  92. F32 mLength[MAX_NUM_LEVELS];
  93. F32 mLengthV[MAX_NUM_LEVELS];
  94. //!~ ratio and ratiopower determine radius/length
  95. F32 mRatio, mRatioPower;
  96. //*! taper of branches
  97. F32 mTaper[MAX_NUM_LEVELS];
  98. // 0 - non-tapering cylinder
  99. // 1 - taper to a point
  100. // 2 - taper to a spherical end
  101. // 3 - periodic tapering (concatenated spheres)
  102. //! SEG SPLITTING
  103. U8 mBaseSplits; //! num segsplits at first curve cross section of trunk
  104. F32 mSegSplits[MAX_NUM_LEVELS]; //~ splits per cross section. 1 = 1 split per section
  105. F32 mSplitAngle[MAX_NUM_LEVELS]; //~ angle that splits go from parent (tempered by height)
  106. F32 mSplitAngleV[MAX_NUM_LEVELS]; //~ variance of the splits
  107. // CURVE
  108. F32 mCurve[MAX_NUM_LEVELS]; //* general, 1-axis, overall curve of branch
  109. F32 mCurveV[MAX_NUM_LEVELS]; //* curve variance at each cross section from general overall curve
  110. U8 mCurveRes[MAX_NUM_LEVELS]; //* number of cross sections for curve
  111. F32 mCurveBack[MAX_NUM_LEVELS]; //* curveback is amount branch curves back towards
  112. // vertices per cross section
  113. U8 mVertices[MAX_NUM_LEVELS];
  114. // * no longer useful with pre-instanced branches
  115. // specifies upward tendency of branches.
  116. //F32 mAttractionUp;
  117. // 1 = each branch will slightly go upwards by the end of the branch
  118. // >1 = branches tend to go upwards earlier in their length
  119. // pruning not implemented
  120. // Prune parameters
  121. //F32 mPruneRatio;
  122. //F32 mPruneWidth, mPruneWidthPeak;
  123. //F32 mPrunePowerLow, mPrunePowerHigh;
  124. // NETWORK MESSAGE DATA
  125. // Below is the outline for network messages regarding trees.
  126. // The general idea is that a user would pick a general 'tree type' (the first variable)
  127. // and then several 'open ended' variables like 'branchiness' and 'leafiness'.
  128. // The effect that each of these general user variables would then affect the actual
  129. // tree parameters (like # branches, # segsplits) in different ways depending on
  130. // the tree type selected. Essentially, each tree type should have a formula
  131. // that expands the 'leafiness' and 'branchiness' user variables into actual
  132. // values for the tree parameters.
  133. // These formulas aren't made yet and will certainly require some tuning. The
  134. // estimates below for the # bits required seems like a good guesstimate.
  135. // VARIABLE - # bits (range) - VARIABLES AFFECTED
  136. // tree type - 5 bits (32) -
  137. // branches - 6 bits (64) - numBranches
  138. // splits - 6 bits (64) - segsplits
  139. // leafiness - 3 bits (8) - numLeaves
  140. // branch spread - 5 bits (32) - splitAngle(V), rotate(V)
  141. // angle - 5 bits (32) - downAngle(V)
  142. // branch length - 6 bits (64) - branchlength(V)
  143. // randomness - 7 bits (128) - percentage for randomness of the (V)'s
  144. // basesize - 5 bits (32) - basesize
  145. // total - 48 bits
  146. //U8 mNetSpecies;
  147. };
  148. #endif