00001 #ifndef SKYDOME_H
00002 #define SKYDOME_H
00003
00004 #include <vrs/environment/config.h>
00005 #include <vrs/shape.h>
00006 #include <vrs/color.h>
00007
00008 namespace VRS {
00009 template<typename T> class Array;
00010 class TextureGL;
00011 }
00012
00013 namespace EnvironmentRenderer {
00014
00015 class CloudLayer;
00016
00022 class VRS_ENV_API SkyDome : public VRS::Shape {
00023 public:
00032 SkyDome(const VRS::Vector &sunDir = VRS::Vector(0.0, 1.0, 0.0),
00033 const VRS::Color &sunColor = VRS::Color(1.0, 1.0, 1.0),
00034 bool perFragment = true);
00035
00037 virtual VRS::Bounds boundingBox() const;
00038
00040 VRS::Vector getSunDirection() const;
00041 void setSunDirection(const VRS::Vector &dir);
00042
00050 static VRS::Vector calculateSunDirection(double longitude, double latitude, int year, int month, int day, int hour = 12, int minute = 0, int second = 0);
00051 void setSunDirection(double longitude, double latitude, int year, int month, int day, int hour = 12, int minute = 0, int second = 0);
00052
00054 void addCloudLayer(VRS::SO<CloudLayer> layer);
00055
00060 CloudLayer* removeCloudLayer(unsigned int index);
00061 bool removeCloudLayer(VRS::SO<CloudLayer> layer);
00062
00064 void clearCloudLayers();
00065
00067 void setRenderClouds(bool yesNo);
00068 bool renderClouds() const;
00069
00072 CloudLayer* getCloudLayer(unsigned int index) const;
00073
00075 VRS::SO<VRS::Iterator<VRS::SO<CloudLayer> > > getCloudLayers() const;
00076
00078 bool getPerFragment() const;
00079 void setPerFragment(bool perFragment);
00080
00085 VRS::Color getSunLightColor() const;
00086 void setSunLightColor(const VRS::Color &c);
00087
00091 VRS::Color getSunLightColorGroundLevel() const;
00092
00095 VRS::Vector getSkyColor(const VRS::Vector& direction) const;
00096
00105 double getPlanetRadius() const;
00106 void setPlanetRadius(double radius);
00107
00108 double getAtmosphereThickness() const;
00109 void setAtmosphereThickness(double thickness);
00110
00114 VRS::VertexData<2, unsigned int> getAtmosphereDetail() const;
00115 void setAtmosphereDetail(unsigned int slices, unsigned int stacks);
00116
00117 VRS::VertexData<2, unsigned int> getCloudDetail() const;
00118 void setCloudDetail(unsigned int slices, unsigned int stacks);
00119
00120
00127 VRS::VertexData<3, unsigned int> getWavelengths() const;
00128 void setWavelengths(unsigned int red, unsigned int green, unsigned int blue);
00129
00134 float getRayleighCoefficient() const;
00135 void setRayleighCoefficient(float coeff);
00136
00142 float getExcentricity() const;
00143 void setExcentricity(float excentricity);
00144 float getMieCoefficient() const;
00145 void setMieCoefficient(float coeff);
00146
00149 float getInscatteringScale() const;
00150 void setInscatteringScale(float scale);
00151
00152
00156 static double calculateAtmosphereThickness(double planetRadius, double atmosphereThickness, const VRS::Vector &direction);
00157
00158
00159 bool needsUpdateAtmosphere() const;
00160 bool needsUpdateClouds() const;
00161
00162 VRS_TYPEINFO(SkyDome, VRS::Shape);
00163 VRS_SERIALIZABLE(SkyDome);
00164
00165 private:
00166 VRS::Bounds m_boundingBox;
00167
00168 VRS::Vector m_sunDirection;
00169 VRS::Color m_sunColor;
00170
00171 VRS::VertexData<3, unsigned int> m_wavelengths;
00172
00173 float m_rayleighCoefficient;
00174 float m_excentricity, m_mieCoefficient, m_inscatteringScale;
00175
00176 double m_atmosphereThickness, m_planetRadius;
00177 VRS::VertexData<2, unsigned int> m_atmosphereDetail, m_cloudDetail;
00178
00179 bool m_perFragment;
00180 bool m_renderClouds;
00181
00182 VRS::SO<VRS::Array<VRS::SO<CloudLayer> > > m_cloudLayers;
00183
00184 mutable bool m_needsUpdateAtmosphere, m_needsUpdateClouds;
00185 };
00186
00187
00189 class VRS_ENV_API CloudLayer : public VRS::SharedObj {
00190 public:
00212 CloudLayer(VRS::TextureGL* texture, const VRS::Vector& flowingDirection = VRS::Vector::origin, double coverage = 0.5, double density = 0.0, double opacity = 1.0, const VRS::Vector& scale = VRS::Vector(1.0, 1.0, 1.0));
00213
00214 VRS::TextureGL* getTexture() const;
00215 void setTexture(VRS::TextureGL* texture);
00216
00217 VRS::Vector getFlowingDirection() const;
00218 void setFlowingDirection(const VRS::Vector& direction);
00219
00220 double getCoverage() const;
00221 void setCoverage(double coverage);
00222
00223 double getDensity() const;
00224 void setDensity(double density);
00225
00226 double getOpacity() const;
00227 void setOpacity(double opacity);
00228
00229 VRS::Vector getScale() const;
00230 void setScale(const VRS::Vector& scale);
00231
00232 VRS_TYPEINFO(CloudLayer, VRS::SharedObj);
00233 VRS_SERIALIZABLE(CloudLayer);
00234
00235 private:
00236 CloudLayer();
00237
00238 VRS::SO<VRS::TextureGL> m_texture;
00239 VRS::Vector m_flowingDirection;
00240 VRS::Vector m_scale;
00241
00242 double m_coverage, m_density, m_opacity;
00243 };
00244
00245 }
00246
00247 #endif // SKYDOME_H
00248