PageRenderTime 32ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/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
Possible License(s): LGPL-2.1
  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. #ifndef LL_VOWLSKY_H
  27. #define LL_VOWLSKY_H
  28. #include "llviewerobject.h"
  29. class LLVOWLSky : public LLStaticViewerObject {
  30. private:
  31. static const F32 DISTANCE_TO_STARS;
  32. // anything less than 3 makes it impossible to create a closed dome.
  33. static const U32 MIN_SKY_DETAIL;
  34. // anything bigger than about 180 will cause getStripsNumVerts() to exceed 65535.
  35. static const U32 MAX_SKY_DETAIL;
  36. inline static U32 getNumStacks(void);
  37. inline static U32 getNumSlices(void);
  38. inline static U32 getFanNumVerts(void);
  39. inline static U32 getFanNumIndices(void);
  40. inline static U32 getStripsNumVerts(void);
  41. inline static U32 getStripsNumIndices(void);
  42. inline static U32 getStarsNumVerts(void);
  43. inline static U32 getStarsNumIndices(void);
  44. public:
  45. LLVOWLSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  46. void initSunDirection(LLVector3 const & sun_direction,
  47. LLVector3 const & sun_angular_velocity);
  48. /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  49. /*virtual*/ BOOL isActive(void) const;
  50. /*virtual*/ LLDrawable * createDrawable(LLPipeline *pipeline);
  51. /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
  52. void drawStars(void);
  53. void drawDome(void);
  54. void resetVertexBuffers(void);
  55. void cleanupGL();
  56. void restoreGL();
  57. private:
  58. // a tiny helper function for controlling the sky dome tesselation.
  59. static F32 calcPhi(U32 i);
  60. // helper function for initializing the stars.
  61. void initStars();
  62. // helper function for building the fan vertex buffer.
  63. static void buildFanBuffer(LLStrider<LLVector3> & vertices,
  64. LLStrider<LLVector2> & texCoords,
  65. LLStrider<U16> & indices);
  66. // helper function for building the strips vertex buffer.
  67. // note begin_stack and end_stack follow stl iterator conventions,
  68. // begin_stack is the first stack to be included, end_stack is the first
  69. // stack not to be included.
  70. static void buildStripsBuffer(U32 begin_stack, U32 end_stack,
  71. LLStrider<LLVector3> & vertices,
  72. LLStrider<LLVector2> & texCoords,
  73. LLStrider<U16> & indices);
  74. // helper function for updating the stars colors.
  75. void updateStarColors();
  76. // helper function for updating the stars geometry.
  77. BOOL updateStarGeometry(LLDrawable *drawable);
  78. private:
  79. LLPointer<LLVertexBuffer> mFanVerts;
  80. std::vector< LLPointer<LLVertexBuffer> > mStripsVerts;
  81. LLPointer<LLVertexBuffer> mStarsVerts;
  82. std::vector<LLVector3> mStarVertices; // Star verticies
  83. std::vector<LLColor4> mStarColors; // Star colors
  84. std::vector<F32> mStarIntensities; // Star intensities
  85. };
  86. #endif // LL_VOWLSKY_H