llvosky.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVOSKY_H
00033 #define LL_LLVOSKY_H
00034 
00035 #include "stdtypes.h"
00036 #include "v3color.h"
00037 #include "v4coloru.h"
00038 #include "llviewerimage.h"
00039 #include "llviewerobject.h"
00040 #include "llframetimer.h"
00041 
00042 
00044 //
00045 // Lots of constants
00046 //
00047 // Will clean these up at some point...
00048 //
00049 
00050 const F32 HORIZON_DIST                  = 1024.0f;
00051 const F32 SKY_BOX_MULT                  = 16.0f;
00052 const F32 HEAVENLY_BODY_DIST            = HORIZON_DIST - 10.f;
00053 const F32 HEAVENLY_BODY_FACTOR  = 0.1f;
00054 const F32 HEAVENLY_BODY_SCALE   = HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR;
00055 const F32 EARTH_RADIUS                  = 6.4e6f;       // exact radius = 6.37 x 10^6 m
00056 const F32 ATM_EXP_FALLOFF               = 0.000126f;
00057 const F32 ATM_SEA_LEVEL_NDENS   = 2.55e25f;
00058 // Somewhat arbitrary:
00059 const F32 ATM_HEIGHT                    = 100000.f;
00060 
00061 const F32 FIRST_STEP = 5000.f;
00062 const F32 INV_FIRST_STEP = 1.f/FIRST_STEP;
00063 const S32 NO_STEPS = 15;
00064 const F32 INV_NO_STEPS = 1.f/NO_STEPS;
00065 
00066 
00067 // constants used in calculation of scattering coeff of clear air
00068 const F32 sigma         = 0.035f;
00069 const F32 fsigma        = (6.f + 3.f * sigma) / (6.f-7.f*sigma);
00070 const F64 Ndens         = 2.55e25;
00071 const F64 Ndens2        = Ndens*Ndens;
00072 
00073 // HACK: Allow server to change sun and moon IDs.
00074 // I can't figure out how to pass the appropriate
00075 // information into the LLVOSky constructor.  JC
00076 extern LLUUID gSunTextureID;
00077 extern LLUUID gMoonTextureID;
00078 
00079 
00080 LL_FORCE_INLINE LLColor3 color_div(const LLColor3 &col1, const LLColor3 &col2)
00081 {
00082         return LLColor3( 
00083                 col1.mV[0] / col2.mV[0],
00084                 col1.mV[1] / col2.mV[1],
00085                 col1.mV[2] / col2.mV[2] );
00086 }
00087 
00088 LLColor3 color_norm(const LLColor3 &col);
00089 BOOL clip_quad_to_horizon(F32& t_left, F32& t_right, LLVector3 v_clipped[4],
00090                                                   const LLVector3 v_corner[4], const F32 cos_max_angle);
00091 F32 clip_side_to_horizon(const LLVector3& v0, const LLVector3& v1, const F32 cos_max_angle);
00092 
00093 inline F32 color_intens ( const LLColor3 &col )
00094 {
00095         return col.mV[0] + col.mV[1] + col.mV[2];
00096 }
00097 
00098 inline F32 color_max(const LLColor3 &col)
00099 {
00100         return llmax(col.mV[0], col.mV[1], col.mV[2]);
00101 }
00102 
00103 inline F32 color_max(const LLColor4 &col)
00104 {
00105         return llmax(col.mV[0], col.mV[1], col.mV[2]);
00106 }
00107 
00108 
00109 inline F32 color_min(const LLColor3 &col)
00110 {
00111         return llmin(col.mV[0], col.mV[1], col.mV[2]);
00112 }
00113 
00114 class LLFace;
00115 class LLHaze;
00116 
00117 
00118 class LLSkyTex
00119 {
00120         friend class LLVOSky;
00121 private:
00122         static S32              sResolution;
00123         static S32              sComponents;
00124         LLPointer<LLImageGL> mImageGL[2];
00125         LLPointer<LLImageRaw> mImageRaw[2];
00126         LLColor4                *mSkyData;
00127         LLVector3               *mSkyDirs;                      // Cache of sky direction vectors
00128         static S32              sCurrent;
00129         static F32              sInterpVal;
00130 
00131 public:
00132         static F32 getInterpVal()                                       { return sInterpVal; }
00133         static void setInterpVal(const F32 v)           { sInterpVal = v; }
00134         static BOOL doInterpolate()                                     { return sInterpVal > 0.001f; }
00135 
00136         void bindTexture(BOOL curr = TRUE);
00137         
00138 protected:
00139         LLSkyTex();
00140         void init();
00141         void cleanupGL();
00142         void restoreGL();
00143 
00144         ~LLSkyTex();
00145 
00146 
00147         static S32 getResolution()                                              { return sResolution; }
00148         static S32 getCurrent()                                         { return sCurrent; }
00149         static S32 stepCurrent()                                        { return (sCurrent = ++sCurrent % 2); }
00150         static S32 getNext()                                            { return ((sCurrent+1) % 2); }
00151         static S32 getWhich(const BOOL curr)            { return curr ? sCurrent : getNext(); }
00152 
00153         void initEmpty(const S32 tex);
00154         
00155         void create(F32 brightness);
00156 
00157         void setDir(const LLVector3 &dir, const S32 i, const S32 j)
00158         {
00159                 S32 offset = i * sResolution + j;
00160                 mSkyDirs[offset] = dir;
00161         }
00162 
00163         const LLVector3 &getDir(const S32 i, const S32 j) const
00164         {
00165                 S32 offset = i * sResolution + j;
00166                 return mSkyDirs[offset];
00167         }
00168 
00169         void setPixel(const LLColor4 &col, const S32 i, const S32 j)
00170         {
00171                 S32 offset = i * sResolution + j;
00172                 mSkyData[offset] = col;
00173         }
00174 
00175         void setPixel(const LLColor4U &col, const S32 i, const S32 j)
00176         {
00177                 S32 offset = (i * sResolution + j) * sComponents;
00178                 U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
00179                 *pix = col.mAll;
00180         }
00181 
00182         LLColor4U getPixel(const S32 i, const S32 j)
00183         {
00184                 LLColor4U col;
00185                 S32 offset = (i * sResolution + j) * sComponents;
00186                 U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
00187                 col.mAll = *pix;
00188                 return col;
00189         }
00190 
00191         LLImageRaw* getImageRaw(BOOL curr=TRUE)                 { return mImageRaw[getWhich(curr)]; }
00192         void createGLImage(BOOL curr=TRUE);
00193 };
00194 
00196 class LLHeavenBody
00197 {
00198 protected:
00199         LLVector3               mDirectionCached;               // hack for events that shouldn't happen every frame
00200 
00201         LLColor3                mColor;
00202         LLColor3                mColorCached;
00203         F32                             mIntensity;
00204         LLVector3               mDirection;                             // direction of the local heavenly body
00205         LLVector3               mAngularVelocity;               // velocity of the local heavenly body
00206 
00207         F32                             mDiskRadius;
00208         BOOL                    mDraw;                                  // FALSE - do not draw.
00209         F32                             mHorizonVisibility;             // number [0, 1] due to how horizon
00210         F32                             mVisibility;                    // same but due to other objects being in throng.
00211         BOOL                    mVisible;
00212         static F32              sInterpVal;
00213         LLVector3               mQuadCorner[4];
00214         LLVector3               mU;
00215         LLVector3               mV;
00216         LLVector3               mO;
00217 
00218 public:
00219         LLHeavenBody(const F32 rad) :
00220                 mDirectionCached(LLVector3(0,0,0)),
00221                 mDirection(LLVector3(0,0,0)),
00222                 mIntensity(0.f),
00223                 mDiskRadius(rad), mDraw(FALSE),
00224                 mHorizonVisibility(1.f), mVisibility(1.f),
00225                 mVisible(FALSE)
00226         {
00227                 mColor.setToBlack();
00228                 mColorCached.setToBlack();
00229         }
00230         ~LLHeavenBody() {}
00231 
00232         const LLVector3& getDirection() const                           { return mDirection; }
00233         void setDirection(const LLVector3 &direction)           { mDirection = direction; }
00234         void setAngularVelocity(const LLVector3 &ang_vel)       { mAngularVelocity = ang_vel; }
00235         const LLVector3& getAngularVelocity() const                     { return mAngularVelocity; }
00236 
00237         const LLVector3& getDirectionCached() const                     { return mDirectionCached; }
00238         void renewDirection()                                                           { mDirectionCached = mDirection; }
00239 
00240         const LLColor3& getColorCached() const                          { return mColorCached; }
00241         void setColorCached(const LLColor3& c)                          { mColorCached = c; }
00242         const LLColor3& getColor() const                                        { return mColor; }
00243         void setColor(const LLColor3& c)                                        { mColor = c; }
00244 
00245         void renewColor()                                                                       { mColorCached = mColor; }
00246 
00247         static F32 interpVal()                                                          { return sInterpVal; }
00248         static void setInterpVal(const F32 v)                           { sInterpVal = v; }
00249 
00250         LLColor3 getInterpColor() const
00251         {
00252                 return sInterpVal * mColor + (1 - sInterpVal) * mColorCached;
00253         }
00254 
00255         const F32& getHorizonVisibility() const                         { return mHorizonVisibility; }
00256         void setHorizonVisibility(const F32 c = 1)                      { mHorizonVisibility = c; }
00257         const F32& getVisibility() const                                        { return mVisibility; }
00258         void setVisibility(const F32 c = 1)                                     { mVisibility = c; }
00259         F32 getHaloBrighness() const
00260         {
00261                 return llmax(0.f, llmin(0.9f, mHorizonVisibility)) * mVisibility;
00262         }
00263         BOOL isVisible() const                                                          { return mVisible; }
00264         void setVisible(const BOOL v)                                           { mVisible = v; }
00265 
00266         const F32& getIntensity() const                                         { return mIntensity; }
00267         void setIntensity(const F32 c)                                          { mIntensity = c; }
00268 
00269         void setDiskRadius(const F32 radius)                            { mDiskRadius = radius; }
00270         F32     getDiskRadius() const                                                   { return mDiskRadius; }
00271 
00272         void setDraw(const BOOL draw)                                           { mDraw = draw; }
00273         BOOL getDraw() const                                                            { return mDraw; }
00274 
00275         const LLVector3& corner(const S32 n) const                      { return mQuadCorner[n]; }
00276         LLVector3& corner(const S32 n)                                          { return mQuadCorner[n]; }
00277         const LLVector3* corners() const                                        { return mQuadCorner; }
00278 
00279         const LLVector3& getU() const                                           { return mU; }
00280         const LLVector3& getV() const                                           { return mV; }
00281         void setU(const LLVector3& u)                                           { mU = u; }
00282         void setV(const LLVector3& v)                                           { mV = v; }
00283 };
00284 
00285 
00286 LL_FORCE_INLINE LLColor3 refr_ind_calc(const LLColor3 &wave_length)
00287 {
00288         LLColor3 refr_ind;
00289         for (S32 i = 0; i < 3; ++i)
00290         {
00291                 const F32 wl2 = wave_length.mV[i] * wave_length.mV[i] * 1e-6f;
00292                 refr_ind.mV[i] = 6.43e3f + ( 2.95e6f / ( 146.0f - 1.f/wl2 ) ) + ( 2.55e4f / ( 41.0f - 1.f/wl2 ) );
00293                 refr_ind.mV[i] *= 1.0e-8f;
00294                 refr_ind.mV[i] += 1.f;
00295         }
00296         return refr_ind;
00297 }
00298 
00299 
00300 LL_FORCE_INLINE LLColor3 calc_air_sca_sea_level()
00301 {
00302         const static LLColor3 WAVE_LEN(675, 520, 445);
00303         const static LLColor3 refr_ind = refr_ind_calc(WAVE_LEN);
00304         const static LLColor3 n21 = refr_ind * refr_ind - LLColor3(1, 1, 1);
00305         const static LLColor3 n4 = n21 * n21;
00306         const static LLColor3 wl2 = WAVE_LEN * WAVE_LEN * 1e-6f;
00307         const static LLColor3 wl4 = wl2 * wl2;
00308         const static LLColor3 mult_const = fsigma * 2.0f/ 3.0f * 1e24f * (F_PI * F_PI) * n4;
00309         const static F32 dens_div_N = F32( ATM_SEA_LEVEL_NDENS / Ndens2);
00310         return dens_div_N * color_div ( mult_const, wl4 );
00311 }
00312 
00313 const LLColor3 gAirScaSeaLevel = calc_air_sca_sea_level();
00314 const F32 AIR_SCA_INTENS = color_intens(gAirScaSeaLevel);       
00315 const F32 AIR_SCA_AVG = AIR_SCA_INTENS / 3.f;
00316 
00317 class LLHaze
00318 {
00319 public:
00320         LLHaze() : mG(0), mFalloff(1), mAbsCoef(0.f) {mSigSca.setToBlack();}
00321         LLHaze(const F32 g, const LLColor3& sca, const F32 fo = 2.f) : 
00322                         mG(g), mSigSca(0.25f/F_PI * sca), mFalloff(fo), mAbsCoef(0.f)
00323         {
00324                 mAbsCoef = color_intens(mSigSca) / AIR_SCA_INTENS;
00325         }
00326 
00327         LLHaze(const F32 g, const F32 sca, const F32 fo = 2.f) : mG(g),
00328                         mSigSca(0.25f/F_PI * LLColor3(sca, sca, sca)), mFalloff(fo)
00329         {
00330                 mAbsCoef = 0.01f * sca / AIR_SCA_AVG;
00331         }
00332 
00333         static void initClass();
00334 
00335 
00336         F32 getG() const                                { return mG; }
00337 
00338         void setG(const F32 g)
00339         {
00340                 mG = g;
00341         }
00342 
00343         const LLColor3& getSigSca() const // sea level
00344         {
00345                 return mSigSca;
00346         } 
00347 
00348         void setSigSca(const LLColor3& s)
00349         {
00350                 mSigSca = s;
00351                 mAbsCoef = 0.01f * color_intens(mSigSca) / AIR_SCA_INTENS;
00352         }
00353 
00354         void setSigSca(const F32 s0, const F32 s1, const F32 s2)
00355         {
00356                 mSigSca = AIR_SCA_AVG * LLColor3 (s0, s1, s2);
00357                 mAbsCoef = 0.01f * (s0 + s1 + s2) / 3;
00358         }
00359 
00360         F32 getFalloff() const
00361         {
00362                 return mFalloff;
00363         }
00364 
00365         void setFalloff(const F32 fo)
00366         {
00367                 mFalloff = fo;
00368         }
00369 
00370         F32 getAbsCoef() const
00371         {
00372                 return mAbsCoef;
00373         }
00374 
00375         inline static F32 calcFalloff(const F32 h)
00376         {
00377                 return (h <= 0) ? 1.0f : (F32)LL_FAST_EXP(-ATM_EXP_FALLOFF * h);
00378         }
00379 
00380         inline LLColor3 calcSigSca(const F32 h) const
00381         {
00382                 return calcFalloff(h * mFalloff) * mSigSca;
00383         }
00384 
00385         inline void calcSigSca(const F32 h, LLColor3 &result) const
00386         {
00387                 result = mSigSca;
00388                 result *= calcFalloff(h * mFalloff);
00389         }
00390 
00391         LLColor3 calcSigExt(const F32 h) const
00392         {
00393                 return calcFalloff(h * mFalloff) * (1 + mAbsCoef) * mSigSca;
00394         }
00395 
00396         F32 calcPhase(const F32 cos_theta) const;
00397 
00398         static inline LLColor3 calcAirSca(const F32 h);
00399         static inline void calcAirSca(const F32 h, LLColor3 &result);
00400         static LLColor3 calcAirScaSeaLevel()                    { return gAirScaSeaLevel; }
00401         static const LLColor3 &getAirScaSeaLevel()              { return sAirScaSeaLevel; }
00402 public:
00403         static LLColor3 sAirScaSeaLevel;
00404 
00405 protected:
00406         F32                     mG;
00407         LLColor3        mSigSca;
00408         F32                     mFalloff;       // 1 - slow, >1 - faster
00409         F32                     mAbsCoef;
00410 };
00411 
00412 
00413 class LLCubeMap;
00414 
00415 // turn on floating point precision
00416 // in vs2003 for this class.  Otherwise
00417 // black dots go everywhere from 7:10 - 8:50
00418 #if LL_MSVC && __MSVC_VER__ < 8
00419 #pragma optimize("p", on)               
00420 #endif
00421 
00422 
00423 class LLVOSky : public LLStaticViewerObject
00424 {
00425 public:
00427         F32 dome_radius;
00428         F32 dome_offset_ratio;
00429         LLColor3 sunlight_color;
00430         LLColor3 ambient;
00431         F32 gamma;
00432         LLVector4 lightnorm;
00433         LLVector4 unclamped_lightnorm;
00434         LLColor3 blue_density;
00435         LLColor3 blue_horizon;
00436         F32 haze_density;
00437         LLColor3 haze_horizon;
00438         F32 density_multiplier;
00439         F32 max_y;
00440         LLColor3 glow;
00441         F32 cloud_shadow;
00442         LLColor3 cloud_color;
00443         F32 cloud_scale;
00444         LLColor3 cloud_pos_density1;
00445         LLColor3 cloud_pos_density2;
00446         
00447 public:
00448         void initAtmospherics(void);
00449         void calcAtmospherics(void);
00450         LLColor3 createDiffuseFromWL(LLColor3 diffuse, LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient);
00451         LLColor3 createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient);
00452 
00453         void calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun, 
00454                                                         LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, 
00455                                                         LLVector2 vary_HorizontalProjection[2]);
00456 
00457         LLColor3 calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor,  LLColor3 & vary_CloudColorSun, 
00458                                                         LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity, 
00459                                                         LLVector2 vary_HorizontalProjection[2]);
00460 
00461 public:
00462         enum
00463         {
00464                 FACE_SIDE0,
00465                 FACE_SIDE1,
00466                 FACE_SIDE2,
00467                 FACE_SIDE3,
00468                 FACE_SIDE4,
00469                 FACE_SIDE5,
00470                 FACE_SUN, // was 6
00471                 FACE_MOON, // was 7
00472                 FACE_BLOOM, // was 8
00473                 FACE_REFLECTION, // was 10
00474                 FACE_DUMMY, //for an ATI bug --bao
00475                 FACE_COUNT
00476         };
00477         
00478         LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
00479 
00480         // Initialize/delete data that's only inited once per class.
00481         static void initClass();
00482         void init();
00483         void initCubeMap();
00484         void initEmpty();
00485         
00486         void cleanupGL();
00487         void restoreGL();
00488 
00489         /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00490         BOOL updateSky();
00491         
00492         // Graphical stuff for objects - maybe broken out into render class
00493         // later?
00494         /*virtual*/ void updateTextures(LLAgent &agent);
00495         /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
00496         /*virtual*/ BOOL                updateGeometry(LLDrawable *drawable);
00497 
00498         void initSkyTextureDirs(const S32 side, const S32 tile);
00499         void createSkyTexture(const S32 side, const S32 tile);
00500 
00501         LLColor4 calcSkyColorInDir(const LLVector3& dir, bool isShiny = false);
00502         
00503         LLColor3 calcRadianceAtPoint(const LLVector3& pos) const
00504         {
00505                 F32 radiance = mBrightnessScaleGuess * mSun.getIntensity();
00506                 return LLColor3(radiance, radiance, radiance);
00507         }
00508 
00509         const LLHeavenBody& getSun() const                                              { return mSun; }
00510         const LLHeavenBody& getMoon() const                                             { return mMoon; }
00511 
00512         const LLVector3& getToSunLast() const                                   { return mSun.getDirectionCached(); }
00513         const LLVector3& getToSun() const                                               { return mSun.getDirection(); }
00514         const LLVector3& getToMoon() const                                              { return mMoon.getDirection(); }
00515         const LLVector3& getToMoonLast() const                                  { return mMoon.getDirectionCached(); }
00516         BOOL isSunUp() const                                                                    { return mSun.getDirectionCached().mV[2] > -0.05f; }
00517         void calculateColors();
00518 
00519         LLColor3 getSunDiffuseColor() const                                             { return mSunDiffuse; }
00520         LLColor3 getMoonDiffuseColor() const                                    { return mMoonDiffuse; }
00521         LLColor4 getSunAmbientColor() const                                             { return mSunAmbient; }
00522         LLColor4 getMoonAmbientColor() const                                    { return mMoonAmbient; }
00523         const LLColor4& getTotalAmbientColor() const                    { return mTotalAmbient; }
00524         LLColor4 getFogColor() const                                                    { return mFogColor; }
00525         LLColor4 getGLFogColor() const                                                  { return mGLFogCol; }
00526         
00527         BOOL isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; }
00528 
00529         void initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity);
00530 
00531         void setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity);
00532 
00533         BOOL updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 side, const BOOL is_sun,
00534                                                                         LLHeavenBody& hb, const F32 sin_max_angle,
00535                                                                         const LLVector3 &up, const LLVector3 &right);
00536 
00537         F32 cosHorizon(const F32 delta = 0) const
00538         {
00539                 const F32 sin_angle = EARTH_RADIUS/(EARTH_RADIUS + mCameraPosAgent.mV[2]);
00540                 return delta - (F32)sqrt(1.f - sin_angle * sin_angle);
00541         }
00542 
00543         void updateSunHaloGeometry(LLDrawable *drawable);
00544         void updateReflectionGeometry(LLDrawable *drawable, F32 H, const LLHeavenBody& HB);
00545 
00546         
00547         const LLHaze& getHaze() const                                           { return mHaze; }
00548         LLHaze& getHaze()                                                                       { return mHaze; }
00549         F32 getHazeConcentration() const                                        { return mHazeConcentration; }
00550         void setHaze(const LLHaze& h)                                           { mHaze = h; }
00551         F32 getWorldScale() const                                                       { return mWorldScale; }
00552         void setWorldScale(const F32 s)                                         { mWorldScale = s; }
00553         void updateFog(const F32 distance);
00554         void setFogRatio(const F32 fog_ratio)                           { mFogRatio = fog_ratio; }
00555         LLColor4U getFadeColor() const                                          { return mFadeColor; }
00556         F32 getFogRatio() const                                                         { return mFogRatio; }
00557         void setCloudDensity(F32 cloud_density)                         { mCloudDensity = cloud_density; }
00558         void setWind ( const LLVector3& wind )                          { mWind = wind.magVec(); }
00559 
00560         const LLVector3 &getCameraPosAgent() const                      { return mCameraPosAgent; }
00561         LLVector3 getEarthCenter() const                                        { return mEarthCenter; }
00562 
00563         LLCubeMap *getCubeMap() const                                           { return mCubeMap; }
00564         S32 getDrawRefl() const                                                         { return mDrawRefl; }
00565         void setDrawRefl(const S32 r)                                           { mDrawRefl = r; }
00566         BOOL isReflFace(const LLFace* face) const                       { return face == mFace[FACE_REFLECTION]; }
00567         LLFace* getReflFace() const                                                     { return mFace[FACE_REFLECTION]; }
00568 
00569         LLViewerImage*  getSunTex() const                                       { return mSunTexturep; }
00570         LLViewerImage*  getMoonTex() const                                      { return mMoonTexturep; }
00571         LLViewerImage*  getBloomTex() const                                     { return mBloomTexturep; }
00572         void forceSkyUpdate(void)                                                       { mForceUpdate = TRUE; }
00573 
00574 public:
00575         LLFace  *mFace[FACE_COUNT];
00576         LLVector3       mBumpSunDir;
00577 
00578 protected:
00579         ~LLVOSky();
00580 
00581         LLPointer<LLViewerImage> mSunTexturep;
00582         LLPointer<LLViewerImage> mMoonTexturep;
00583         LLPointer<LLViewerImage> mBloomTexturep;
00584 
00585         static S32                      sResolution;
00586         static S32                      sTileResX;
00587         static S32                      sTileResY;
00588         LLSkyTex                        mSkyTex[6];
00589         LLSkyTex                        mShinyTex[6];
00590         LLHeavenBody            mSun;
00591         LLHeavenBody            mMoon;
00592         LLVector3                       mSunDefaultPosition;
00593         LLVector3                       mSunAngVel;
00594         F32                                     mAtmHeight;
00595         LLVector3                       mEarthCenter;
00596         LLVector3                       mCameraPosAgent;
00597         F32                                     mBrightnessScale;
00598         LLColor3                        mBrightestPoint;
00599         F32                                     mBrightnessScaleNew;
00600         LLColor3                        mBrightestPointNew;
00601         F32                                     mBrightnessScaleGuess;
00602         LLColor3                        mBrightestPointGuess;
00603         LLHaze                          mHaze;
00604         F32                                     mHazeConcentration;
00605         BOOL                            mWeatherChange;
00606         F32                                     mCloudDensity;
00607         F32                                     mWind;
00608         
00609         BOOL                            mInitialized;
00610         BOOL                            mForceUpdate;                           //flag to force instantaneous update of cubemap
00611         LLVector3                       mLastLightingDirection;
00612         LLColor3                        mLastTotalAmbient;
00613         F32                                     mAmbientScale;
00614         LLColor3                        mNightColorShift;
00615         F32                                     sInterpVal;
00616 
00617         LLColor4                        mFogColor;
00618         LLColor4                        mGLFogCol;
00619         
00620         F32                                     mFogRatio;
00621         F32                                     mWorldScale;
00622 
00623         LLColor4                        mSunAmbient;
00624         LLColor4                        mMoonAmbient;
00625         LLColor4                        mTotalAmbient;
00626         LLColor3                        mSunDiffuse;
00627         LLColor3                        mMoonDiffuse;
00628         LLColor4U                       mFadeColor;                                     // Color to fade in from        
00629 
00630         LLPointer<LLCubeMap>    mCubeMap;                                       // Cube map for the environment
00631         S32                                     mDrawRefl;
00632 
00633         LLFrameTimer            mUpdateTimer;
00634 
00635 public:
00636         //by bao
00637         //fake vertex buffer updating
00638         //to guaranttee at least updating one VBO buffer every frame
00639         //to walk around the bug caused by ATI card --> DEV-3855
00640         //
00641         void createDummyVertexBuffer() ;
00642         void updateDummyVertexBuffer() ;
00643 
00644         BOOL mHeavenlyBodyUpdated ;
00645 };
00646 
00647 // turn it off
00648 #if LL_MSVC && __MSVC_VER__ < 8
00649 #pragma optimize("p", off)              
00650 #endif
00651 
00652 // Utility functions
00653 F32 azimuth(const LLVector3 &v);
00654 F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply = FALSE);
00655 
00656 
00657 /* Proportion of light that is scattered into 'path' from 'in' over distance dt. */
00658 /* assumes that vectors 'path' and 'in' are normalized. Scattering coef / 2pi */
00659 
00660 inline LLColor3 LLHaze::calcAirSca(const F32 h)
00661 {
00662         static const LLColor3 air_sca_sea_level = calcAirScaSeaLevel();
00663         return calcFalloff(h) * air_sca_sea_level;
00664 }
00665 
00666 inline void LLHaze::calcAirSca(const F32 h, LLColor3 &result)
00667 {
00668         static const LLColor3 air_sca_sea_level = calcAirScaSeaLevel();
00669         result = air_sca_sea_level;
00670         result *= calcFalloff(h);
00671 }
00672 
00673 
00674 #endif

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