llvotree.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVOTREE_H
00033 #define LL_LLVOTREE_H
00034 
00035 #include "llviewerobject.h"
00036 #include "lldarray.h"
00037 #include "xform.h"
00038 
00039 class LLFace;
00040 class LLDrawPool;
00041 
00042 
00043 class LLVOTree : public LLViewerObject
00044 {
00045 protected:
00046         ~LLVOTree();
00047 
00048 public:
00049         enum
00050         {
00051                 VERTEX_DATA_MASK =      (1 << LLVertexBuffer::TYPE_VERTEX) |
00052                                                         (1 << LLVertexBuffer::TYPE_NORMAL) |
00053                                                         (1 << LLVertexBuffer::TYPE_TEXCOORD)
00054         };
00055 
00056         LLVOTree(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
00057 
00058         // Initialize data that's only inited once per class.
00059         static void initClass();
00060         static void cleanupClass();
00061 
00062         /*virtual*/ U32 processUpdateMessage(LLMessageSystem *mesgsys,
00063                                                                                         void **user_data,
00064                                                                                         U32 block_num, const EObjectUpdateType update_type,
00065                                                                                         LLDataPacker *dp);
00066         /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00067         
00068         // Graphical stuff for objects - maybe broken out into render class later?
00069         /*virtual*/ void render(LLAgent &agent);
00070         /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent);
00071         /*virtual*/ void updateTextures(LLAgent &agent);
00072 
00073         /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
00074         /*virtual*/ BOOL                updateGeometry(LLDrawable *drawable);
00075         /*virtual*/ void                updateSpatialExtents(LLVector3 &min, LLVector3 &max);
00076 
00077         virtual U32 getPartitionType() const;
00078 
00079         void updateRadius();
00080 
00081         U32 drawBranchPipeline(U32* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth,  F32 scale, F32 twist, F32 droop,  F32 branches, F32 alpha);
00082  
00083         void drawBranch(S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop,  F32 branches, F32 alpha, BOOL draw_leaves);
00084 
00085         static S32 sMaxTreeSpecies;
00086 
00087         struct TreeSpeciesData
00088         {
00089                 LLUUID mTextureID;
00090                 
00091                 F32                             mBranchLength;  // Scale (length) of tree branches
00092                 F32                             mDroop;                 // Droop from vertical (degrees) at each branch recursion
00093                 F32                             mTwist;                 // Twist 
00094                 F32                             mBranches;              // Number of branches emitted at each recursion level 
00095                 U8                              mDepth;                 // Number of recursions to tips of branches
00096                 F32                             mScaleStep;             // Multiplier for scale at each recursion level
00097                 U8                              mTrunkDepth;
00098 
00099                 F32                             mLeafScale;             // Scales leaf texture when rendering 
00100                 F32                             mTrunkLength;   // Scales branch diameters when rendering 
00101                 F32                             mBillboardScale; // Scales the billboard representation 
00102                 F32                             mBillboardRatio; // Height to width aspect ratio
00103                 F32                             mTrunkAspect;   
00104                 F32                             mBranchAspect;
00105                 F32                             mRandomLeafRotate;
00106                 F32                             mNoiseScale;    //  Scaling of noise function in perlin space (norm = 1.0)
00107                 F32                             mNoiseMag;              //  amount of perlin noise to deform by (0 = none)
00108                 F32                             mTaper;                 //  amount of perlin noise to deform by (0 = none)
00109                 F32                             mRepeatTrunkZ;  //  Times to repeat the trunk texture vertically along trunk 
00110         };
00111 
00112         static F32 sTreeFactor;                 // Tree level of detail factor
00113 
00114         friend class LLDrawPoolTree;
00115 protected:
00116         LLVector3               mTrunkBend;             // Accumulated wind (used for blowing trees)
00117         LLVector3               mTrunkVel;              // 
00118         LLVector3               mWind;
00119 
00120         LLPointer<LLViewerImage> mTreeImagep;   // Pointer to proper tree image
00121 
00122         U8                              mSpecies;               // Species of tree
00123         F32                             mBranchLength;  // Scale (length) of tree branches
00124         F32                             mTrunkLength;   // Trunk length (first recursion)
00125         F32                             mDroop;                 // Droop from vertical (degrees) at each branch recursion
00126         F32                             mTwist;                 // Twist 
00127         F32                             mBranches;              // Number of branches emitted at each recursion level 
00128         U8                              mDepth;                 // Number of recursions to tips of branches
00129         F32                             mScaleStep;             // Multiplier for scale at each recursion level
00130         U8                              mTrunkDepth;
00131 
00132         F32                             mLeafScale;             // Scales leaf texture when rendering 
00133 
00134         F32                             mBillboardScale;        //  How big to draw the billboard?
00135         F32                             mBillboardRatio;        //  Height to width ratio of billboard
00136         F32                             mTrunkAspect;           //  Ratio between width/length of trunk
00137         F32                             mBranchAspect;  //  Ratio between width/length of branch
00138         F32                             mRandomLeafRotate;      //      How much to randomly rotate leaves about arbitrary axis 
00139         
00140         U32 mFrameCount;
00141 
00142         typedef std::map<U32, TreeSpeciesData*> SpeciesMap;
00143         static SpeciesMap sSpeciesTable;
00144 
00145         static S32 sLODIndexOffset[4];
00146         static S32 sLODIndexCount[4];
00147         static S32 sLODVertexOffset[4];
00148         static S32 sLODVertexCount[4];
00149         static S32 sLODSlices[4];
00150         static F32 sLODAngles[4];
00151 };
00152 
00153 #endif

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