summaryrefslogtreecommitdiff
path: root/indra/llprimitive/lltreeparams.cpp
blob: ba038ffba894357ca23d2eae19cece3ae5e292a1 (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
208
209
210
/** 
 * @file lltreeparams.cpp
 * @brief implementation of the LLTreeParams class.
 *
 * $LicenseInfo:firstyear=2001&license=viewergpl$
 * 
 * Copyright (c) 2001-2007, 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://secondlife.com/developers/opensource/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://secondlife.com/developers/opensource/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$
 */

//////////////////////////////////////////////////////////////////////

#include "linden_common.h"

#include "llmath.h"

#include "lltreeparams.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


LLTreeParams::LLTreeParams()
{

//	llinfos << "TREE PARAMS INITIALIZED" << llendl;
	// init to basic something or other...
	mShape = SR_TEND_FLAME;
	mLevels = 1;
	mScale = 15;
	mScaleV = 0;

	mBaseSize = 0.3f;

	mRatio = 0.015f;
	mRatioPower = 1.3f;

	mLobes = 0;
	mLobeDepth = .1f;

	mFlare = 1.2f;
	mFlarePercentage = 0.1f;
	mFlareRes = 3;

	//mAttractionUp = .5f;

	mBaseSplits = 0;

	mScale0 = 2.0;		
	mScaleV0 = 0.0;

	// level 0

	// scaling
	mLength[0] = 1.0f;
	mLengthV[0] = 0;
	mTaper[0] = 1.0f;

	// stem splits
	mSegSplits[0] = 0.15f;
	mSplitAngle[0] = 15.0f;
	mSplitAngleV[0] = 10.0f;

	mVertices[0] = 5;
	
	// curvature
	mCurveRes[0] = 4;
	mCurve[0] = 0;
	mCurveV[0] = 25;
	mCurveBack[0] = 0;

	// level 1

	// scaling
	mLength[1] = .3f;
	mLengthV[1] = 0.05f;
	mTaper[1] = 1.0f;

	// angle params
	mDownAngle[0] = 60.0f;
	mDownAngleV[0] = 20.0f;
	mRotate[0] = 140.0f;
	mRotateV[0] = 0.0f;
	mBranches[0] = 35;

	mVertices[1] = 3; 

	// stem splits
	mSplitAngle[1] = 0.0f;
	mSplitAngleV[1] = 0.0f;
	mSegSplits[1] = 0.0f;

	// curvature
	mCurveRes[1] = 4;
	mCurve[1] = 0;
	mCurveV[1] = 0;
	mCurveBack[1] = 40;

	// level 2
	mLength[2] = .6f;
	mLengthV[2] = .1f;
	mTaper[2] = 1;

	mDownAngle[1] = 30;
	mDownAngleV[1] = 10;
	mRotate[1] = 140;
	mRotateV[1] = 0;

	mBranches[1] = 20;
	mVertices[2] = 3;

	mSplitAngle[2] = 0;
	mSplitAngleV[2] = 0;
	mSegSplits[2] = 0;

	mCurveRes[2] = 3;
	mCurve[2] = 10;
	mCurveV[2] = 150;
	mCurveBack[2] = 0;

	// level 3
	mLength[3] = .4f;
	mLengthV[3] = 0;
	mTaper[3] = 1;

	mDownAngle[2] = 45;
	mDownAngleV[2] = 10;
	mRotate[2] = 140;
	mRotateV[2] = 0;

	mBranches[2] = 5;
	mVertices[3] = 3;


	mSplitAngle[3] = 0;
	mSplitAngleV[3] = 0;
	mSegSplits[3] = 0;

	mCurveRes[3] = 2;
	mCurve[3] = 0;
	mCurveV[3] = 0;
	mCurveBack[3] = 0;

	mLeaves = 0;
	mLeafScaleX = 1.0f;
	mLeafScaleY = 1.0f;

	mLeafQuality = 1.25;
}

LLTreeParams::~LLTreeParams()
{

}

F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio) 
{
	switch (shape) {
		case (SR_CONICAL): 
			return (.2f + .8f * ratio);
		case (SR_SPHERICAL):
			return (.2f + .8f * sinf(F_PI*ratio));
		case (SR_HEMISPHERICAL):
			return (.2f + .8f * sinf(.5*F_PI*ratio));
		case (SR_CYLINDRICAL):
			return (1);
		case (SR_TAPERED_CYLINDRICAL):
			return (.5f + .5f * ratio);
		case (SR_FLAME):
			if (ratio <= .7f) {
				return ratio/.7f;
			} else {
				return ((1 - ratio)/.3f);
			}
		case (SR_INVERSE_CONICAL):
			return (1 - .8f * ratio);
		case (SR_TEND_FLAME):
			if (ratio <= .7) {
				return (.5f + .5f*(ratio/.7f));
			} else {
				return (.5f + .5f * (1 - ratio)/.3f);
			}
		case (SR_ENVELOPE):
			return 1;
		default:
			return 1;
	}
}