aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llprimitive/lltreeparams.h
blob: 9ca2c81ec6c026034b74d20e2fdf41a1968ce58b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/** 
 * @file lltreeparams.h
 * @brief Implementation of the LLTreeParams class
 *
 * $LicenseInfo:firstyear=2001&license=viewergpl$
 * 
 * Copyright (c) 2001-2009, Linden Research, Inc.
 * 
 * Second Life Viewer Source Code
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at
 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#ifndef LL_LLTREEPARAMS_H
#define LL_LLTREEPARAMS_H 

/* for information about formulas associated with each type
 * check the Weber + Penn paper
 */
enum EShapeRatio { SR_CONICAL, SR_SPHERICAL, SR_HEMISPHERICAL, 
				SR_CYLINDRICAL, SR_TAPERED_CYLINDRICAL, SR_FLAME, 
				SR_INVERSE_CONICAL, SR_TEND_FLAME, SR_ENVELOPE};

const U32 TREE_BLOCK_SIZE = 16;

const U8 MAX_NUM_LEVELS = 4;

class LLTreeParams  
{
public:
	LLTreeParams();
	virtual ~LLTreeParams();

	static F32 ShapeRatio(EShapeRatio shape, F32 ratio);

public:

	// Variables with an asterick (*) cannot be modified without a re-instancing the
	// trunk/branches

	// Variables with an exclamation point (!) should probably not be modified outside and instead
	// be tied directly to the species

	// Variables with a tilde (~) should be tied to a range specified by the 
	// species type but still slightly controllable by the user

	// GENERAL

	//! determines length/radius of branches on tree -- ie: general 'shape' 
	EShapeRatio mShape;
	
	//! number of recursive branch levels...limit to MAX_NUM_LEVELS
	U8 mLevels;

	//~ percentage of trunk at bottom without branches 
	F32 mBaseSize;
	
	//~ the general scale + variance of tree
	F32 mScale, mScaleV;

	// general scale of tree
	F32 mScale0, mScaleV0;



	// LOBING

	//*! number of peaks in the radial distance about the perimeter
	U8 mLobes;
		//	even numbers = obvius symmetry ... use odd numbers
	
	//*! magnitude of the variations as a fraction of the radius
	F32 mLobeDepth;



	// FLARE

	//*! causes exponential expansion near base of trunk
	F32 mFlare;
		//	scales radius base by min 1 to '1 + flare'

	//*! percentage of the height of the trunk to flair -- likely less than baseSize
	F32 mFlarePercentage;

	//*! number of cross sections to make for the flair
	U8 mFlareRes;



	// LEAVES

	//~ number of leaves to make
	U8 mLeaves;

	//! scale of the leaves
	F32 mLeafScaleX, mLeafScaleY;

	// quality/density of leaves
	F32 mLeafQuality;

	// several params don't have level 0 values

	// BRANCHES 

	//~ angle away from parent
	F32 mDownAngle[MAX_NUM_LEVELS - 1];		
	F32 mDownAngleV[MAX_NUM_LEVELS - 1];
	
	//~ rotation around parent
	F32 mRotate[MAX_NUM_LEVELS - 1];
	F32 mRotateV[MAX_NUM_LEVELS - 1];

	//~ num branches to spawn
	U8 mBranches[MAX_NUM_LEVELS - 1];

	//~ fractional length of branch. 1 = same length as parent branch
	F32 mLength[MAX_NUM_LEVELS];
	F32 mLengthV[MAX_NUM_LEVELS];

	//!~ ratio and ratiopower determine radius/length
	F32 mRatio, mRatioPower;	

	//*! taper of branches
	F32 mTaper[MAX_NUM_LEVELS];
			// 0 - non-tapering cylinder
			// 1 - taper to a point
			// 2 - taper to a spherical end
			// 3 - periodic tapering (concatenated spheres)
	
	//! SEG SPLITTING
	U8 mBaseSplits;						//! num segsplits at first curve cross section of trunk
	F32 mSegSplits[MAX_NUM_LEVELS];		//~ splits per cross section. 1 = 1 split per section
	F32 mSplitAngle[MAX_NUM_LEVELS];	//~ angle that splits go from parent (tempered by height)
	F32 mSplitAngleV[MAX_NUM_LEVELS];	//~ variance of the splits

	// CURVE
	F32 mCurve[MAX_NUM_LEVELS];		//* general, 1-axis, overall curve of branch
	F32 mCurveV[MAX_NUM_LEVELS];	//* curve variance at each cross section from general overall curve
	U8 mCurveRes[MAX_NUM_LEVELS];	//* number of cross sections for curve
	F32 mCurveBack[MAX_NUM_LEVELS];	//* curveback is amount branch curves back towards 
	
	//  vertices per cross section
	U8 mVertices[MAX_NUM_LEVELS];

	// * no longer useful with pre-instanced branches
	// specifies upward tendency of branches. 
	//F32 mAttractionUp;	
		//	1 = each branch will slightly go upwards by the end of the branch
		//  >1 = branches tend to go upwards earlier in their length
	// pruning not implemented
	// Prune parameters
	//F32 mPruneRatio;
	//F32 mPruneWidth, mPruneWidthPeak;
	//F32 mPrunePowerLow, mPrunePowerHigh;


	// NETWORK MESSAGE DATA
	// Below is the outline for network messages regarding trees.  
	// The general idea is that a user would pick a general 'tree type' (the first variable)
	// and then several 'open ended' variables like 'branchiness' and 'leafiness'. 
	// The effect that each of these general user variables would then affect the actual
	// tree parameters (like # branches, # segsplits) in different ways depending on
	// the tree type selected.  Essentially, each tree type should have a formula
	// that expands the 'leafiness' and 'branchiness' user variables into actual
	// values for the tree parameters.  

	// These formulas aren't made yet and will certainly require some tuning.  The
	// estimates below for the # bits required seems like a good guesstimate.

	// VARIABLE			-	# bits (range)	-	VARIABLES AFFECTED
	// tree type		-	5 bits (32)		-	
	// branches			-	6 bits (64)		-	numBranches
	// splits			-	6 bits (64)		-	segsplits
	// leafiness		-	3 bits (8)		-	numLeaves
	// branch spread	-	5 bits (32)		-	splitAngle(V), rotate(V)
	// angle			-	5 bits (32)		-	downAngle(V)
	// branch length	-	6 bits (64)		-	branchlength(V)
	// randomness		-	7 bits (128)	-	percentage for randomness of the (V)'s
	// basesize			-	5 bits (32)		-	basesize
	
	// total			-	48 bits

	//U8 mNetSpecies;

};

#endif