lltreeparams.cpp

Go to the documentation of this file.
00001 
00032 
00033 
00034 #include "linden_common.h"
00035 
00036 #include "llmath.h"
00037 
00038 #include "lltreeparams.h"
00039 
00041 // Construction/Destruction
00043 
00044 
00045 LLTreeParams::LLTreeParams()
00046 {
00047 
00048 //      llinfos << "TREE PARAMS INITIALIZED" << llendl;
00049         // init to basic something or other...
00050         mShape = SR_TEND_FLAME;
00051         mLevels = 1;
00052         mScale = 15;
00053         mScaleV = 0;
00054 
00055         mBaseSize = 0.3f;
00056 
00057         mRatio = 0.015f;
00058         mRatioPower = 1.3f;
00059 
00060         mLobes = 0;
00061         mLobeDepth = .1f;
00062 
00063         mFlare = 1.2f;
00064         mFlarePercentage = 0.1f;
00065         mFlareRes = 3;
00066 
00067         //mAttractionUp = .5f;
00068 
00069         mBaseSplits = 0;
00070 
00071         mScale0 = 2.0;          
00072         mScaleV0 = 0.0;
00073 
00074         // level 0
00075 
00076         // scaling
00077         mLength[0] = 1.0f;
00078         mLengthV[0] = 0;
00079         mTaper[0] = 1.0f;
00080 
00081         // stem splits
00082         mSegSplits[0] = 0.15f;
00083         mSplitAngle[0] = 15.0f;
00084         mSplitAngleV[0] = 10.0f;
00085 
00086         mVertices[0] = 5;
00087         
00088         // curvature
00089         mCurveRes[0] = 4;
00090         mCurve[0] = 0;
00091         mCurveV[0] = 25;
00092         mCurveBack[0] = 0;
00093 
00094         // level 1
00095 
00096         // scaling
00097         mLength[1] = .3f;
00098         mLengthV[1] = 0.05f;
00099         mTaper[1] = 1.0f;
00100 
00101         // angle params
00102         mDownAngle[0] = 60.0f;
00103         mDownAngleV[0] = 20.0f;
00104         mRotate[0] = 140.0f;
00105         mRotateV[0] = 0.0f;
00106         mBranches[0] = 35;
00107 
00108         mVertices[1] = 3; 
00109 
00110         // stem splits
00111         mSplitAngle[1] = 0.0f;
00112         mSplitAngleV[1] = 0.0f;
00113         mSegSplits[1] = 0.0f;
00114 
00115         // curvature
00116         mCurveRes[1] = 4;
00117         mCurve[1] = 0;
00118         mCurveV[1] = 0;
00119         mCurveBack[1] = 40;
00120 
00121         // level 2
00122         mLength[2] = .6f;
00123         mLengthV[2] = .1f;
00124         mTaper[2] = 1;
00125 
00126         mDownAngle[1] = 30;
00127         mDownAngleV[1] = 10;
00128         mRotate[1] = 140;
00129         mRotateV[1] = 0;
00130 
00131         mBranches[1] = 20;
00132         mVertices[2] = 3;
00133 
00134         mSplitAngle[2] = 0;
00135         mSplitAngleV[2] = 0;
00136         mSegSplits[2] = 0;
00137 
00138         mCurveRes[2] = 3;
00139         mCurve[2] = 10;
00140         mCurveV[2] = 150;
00141         mCurveBack[2] = 0;
00142 
00143         // level 3
00144         mLength[3] = .4f;
00145         mLengthV[3] = 0;
00146         mTaper[3] = 1;
00147 
00148         mDownAngle[2] = 45;
00149         mDownAngleV[2] = 10;
00150         mRotate[2] = 140;
00151         mRotateV[2] = 0;
00152 
00153         mBranches[2] = 5;
00154         mVertices[3] = 3;
00155 
00156 
00157         mSplitAngle[3] = 0;
00158         mSplitAngleV[3] = 0;
00159         mSegSplits[3] = 0;
00160 
00161         mCurveRes[3] = 2;
00162         mCurve[3] = 0;
00163         mCurveV[3] = 0;
00164         mCurveBack[3] = 0;
00165 
00166         mLeaves = 0;
00167         mLeafScaleX = 1.0f;
00168         mLeafScaleY = 1.0f;
00169 
00170         mLeafQuality = 1.25;
00171 }
00172 
00173 LLTreeParams::~LLTreeParams()
00174 {
00175 
00176 }
00177 
00178 F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio) 
00179 {
00180         switch (shape) {
00181                 case (SR_CONICAL): 
00182                         return (.2f + .8f * ratio);
00183                 case (SR_SPHERICAL):
00184                         return (.2f + .8f * sinf(F_PI*ratio));
00185                 case (SR_HEMISPHERICAL):
00186                         return (.2f + .8f * sinf(.5*F_PI*ratio));
00187                 case (SR_CYLINDRICAL):
00188                         return (1);
00189                 case (SR_TAPERED_CYLINDRICAL):
00190                         return (.5f + .5f * ratio);
00191                 case (SR_FLAME):
00192                         if (ratio <= .7f) {
00193                                 return ratio/.7f;
00194                         } else {
00195                                 return ((1 - ratio)/.3f);
00196                         }
00197                 case (SR_INVERSE_CONICAL):
00198                         return (1 - .8f * ratio);
00199                 case (SR_TEND_FLAME):
00200                         if (ratio <= .7) {
00201                                 return (.5f + .5f*(ratio/.7f));
00202                         } else {
00203                                 return (.5f + .5f * (1 - ratio)/.3f);
00204                         }
00205                 case (SR_ENVELOPE):
00206                         return 1;
00207                 default:
00208                         return 1;
00209         }
00210 }

Generated on Thu Jul 1 06:09:23 2010 for Second Life Viewer by  doxygen 1.4.7