PageRenderTime 35ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llvotree.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 196 lines | 134 code | 33 blank | 29 comment | 0 complexity | 6a06698542502705da9e94d0ea4fdc6f MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvotree.h
  3. * @brief LLVOTree class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&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. #ifndef LL_LLVOTREE_H
  27. #define LL_LLVOTREE_H
  28. #include "llviewerobject.h"
  29. #include "lldarray.h"
  30. #include "xform.h"
  31. class LLFace;
  32. class LLDrawPool;
  33. class LLViewerFetchedTexture;
  34. class LLVOTree : public LLViewerObject
  35. {
  36. protected:
  37. ~LLVOTree();
  38. public:
  39. enum
  40. {
  41. VERTEX_DATA_MASK = (1 << LLVertexBuffer::TYPE_VERTEX) |
  42. (1 << LLVertexBuffer::TYPE_NORMAL) |
  43. (1 << LLVertexBuffer::TYPE_TEXCOORD0)
  44. };
  45. LLVOTree(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  46. // Initialize data that's only inited once per class.
  47. static void initClass();
  48. static void cleanupClass();
  49. static bool isTreeRenderingStopped();
  50. /*virtual*/ U32 processUpdateMessage(LLMessageSystem *mesgsys,
  51. void **user_data,
  52. U32 block_num, const EObjectUpdateType update_type,
  53. LLDataPacker *dp);
  54. /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  55. // Graphical stuff for objects - maybe broken out into render class later?
  56. /*virtual*/ void render(LLAgent &agent);
  57. /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent);
  58. /*virtual*/ void updateTextures();
  59. /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
  60. /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
  61. /*virtual*/ void updateSpatialExtents(LLVector4a &min, LLVector4a &max);
  62. virtual U32 getPartitionType() const;
  63. void updateRadius();
  64. void calcNumVerts(U32& vert_count, U32& index_count, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 branches);
  65. void updateMesh();
  66. void appendMesh(LLStrider<LLVector3>& vertices,
  67. LLStrider<LLVector3>& normals,
  68. LLStrider<LLVector2>& tex_coords,
  69. LLStrider<U16>& indices,
  70. U16& idx_offset,
  71. LLMatrix4& matrix,
  72. LLMatrix4& norm_mat,
  73. S32 vertex_offset,
  74. S32 vertex_count,
  75. S32 index_count,
  76. S32 index_offset);
  77. void genBranchPipeline(LLStrider<LLVector3>& vertices,
  78. LLStrider<LLVector3>& normals,
  79. LLStrider<LLVector2>& tex_coords,
  80. LLStrider<U16>& indices,
  81. U16& index_offset,
  82. LLMatrix4& matrix,
  83. S32 trunk_LOD,
  84. S32 stop_level,
  85. U16 depth,
  86. U16 trunk_depth,
  87. F32 scale,
  88. F32 twist,
  89. F32 droop,
  90. F32 branches,
  91. F32 alpha);
  92. U32 drawBranchPipeline(LLMatrix4& matrix, U16* indicesp, S32 trunk_LOD, S32 stop_level, U16 depth, U16 trunk_depth, F32 scale, F32 twist, F32 droop, F32 branches, F32 alpha);
  93. /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end,
  94. S32 face = -1, // which face to check, -1 = ALL_SIDES
  95. BOOL pick_transparent = FALSE,
  96. S32* face_hit = NULL, // which face was hit
  97. LLVector3* intersection = NULL, // return the intersection point
  98. LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point
  99. LLVector3* normal = NULL, // return the surface normal at the intersection point
  100. LLVector3* bi_normal = NULL // return the surface bi-normal at the intersection point
  101. );
  102. static S32 sMaxTreeSpecies;
  103. struct TreeSpeciesData
  104. {
  105. LLUUID mTextureID;
  106. F32 mBranchLength; // Scale (length) of tree branches
  107. F32 mDroop; // Droop from vertical (degrees) at each branch recursion
  108. F32 mTwist; // Twist
  109. F32 mBranches; // Number of branches emitted at each recursion level
  110. U8 mDepth; // Number of recursions to tips of branches
  111. F32 mScaleStep; // Multiplier for scale at each recursion level
  112. U8 mTrunkDepth;
  113. F32 mLeafScale; // Scales leaf texture when rendering
  114. F32 mTrunkLength; // Scales branch diameters when rendering
  115. F32 mBillboardScale; // Scales the billboard representation
  116. F32 mBillboardRatio; // Height to width aspect ratio
  117. F32 mTrunkAspect;
  118. F32 mBranchAspect;
  119. F32 mRandomLeafRotate;
  120. F32 mNoiseScale; // Scaling of noise function in perlin space (norm = 1.0)
  121. F32 mNoiseMag; // amount of perlin noise to deform by (0 = none)
  122. F32 mTaper; // amount of perlin noise to deform by (0 = none)
  123. F32 mRepeatTrunkZ; // Times to repeat the trunk texture vertically along trunk
  124. };
  125. static F32 sTreeFactor; // Tree level of detail factor
  126. static const S32 sMAX_NUM_TREE_LOD_LEVELS ;
  127. friend class LLDrawPoolTree;
  128. protected:
  129. LLVector3 mTrunkBend; // Accumulated wind (used for blowing trees)
  130. LLVector3 mWind;
  131. LLPointer<LLVertexBuffer> mReferenceBuffer; //reference geometry for generating tree mesh
  132. LLPointer<LLViewerFetchedTexture> mTreeImagep; // Pointer to proper tree image
  133. U8 mSpecies; // Species of tree
  134. F32 mBranchLength; // Scale (length) of tree branches
  135. F32 mTrunkLength; // Trunk length (first recursion)
  136. F32 mDroop; // Droop from vertical (degrees) at each branch recursion
  137. F32 mTwist; // Twist
  138. F32 mBranches; // Number of branches emitted at each recursion level
  139. U8 mDepth; // Number of recursions to tips of branches
  140. F32 mScaleStep; // Multiplier for scale at each recursion level
  141. U8 mTrunkDepth;
  142. U32 mTrunkLOD;
  143. F32 mLeafScale; // Scales leaf texture when rendering
  144. F32 mBillboardScale; // How big to draw the billboard?
  145. F32 mBillboardRatio; // Height to width ratio of billboard
  146. F32 mTrunkAspect; // Ratio between width/length of trunk
  147. F32 mBranchAspect; // Ratio between width/length of branch
  148. F32 mRandomLeafRotate; // How much to randomly rotate leaves about arbitrary axis
  149. // cache last position+rotation so we can detect the need for a
  150. // complete rebuild when not animating
  151. LLVector3 mLastPosition;
  152. LLQuaternion mLastRotation;
  153. U32 mFrameCount;
  154. typedef std::map<U32, TreeSpeciesData*> SpeciesMap;
  155. static SpeciesMap sSpeciesTable;
  156. static S32 sLODIndexOffset[4];
  157. static S32 sLODIndexCount[4];
  158. static S32 sLODVertexOffset[4];
  159. static S32 sLODVertexCount[4];
  160. static S32 sLODSlices[4];
  161. static F32 sLODAngles[4];
  162. };
  163. #endif