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