lltreeparams.h 5.9 KB

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