PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llvowlsky.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 105 lines | 50 code | 19 blank | 36 comment | 0 complexity | a18f0be9c333785bebb8212f6f2d4fd5 MD5 | raw file
  1/** 
  2 * @file llvowlsky.h
  3 * @brief LLVOWLSky class definition
  4 *
  5 * $LicenseInfo:firstyear=2007&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_VOWLSKY_H
 28#define LL_VOWLSKY_H
 29
 30#include "llviewerobject.h"
 31
 32class LLVOWLSky : public LLStaticViewerObject {
 33private:
 34	static const F32 DISTANCE_TO_STARS;
 35
 36	// anything less than 3 makes it impossible to create a closed dome.
 37	static const U32 MIN_SKY_DETAIL;
 38	// anything bigger than about 180 will cause getStripsNumVerts() to exceed 65535.
 39	static const U32 MAX_SKY_DETAIL;
 40
 41	inline static U32 getNumStacks(void);
 42	inline static U32 getNumSlices(void);
 43	inline static U32 getFanNumVerts(void);
 44	inline static U32 getFanNumIndices(void);
 45	inline static U32 getStripsNumVerts(void);
 46	inline static U32 getStripsNumIndices(void);
 47	inline static U32 getStarsNumVerts(void);
 48	inline static U32 getStarsNumIndices(void);
 49
 50public:
 51	LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
 52
 53	void initSunDirection(LLVector3 const & sun_direction,
 54		LLVector3 const & sun_angular_velocity);
 55
 56	/*virtual*/ BOOL		 idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
 57	/*virtual*/ BOOL		 isActive(void) const;
 58	/*virtual*/ LLDrawable * createDrawable(LLPipeline *pipeline);
 59	/*virtual*/ BOOL		 updateGeometry(LLDrawable *drawable);
 60
 61	void drawStars(void);
 62	void drawDome(void);
 63	void resetVertexBuffers(void);
 64	
 65	void cleanupGL();
 66	void restoreGL();
 67
 68private:
 69	// a tiny helper function for controlling the sky dome tesselation.
 70	static F32 calcPhi(U32 i);
 71
 72	// helper function for initializing the stars.
 73	void initStars();
 74
 75	// helper function for building the fan vertex buffer.
 76	static void buildFanBuffer(LLStrider<LLVector3> & vertices,
 77							   LLStrider<LLVector2> & texCoords,
 78							   LLStrider<U16> & indices);
 79
 80	// helper function for building the strips vertex buffer.
 81	// note begin_stack and end_stack follow stl iterator conventions,
 82	// begin_stack is the first stack to be included, end_stack is the first
 83	// stack not to be included.
 84	static void buildStripsBuffer(U32 begin_stack, U32 end_stack,
 85								  LLStrider<LLVector3> & vertices,
 86								  LLStrider<LLVector2> & texCoords,
 87								  LLStrider<U16> & indices);
 88
 89	// helper function for updating the stars colors.
 90	void updateStarColors();
 91
 92	// helper function for updating the stars geometry.
 93	BOOL updateStarGeometry(LLDrawable *drawable);
 94
 95private:
 96	LLPointer<LLVertexBuffer>					mFanVerts;
 97	std::vector< LLPointer<LLVertexBuffer> >	mStripsVerts;
 98	LLPointer<LLVertexBuffer>					mStarsVerts;
 99
100	std::vector<LLVector3>	mStarVertices;				// Star verticies
101	std::vector<LLColor4>	mStarColors;				// Star colors
102	std::vector<F32>		mStarIntensities;			// Star intensities
103};
104
105#endif // LL_VOWLSKY_H