~ubuntu-branches/debian/squeeze/stellarium/squeeze

« back to all changes in this revision

Viewing changes to src/Atmosphere.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2008-05-19 21:28:23 UTC
  • mfrom: (3.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080519212823-m5nfiuntxstxzxj7
Tags: 0.9.1-4
Add libxcursor-dev, libxfixes-dev, libxinerama-dev, libqt4-opengl-dev to
build-deps (Closes: #479906)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Stellarium
 
3
 * Copyright (C) 2003 Fabien Chereau
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifndef _STEL_ATMOSTPHERE_H_
 
21
#define _STEL_ATMOSTPHERE_H_
 
22
 
 
23
#include "Skylight.hpp"
 
24
#include "vecmath.h"
 
25
#include "Navigator.hpp"
 
26
#include "Skybright.hpp"
 
27
#include "Fader.hpp"
 
28
 
 
29
using namespace std;
 
30
 
 
31
class Projector;
 
32
class ToneReproducer;
 
33
 
 
34
//! Compute and display the daylight sky color using openGL.
 
35
//! The sky brightness is computed with the SkyBright class, the color with the SkyLight
 
36
class Atmosphere
 
37
{
 
38
public:
 
39
    Atmosphere(void);
 
40
    virtual ~Atmosphere(void);
 
41
        void compute_color(double JD, Vec3d sunPos, Vec3d moonPos, float moon_phase, ToneReproducer * eye, Projector* prj,
 
42
                float latitude = 45.f, float altitude = 200.f,
 
43
                float temperature = 15.f, float relative_humidity = 40.f);
 
44
        void draw(Projector* prj);
 
45
        void update(double deltaTime) {fader.update((int)(deltaTime*1000));}
 
46
        
 
47
        //! Set fade in/out duration in seconds
 
48
        void setFadeDuration(float duration) {fader.set_duration((int)(duration*1000.f));}
 
49
        //! Get fade in/out duration in seconds
 
50
        float getFadeDuration() {return fader.get_duration()/1000.f;}
 
51
        
 
52
        //! Define whether to display atmosphere
 
53
        void setFlagShow(bool b){fader = b;}
 
54
        //! Get whether atmosphere is displayed
 
55
        bool getFlagShow() const {return fader;}
 
56
        
 
57
        //! Get the actual atmosphere intensity due to eclipses + fader
 
58
        //! @return the display intensity ranging from 0 to 1
 
59
        float getRealDisplayIntensityFactor(void) const {return fader.getInterstate()*eclipseFactor;}
 
60
        
 
61
        // let's you know how far faded in or out the atm is (0-1)
 
62
        float getFadeIntensity(void) const {return fader.getInterstate();}
 
63
        
 
64
        //! Get the average luminance of the atmosphere in cd/m2
 
65
        //! If atmosphere is off, the luminance includes the background starlight + light pollution.
 
66
        //! Otherwise it includes the atmosphere + background starlight + eclipse factor + light pollution.
 
67
        //! @return the last computed average luminance of the atmosphere in cd/m2.
 
68
        float getAverageLuminance(void) const {return averageLuminance;}
 
69
 
 
70
        void setLightPollutionLuminance(float f) { lightPollutionLuminance = f; }
 
71
        float getLightPollutionLuminance() const { return lightPollutionLuminance; }
 
72
 
 
73
private:
 
74
        Vector4<GLint> viewport;
 
75
        Skylight sky;
 
76
        Skybright skyb;
 
77
        int sky_resolution_y,sky_resolution_x;
 
78
        struct GridPoint {
 
79
                Vec2f pos_2d;
 
80
                Vec3f color;
 
81
        };
 
82
        GridPoint *grid;        // For Atmosphere calculation
 
83
 
 
84
        //! The average luminance of the atmosphere in cd/m2
 
85
        float averageLuminance;
 
86
        double eclipseFactor;
 
87
        ParabolicFader fader;
 
88
        float lightPollutionLuminance;
 
89
};
 
90
 
 
91
#endif // _STEL_ATMOSTPHERE_H_