2015-10-15 15:52:03 +00:00
|
|
|
#include "TimeManager.h"
|
|
|
|
|
|
|
|
#include "AtmosphereDefinition.h"
|
|
|
|
#include "CloudLayerDefinition.h"
|
2016-07-23 20:58:32 +00:00
|
|
|
#include "CloudsDefinition.h"
|
|
|
|
#include "FloatNode.h"
|
|
|
|
#include "Scenery.h"
|
2015-10-15 15:52:03 +00:00
|
|
|
#include "WaterDefinition.h"
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
TimeManager::TimeManager() {
|
2015-10-15 15:52:03 +00:00
|
|
|
wind_x = 0.0;
|
|
|
|
wind_z = 0.0;
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TimeManager::moveForward(Scenery *scenery, double amount) {
|
2015-10-15 15:52:03 +00:00
|
|
|
// Move the sun
|
2015-12-29 23:20:20 +00:00
|
|
|
scenery->getAtmosphere()->setDayTime(scenery->getAtmosphere()->getDaytime() + amount);
|
2015-10-15 15:52:03 +00:00
|
|
|
|
|
|
|
// Move the clouds
|
2015-11-20 00:07:31 +00:00
|
|
|
int n = scenery->getClouds()->getLayerCount();
|
2015-11-09 21:30:46 +00:00
|
|
|
for (int i = 0; i < n; i++) {
|
2015-10-15 15:52:03 +00:00
|
|
|
CloudLayerDefinition *cloud = scenery->getClouds()->getCloudLayer(i);
|
|
|
|
cloud->propXOffset()->addValue(-wind_x * amount * 100.0);
|
|
|
|
cloud->propZOffset()->addValue(-wind_z * amount * 100.0);
|
|
|
|
// TODO Alter noise offsets
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move the water
|
|
|
|
WaterDefinition *water = scenery->getWater();
|
|
|
|
water->propXOffset()->addValue(-wind_x * amount * 10.0);
|
|
|
|
water->propZOffset()->addValue(-wind_z * amount * 10.0);
|
|
|
|
// TODO Alter noise offsets
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void TimeManager::setWind(double wind_x, double wind_z) {
|
2015-10-15 15:52:03 +00:00
|
|
|
this->wind_x = wind_x;
|
|
|
|
this->wind_z = wind_z;
|
|
|
|
}
|