11 #ifndef hifi_model_Stage_h
12 #define hifi_model_Stage_h
14 #include <gpu/Pipeline.h>
21 typedef glm::dvec3 Vec3d;
22 typedef glm::dvec4 Vec4d;
23 typedef glm::dmat4 Mat4d;
24 typedef glm::mat4
Mat4;
29 void setScale(
float scale);
30 float getScale()
const {
return _scale; }
32 void setLatitude(
float lat);
33 float getLatitude()
const {
return _latitude; }
34 void setLongitude(
float lon);
35 float getLongitude()
const {
return _longitude; }
36 void setAltitude(
float altitude);
37 float getAltitude()
const {
return _altitude; }
40 void setSurfaceOrientation(
const Quat& orientation);
41 const Quat& getSurfaceOrientation()
const { valid();
return _surfaceOrientation; }
43 const Vec3d& getSurfacePos()
const { valid();
return _surfacePos; }
45 const Mat4d& getSurfaceToWorldMat()
const { valid();
return _surfaceToWorldMat; }
46 const Mat4d& getWoldToSurfaceMat()
const { valid();
return _worldToSurfaceMat; }
48 const Mat4d& getEyeToSurfaceMat()
const { valid();
return _eyeToSurfaceMat; }
49 const Mat4d& getSurfaceToEyeMat()
const { valid();
return _surfaceToEyeMat; }
51 const Mat4d& getEyeToWorldMat()
const { valid();
return _eyeToWorldMat; }
52 const Mat4d& getWorldToEyeMat()
const { valid();
return _worldToEyeMat; }
56 void setEyeToSurfaceMat(
const Mat4d& e2s);
58 const Vec3d& getEyePos()
const { valid();
return _eyePos; }
59 const Vec3d& getEyeDir()
const { valid();
return _eyeDir; }
61 void setSunLongitude(
float lon);
62 float getSunLongitude()
const {
return _sunLongitude; }
64 void setSunLatitude(
float lat);
65 float getSunLatitude()
const {
return _sunLatitude; }
67 const Vec3d& getWorldSunDir()
const { valid();
return _sunDir; }
68 const Vec3d& getSurfaceSunDir()
const { valid();
return _surfaceSunDir; }
71 EarthSunModel() { valid(); }
74 float _scale = 1000.0f;
75 float _earthRadius = 6360.0;
77 Quat _surfaceOrientation;
79 float _longitude = 0.0f;
80 float _latitude = 0.0f;
81 float _altitude = 0.01f;
82 mutable Vec3d _surfacePos;
83 mutable Mat4d _worldToSurfaceMat;
84 mutable Mat4d _surfaceToWorldMat;
85 void updateWorldToSurface()
const;
87 mutable Mat4d _surfaceToEyeMat;
88 mutable Mat4d _eyeToSurfaceMat;
89 mutable Vec3d _eyeDir;
90 mutable Vec3d _eyePos;
91 void updateSurfaceToEye()
const;
93 mutable Mat4d _worldToEyeMat;
94 mutable Mat4d _eyeToWorldMat;
96 float _sunLongitude = 0.0f;
97 float _sunLatitude = 0.0f;
98 mutable Vec3d _sunDir;
99 mutable Vec3d _surfaceSunDir;
100 void updateSun()
const;
102 mutable bool _invalid =
true;
103 void invalidate()
const { _invalid =
true; }
104 void valid()
const {
if (_invalid) { updateAll(); _invalid =
false; } }
105 void updateAll()
const;
107 static Mat4d evalWorldToGeoLocationMat(
double longitude,
double latitude,
double altitude,
double scale);
119 void setDayTime(
float hour);
120 float getDayTime()
const {
return _dayTime; }
123 void setYearTime(
unsigned int day);
124 unsigned int getYearTime()
const {
return _yearTime; }
129 void setOriginOrientation(
const Quat& orientation);
130 const Quat& getOriginOrientation()
const {
return _earthSunModel.getSurfaceOrientation(); }
133 void setOriginLatitude(
float latitude);
134 void setOriginLongitude(
float longitude);
135 void setOriginSurfaceAltitude(
float surfaceAltitude);
136 void setOriginLocation(
float longitude,
float latitude,
float surfaceAltitude);
137 float getOriginLatitude()
const {
return _earthSunModel.getLatitude(); }
138 float getOriginLongitude()
const {
return _earthSunModel.getLongitude(); }
139 float getOriginSurfaceAltitude()
const {
return _earthSunModel.getAltitude(); }
142 void setSunModelEnable(
bool isEnabled);
143 bool isSunModelEnabled()
const {
return _sunModelEnable; }
146 void setSunColor(
const Vec3& color) { _sunLight->setColor(color); }
147 const Vec3& getSunColor()
const {
return getSunLight()->getColor(); }
148 void setSunIntensity(
float intensity) { _sunLight->setIntensity(intensity); }
149 float getSunIntensity()
const {
return getSunLight()->getIntensity(); }
150 void setSunAmbientIntensity(
float intensity) { _sunLight->setAmbientIntensity(intensity); }
151 float getSunAmbientIntensity()
const {
return getSunLight()->getAmbientIntensity(); }
152 void setSunAmbientSphere(
const gpu::SHPointer& sphere);
153 void setSunAmbientMap(
const gpu::TexturePointer& map);
156 void setSunDirection(
const Vec3& direction);
157 const Vec3& getSunDirection()
const {
return getSunLight()->getDirection(); }
159 LightPointer getSunLight()
const { valid();
return _sunLight; }
161 enum BackgroundMode {
165 SKY_DEFAULT_AMBIENT_TEXTURE,
168 NUM_BACKGROUND_MODES,
170 void setBackgroundMode(BackgroundMode mode);
171 BackgroundMode getBackgroundMode()
const {
return _backgroundMode; }
174 void setSkybox(
const SkyboxPointer& skybox);
175 const SkyboxPointer& getSkybox()
const { valid();
return _skybox; }
178 BackgroundMode _backgroundMode = SKY_DEFAULT;
180 LightPointer _sunLight;
181 mutable SkyboxPointer _skybox;
183 float _dayTime = 12.0f;
185 mutable EarthSunModel _earthSunModel;
186 bool _sunModelEnable =
true;
188 mutable bool _invalid =
true;
189 void invalidate()
const { _invalid =
true; }
190 void valid()
const {
if (_invalid) { updateGraphicsObject(); _invalid =
false; } }
191 void updateGraphicsObject()
const;
194 typedef std::shared_ptr< SunSkyStage > SunSkyStagePointer;
Provides the Mat4 scripting interface.
Definition: Mat4.h:44
Provides the Quat scripting interface.
Definition: Quat.h:61
Provides the Vec3 scripting interface.
Definition: Vec3.h:80