mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
REfining the naming and introducing an orientation offset
This commit is contained in:
parent
e3b3c8e1ef
commit
f6a9bd1870
5 changed files with 49 additions and 16 deletions
|
@ -13,9 +13,11 @@ var day = 0.0;
|
|||
var hour = 12.0;
|
||||
var longitude = -115.0;
|
||||
var latitude = -31.0;
|
||||
var stageOrientation = Quat.fromPitchYawRollDegrees(0.0, 180.0, 0.0);
|
||||
|
||||
Scene.setDayTime(hour);
|
||||
//Scene.setOriginLocation(longitude, latitude, 0.0);
|
||||
Scene.setStageDayTime(hour);
|
||||
Scene.setStageOrientation(stageOrientation);
|
||||
Scene.setStageLocation(longitude, latitude, 0.0);
|
||||
|
||||
function ticktack() {
|
||||
hour += 0.1;
|
||||
|
@ -23,9 +25,9 @@ function ticktack() {
|
|||
if (hour > 24.0) {
|
||||
hour = 0.0;
|
||||
day++;
|
||||
Scene.setYearTime(day);
|
||||
Scene.setStageYearTime(day);
|
||||
}
|
||||
Scene.setDayTime(hour);
|
||||
Scene.setStageDayTime(hour);
|
||||
}
|
||||
|
||||
Script.setInterval(ticktack, 41);
|
||||
|
|
|
@ -73,9 +73,19 @@ void EarthSunModel::updateSun() const {
|
|||
|
||||
// sun direction is looking up toward Y axis at the specified sun lat, long
|
||||
Vec3d lssd = Vec3d(_worldToSurfaceMat * Vec4d(_sunDir.x, _sunDir.y, _sunDir.z, 0.0));
|
||||
|
||||
// apply surface rotation offset
|
||||
glm::dquat dSurfOrient(_surfaceOrientation);
|
||||
lssd = glm::rotate(dSurfOrient, lssd);
|
||||
|
||||
_surfaceSunDir = glm::normalize(Vec3(lssd.x, lssd.y, lssd.z));
|
||||
}
|
||||
|
||||
void EarthSunModel::setSurfaceOrientation(const Quat& orientation) {
|
||||
_surfaceOrientation = orientation;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
double moduloRange(double val, double minVal, double maxVal) {
|
||||
double range = maxVal - minVal;
|
||||
double rval = (val - minVal) / range;
|
||||
|
@ -155,6 +165,11 @@ void SunSkyStage::setYearTime(unsigned int day) {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
void SunSkyStage::setOriginOrientation(const Quat& orientation) {
|
||||
_earthSunModel.setSurfaceOrientation(orientation);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void SunSkyStage::setOriginLocation(float longitude, float latitude, float altitude) {
|
||||
_earthSunModel.setLongitude(longitude);
|
||||
_earthSunModel.setLatitude(latitude);
|
||||
|
|
|
@ -33,6 +33,10 @@ public:
|
|||
void setAltitude(float altitude);
|
||||
float getAltitude() const { return _altitude; }
|
||||
|
||||
|
||||
void setSurfaceOrientation(const Quat& orientation);
|
||||
const Quat& getSurfaceOrientation() const { valid(); return _surfaceOrientation; }
|
||||
|
||||
const Vec3d& getSurfacePos() const { valid(); return _surfacePos; }
|
||||
|
||||
const Mat4d& getSurfaceToWorldMat() const { valid(); return _surfaceToWorldMat; }
|
||||
|
@ -67,6 +71,8 @@ protected:
|
|||
double _scale = 1000.0; //Km
|
||||
double _earthRadius = 6360.0;
|
||||
|
||||
Quat _surfaceOrientation;
|
||||
|
||||
double _longitude = 0.0;
|
||||
double _latitude = 0.0;
|
||||
double _altitude = 0.01;
|
||||
|
@ -114,6 +120,12 @@ public:
|
|||
void setYearTime(unsigned int day);
|
||||
unsigned int getYearTime() const { return _yearTime; }
|
||||
|
||||
// Origin orientation used to modify the cardinal axis alignement used.
|
||||
// THe default is north along +Z axis and west along +X axis. this orientation gets added
|
||||
// to the transform stack producing the sun light direction.
|
||||
void setOriginOrientation(const Quat& orientation);
|
||||
const Quat& getOriginOrientation() const { return _earthSunModel.getSurfaceOrientation(); }
|
||||
|
||||
// Location used to define the sun & sky is a longitude and latitude [rad] and a earth surface altitude [km]
|
||||
void setOriginLocation(float longitude, float latitude, float surfaceAltitude);
|
||||
float getOriginLatitude() const { return _earthSunModel.getLatitude(); }
|
||||
|
|
|
@ -13,10 +13,20 @@
|
|||
|
||||
#include "SceneScriptingInterface.h"
|
||||
|
||||
Q_INVOKABLE void setOriginGeoLocation(float longitude, float latitude, float altitude);
|
||||
void SceneScriptingInterface::setOriginLocation(float longitude, float latitude, float altitude) {
|
||||
void SceneScriptingInterface::setStageOrientation(const glm::quat& orientation) {
|
||||
_skyStage->setOriginOrientation(orientation);
|
||||
}
|
||||
void SceneScriptingInterface::setStageLocation(float longitude, float latitude, float altitude) {
|
||||
_skyStage->setOriginLocation(longitude, latitude, altitude);
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setStageDayTime(float hour) {
|
||||
_skyStage->setDayTime(hour);
|
||||
}
|
||||
void SceneScriptingInterface::setStageYearTime(int day) {
|
||||
_skyStage->setYearTime(day);
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setSunColor(const glm::vec3& color) {
|
||||
_skyStage->setSunColor(color);
|
||||
}
|
||||
|
@ -24,12 +34,6 @@ void SceneScriptingInterface::setSunIntensity(float intensity) {
|
|||
_skyStage->setSunIntensity(intensity);
|
||||
}
|
||||
|
||||
void SceneScriptingInterface::setDayTime(float hour) {
|
||||
_skyStage->setDayTime(hour);
|
||||
}
|
||||
void SceneScriptingInterface::setYearTime(int day) {
|
||||
_skyStage->setYearTime(day);
|
||||
}
|
||||
|
||||
model::SunSkyStagePointer SceneScriptingInterface::getSkyStage() const {
|
||||
return _skyStage;
|
||||
|
|
|
@ -23,14 +23,14 @@ class SceneScriptingInterface : public QObject, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void setOriginLocation(float longitude, float latitude, float altitude);
|
||||
Q_INVOKABLE void setStageOrientation(const glm::quat& orientation);
|
||||
Q_INVOKABLE void setStageLocation(float longitude, float latitude, float altitude);
|
||||
Q_INVOKABLE void setStageDayTime(float hour);
|
||||
Q_INVOKABLE void setStageYearTime(int day);
|
||||
|
||||
Q_INVOKABLE void setSunColor(const glm::vec3& color);
|
||||
Q_INVOKABLE void setSunIntensity(float intensity);
|
||||
|
||||
Q_INVOKABLE void setDayTime(float hour);
|
||||
Q_INVOKABLE void setYearTime(int day);
|
||||
|
||||
model::SunSkyStagePointer getSkyStage() const;
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue