llvowlsky.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_VOWLSKY_H
00033 #define LL_VOWLSKY_H
00034 
00035 #include "llviewerobject.h"
00036 
00037 class LLVOWLSky : public LLStaticViewerObject {
00038 private:
00039         static const F32 DISTANCE_TO_STARS;
00040 
00041         // anything less than 3 makes it impossible to create a closed dome.
00042         static const U32 MIN_SKY_DETAIL;
00043         // anything bigger than about 180 will cause getStripsNumVerts() to exceed 65535.
00044         static const U32 MAX_SKY_DETAIL;
00045 
00046         inline static U32 getNumStacks(void);
00047         inline static U32 getNumSlices(void);
00048         inline static U32 getFanNumVerts(void);
00049         inline static U32 getFanNumIndices(void);
00050         inline static U32 getStripsNumVerts(void);
00051         inline static U32 getStripsNumIndices(void);
00052         inline static U32 getStarsNumVerts(void);
00053         inline static U32 getStarsNumIndices(void);
00054 
00055 public:
00056         LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
00057 
00058         void initSunDirection(LLVector3 const & sun_direction,
00059                 LLVector3 const & sun_angular_velocity);
00060 
00061         /*virtual*/ BOOL                 idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00062         /*virtual*/ BOOL                 isActive(void) const;
00063         /*virtual*/ LLDrawable * createDrawable(LLPipeline *pipeline);
00064         /*virtual*/ BOOL                 updateGeometry(LLDrawable *drawable);
00065 
00066         void drawStars(void);
00067         void drawDome(void);
00068         void resetVertexBuffers(void);
00069         
00070         void cleanupGL();
00071         void restoreGL();
00072 
00073 private:
00074         // a tiny helper function for controlling the sky dome tesselation.
00075         static F32 calcPhi(U32 i);
00076 
00077         // helper function for initializing the stars.
00078         void initStars();
00079 
00080         // helper function for building the fan vertex buffer.
00081         static void buildFanBuffer(LLStrider<LLVector3> & vertices,
00082                                                            LLStrider<LLVector2> & texCoords,
00083                                                            LLStrider<U16> & indices);
00084 
00085         // helper function for building the strips vertex buffer.
00086         // note begin_stack and end_stack follow stl iterator conventions,
00087         // begin_stack is the first stack to be included, end_stack is the first
00088         // stack not to be included.
00089         static void buildStripsBuffer(U32 begin_stack, U32 end_stack,
00090                                                                   LLStrider<LLVector3> & vertices,
00091                                                                   LLStrider<LLVector2> & texCoords,
00092                                                                   LLStrider<U16> & indices);
00093 
00094         // helper function for updating the stars colors.
00095         void updateStarColors();
00096 
00097         // helper function for updating the stars geometry.
00098         BOOL updateStarGeometry(LLDrawable *drawable);
00099 
00100 private:
00101         LLPointer<LLVertexBuffer>                                       mFanVerts;
00102         std::vector< LLPointer<LLVertexBuffer> >        mStripsVerts;
00103         LLPointer<LLVertexBuffer>                                       mStarsVerts;
00104 
00105         std::vector<LLVector3>  mStarVertices;                          // Star verticies
00106         std::vector<LLColor4>   mStarColors;                            // Star colors
00107         std::vector<F32>                mStarIntensities;                       // Star intensities
00108 };
00109 
00110 #endif // LL_VOWLSKY_H

Generated on Fri May 16 08:34:24 2008 for SecondLife by  doxygen 1.5.5