PageRenderTime 576ms CodeModel.GetById 161ms app.highlight 246ms RepoModel.GetById 167ms app.codeStats 0ms

/indra/llprimitive/lltreeparams.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 205 lines | 120 code | 42 blank | 43 comment | 5 complexity | d8eb8adc57e3fb7e7d48eaa20c2c6b86 MD5 | raw file
  1/** 
  2 * @file lltreeparams.cpp
  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//////////////////////////////////////////////////////////////////////
 28
 29#include "linden_common.h"
 30
 31#include "llmath.h"
 32
 33#include "lltreeparams.h"
 34
 35//////////////////////////////////////////////////////////////////////
 36// Construction/Destruction
 37//////////////////////////////////////////////////////////////////////
 38
 39
 40LLTreeParams::LLTreeParams()
 41{
 42
 43//	llinfos << "TREE PARAMS INITIALIZED" << llendl;
 44	// init to basic something or other...
 45	mShape = SR_TEND_FLAME;
 46	mLevels = 1;
 47	mScale = 15;
 48	mScaleV = 0;
 49
 50	mBaseSize = 0.3f;
 51
 52	mRatio = 0.015f;
 53	mRatioPower = 1.3f;
 54
 55	mLobes = 0;
 56	mLobeDepth = .1f;
 57
 58	mFlare = 1.2f;
 59	mFlarePercentage = 0.1f;
 60	mFlareRes = 3;
 61
 62	//mAttractionUp = .5f;
 63
 64	mBaseSplits = 0;
 65
 66	mScale0 = 2.0;		
 67	mScaleV0 = 0.0;
 68
 69	// level 0
 70
 71	// scaling
 72	mLength[0] = 1.0f;
 73	mLengthV[0] = 0;
 74	mTaper[0] = 1.0f;
 75
 76	// stem splits
 77	mSegSplits[0] = 0.15f;
 78	mSplitAngle[0] = 15.0f;
 79	mSplitAngleV[0] = 10.0f;
 80
 81	mVertices[0] = 5;
 82	
 83	// curvature
 84	mCurveRes[0] = 4;
 85	mCurve[0] = 0;
 86	mCurveV[0] = 25;
 87	mCurveBack[0] = 0;
 88
 89	// level 1
 90
 91	// scaling
 92	mLength[1] = .3f;
 93	mLengthV[1] = 0.05f;
 94	mTaper[1] = 1.0f;
 95
 96	// angle params
 97	mDownAngle[0] = 60.0f;
 98	mDownAngleV[0] = 20.0f;
 99	mRotate[0] = 140.0f;
100	mRotateV[0] = 0.0f;
101	mBranches[0] = 35;
102
103	mVertices[1] = 3; 
104
105	// stem splits
106	mSplitAngle[1] = 0.0f;
107	mSplitAngleV[1] = 0.0f;
108	mSegSplits[1] = 0.0f;
109
110	// curvature
111	mCurveRes[1] = 4;
112	mCurve[1] = 0;
113	mCurveV[1] = 0;
114	mCurveBack[1] = 40;
115
116	// level 2
117	mLength[2] = .6f;
118	mLengthV[2] = .1f;
119	mTaper[2] = 1;
120
121	mDownAngle[1] = 30;
122	mDownAngleV[1] = 10;
123	mRotate[1] = 140;
124	mRotateV[1] = 0;
125
126	mBranches[1] = 20;
127	mVertices[2] = 3;
128
129	mSplitAngle[2] = 0;
130	mSplitAngleV[2] = 0;
131	mSegSplits[2] = 0;
132
133	mCurveRes[2] = 3;
134	mCurve[2] = 10;
135	mCurveV[2] = 150;
136	mCurveBack[2] = 0;
137
138	// level 3
139	mLength[3] = .4f;
140	mLengthV[3] = 0;
141	mTaper[3] = 1;
142
143	mDownAngle[2] = 45;
144	mDownAngleV[2] = 10;
145	mRotate[2] = 140;
146	mRotateV[2] = 0;
147
148	mBranches[2] = 5;
149	mVertices[3] = 3;
150
151
152	mSplitAngle[3] = 0;
153	mSplitAngleV[3] = 0;
154	mSegSplits[3] = 0;
155
156	mCurveRes[3] = 2;
157	mCurve[3] = 0;
158	mCurveV[3] = 0;
159	mCurveBack[3] = 0;
160
161	mLeaves = 0;
162	mLeafScaleX = 1.0f;
163	mLeafScaleY = 1.0f;
164
165	mLeafQuality = 1.25;
166}
167
168LLTreeParams::~LLTreeParams()
169{
170
171}
172
173F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio) 
174{
175	switch (shape) {
176		case (SR_CONICAL): 
177			return (.2f + .8f * ratio);
178		case (SR_SPHERICAL):
179			return (.2f + .8f * sinf(F_PI*ratio));
180		case (SR_HEMISPHERICAL):
181			return (.2f + .8f * sinf(.5*F_PI*ratio));
182		case (SR_CYLINDRICAL):
183			return (1);
184		case (SR_TAPERED_CYLINDRICAL):
185			return (.5f + .5f * ratio);
186		case (SR_FLAME):
187			if (ratio <= .7f) {
188				return ratio/.7f;
189			} else {
190				return ((1 - ratio)/.3f);
191			}
192		case (SR_INVERSE_CONICAL):
193			return (1 - .8f * ratio);
194		case (SR_TEND_FLAME):
195			if (ratio <= .7) {
196				return (.5f + .5f*(ratio/.7f));
197			} else {
198				return (.5f + .5f * (1 - ratio)/.3f);
199			}
200		case (SR_ENVELOPE):
201			return 1;
202		default:
203			return 1;
204	}
205}