llvowlsky.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * @file llvowlsky.h
  3. * @brief LLVOWLSky class definition
  4. *
  5. * $LicenseInfo:firstyear=2007&license=viewergpl$
  6. *
  7. * Copyright (c) 2007-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_VOWLSKY_H
  33. #define LL_VOWLSKY_H
  34. #include "llsettingssky.h" // For LL_VARIABLE_SKY_DOME_SIZE
  35. #include "llviewerobject.h"
  36. class LLVOWLSky final : public LLStaticViewerObject
  37. {
  38. protected:
  39. LOG_CLASS(LLVOWLSky);
  40. public:
  41. LLVOWLSky(const LLUUID& id, LLViewerRegion* regionp);
  42. // Nothing to do.
  43. LL_INLINE void idleUpdate(F64) override {}
  44. LL_INLINE bool isActive() const override { return false; }
  45. LLDrawable* createDrawable() override;
  46. bool updateGeometry(LLDrawable* drawable) override;
  47. void drawStars();
  48. void drawDome();
  49. void resetVertexBuffers() override;
  50. void cleanupGL();
  51. void restoreGL();
  52. static void initClass();
  53. static void updateSettings();
  54. static void cleanupClass();
  55. private:
  56. LL_INLINE static U32 getNumStacks()
  57. {
  58. return sWLSkyDetail;
  59. }
  60. LL_INLINE static U32 getNumSlices()
  61. {
  62. return 2 * sWLSkyDetail;
  63. }
  64. LL_INLINE static U32 getFanNumVerts()
  65. {
  66. return getNumSlices() + 1;
  67. }
  68. LL_INLINE static U32 getFanNumIndices()
  69. {
  70. return getNumSlices() * 3;
  71. }
  72. // Gets the dome radius, based on whether we render Windlight or extended
  73. // environment settings.
  74. #if LL_VARIABLE_SKY_DOME_SIZE
  75. static F32 getDomeRadius();
  76. #else
  77. // In fact, Windlight always had it fixed to 15000m, and it is also the
  78. // value for the current extended environment code... So, why bothering ?
  79. LL_INLINE static F32 getDomeRadius() { return 15000.f; }
  80. #endif
  81. // A tiny helper method for controlling the sky dome tesselation.
  82. static F32 calcPhi(U32 i);
  83. // Helper method for initializing the stars.
  84. void initStars();
  85. // Helper method for building the strips vertex buffer. Note: begin_stack
  86. // and end_stack follow stl iterator conventions, begin_stack is the first
  87. // stack to be included, end_stack is the first stack not to be included.
  88. static void buildStripsBuffer(U32 begin_stack, U32 end_stack,
  89. LLStrider<LLVector3>& vertices,
  90. LLStrider<LLVector2>& texCoords,
  91. LLStrider<U16>& indices);
  92. // Helper method for updating the stars colors.
  93. void updateStarColors();
  94. // Helper method for updating the stars geometry.
  95. bool updateStarGeometry(LLDrawable* drawable);
  96. private:
  97. LLPointer<LLVertexBuffer> mStarsVerts;
  98. typedef std::vector<LLPointer<LLVertexBuffer> > strips_verts_vec_t;
  99. strips_verts_vec_t mStripsVerts;
  100. std::vector<LLVector3> mStarVertices;
  101. std::vector<LLColor4> mStarColors;
  102. std::vector<F32> mStarIntensities;
  103. U32 mLastWLSkyDetail;
  104. static U32 sWLSkyDetail;
  105. };
  106. #endif // LL_VOWLSKY_H