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