Added /atmosphere/humidity control
This commit is contained in:
parent
625507e11d
commit
c199bef7f2
9 changed files with 73 additions and 33 deletions
|
@ -8,6 +8,7 @@ AtmosphereDefinition::AtmosphereDefinition(DefinitionNode* parent):
|
|||
DefinitionNode(parent, "atmosphere", "atmosphere")
|
||||
{
|
||||
daytime = new FloatNode(this, "daytime");
|
||||
humidity = new FloatNode(this, "humidity");
|
||||
}
|
||||
|
||||
AtmosphereDefinition::~AtmosphereDefinition()
|
||||
|
@ -22,7 +23,6 @@ void AtmosphereDefinition::save(PackStream* stream) const
|
|||
sun_color.save(stream);
|
||||
stream->write(&sun_radius);
|
||||
stream->write(&dome_lighting);
|
||||
stream->write(&humidity);
|
||||
stream->write(&moon_radius);
|
||||
stream->write(&moon_theta);
|
||||
stream->write(&moon_phi);
|
||||
|
@ -45,7 +45,6 @@ void AtmosphereDefinition::load(PackStream* stream)
|
|||
sun_color.load(stream);
|
||||
stream->read(&sun_radius);
|
||||
stream->read(&dome_lighting);
|
||||
stream->read(&humidity);
|
||||
stream->read(&moon_radius);
|
||||
stream->read(&moon_theta);
|
||||
stream->read(&moon_phi);
|
||||
|
@ -78,7 +77,6 @@ void AtmosphereDefinition::copy(DefinitionNode* _destination) const
|
|||
destination->sun_color = sun_color;
|
||||
destination->sun_radius = sun_radius;
|
||||
destination->dome_lighting = dome_lighting;
|
||||
destination->humidity = humidity;
|
||||
destination->moon_radius = moon_radius;
|
||||
destination->moon_theta = moon_theta;
|
||||
destination->moon_phi = moon_phi;
|
||||
|
@ -125,7 +123,6 @@ void AtmosphereDefinition::applyPreset(AtmospherePreset preset)
|
|||
moon_radius = 1.0;
|
||||
moon_theta = 0.3;
|
||||
moon_phi = 0.5;
|
||||
humidity = 0.1;
|
||||
|
||||
model = ATMOSPHERE_MODEL_BRUNETON;
|
||||
|
||||
|
@ -133,27 +130,29 @@ void AtmosphereDefinition::applyPreset(AtmospherePreset preset)
|
|||
{
|
||||
case ATMOSPHERE_PRESET_CLEAR_DAY:
|
||||
setDayTime(15);
|
||||
humidity->setValue(0.1);
|
||||
dome_lighting = 0.2;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_CLEAR_SUNSET:
|
||||
setDayTime(17, 45);
|
||||
humidity->setValue(0.1);
|
||||
dome_lighting = 0.3;
|
||||
sun_radius = 0.03;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_HAZY_MORNING:
|
||||
setDayTime(8, 30);
|
||||
humidity->setValue(0.4);
|
||||
dome_lighting = 0.25;
|
||||
humidity = 0.4;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_FOGGY:
|
||||
setDayTime(15);
|
||||
humidity->setValue(0.7);
|
||||
dome_lighting = 0.1;
|
||||
humidity = 0.7;
|
||||
break;
|
||||
case ATMOSPHERE_PRESET_STORMY:
|
||||
setDayTime(15);
|
||||
humidity->setValue(0.9);
|
||||
dome_lighting = 0.05;
|
||||
humidity = 0.9;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
virtual void copy(DefinitionNode* destination) const override;
|
||||
|
||||
inline FloatNode *propDayTime() const {return daytime;}
|
||||
inline FloatNode *propHumidity() const {return humidity;}
|
||||
|
||||
/**
|
||||
* Set the daytime from a 0.0-1.0 value.
|
||||
|
@ -65,7 +66,7 @@ public:
|
|||
|
||||
public:
|
||||
AtmosphereModel model;
|
||||
double humidity;
|
||||
|
||||
Color sun_color;
|
||||
double sun_radius;
|
||||
double dome_lighting;
|
||||
|
@ -77,6 +78,7 @@ public:
|
|||
std::vector<Star> stars;
|
||||
|
||||
private:
|
||||
FloatNode *humidity;
|
||||
FloatNode *daytime;
|
||||
};
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
AtmosphereModeler::AtmosphereModeler(MainModelerWindow *main)
|
||||
{
|
||||
prop_daytime = new FloatPropertyBind(main, "atmosphere_daytime", "value", main->getScenery()->getAtmosphere()->propDayTime());
|
||||
prop_humidity = new FloatPropertyBind(main, "atmosphere_humidity", "value", main->getScenery()->getAtmosphere()->propHumidity());
|
||||
}
|
||||
|
||||
AtmosphereModeler::~AtmosphereModeler()
|
||||
{
|
||||
delete prop_daytime;
|
||||
delete prop_humidity;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public:
|
|||
|
||||
private:
|
||||
FloatPropertyBind *prop_daytime;
|
||||
FloatPropertyBind *prop_humidity;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,12 @@ BaseSection {
|
|||
picture: "images/icon_atmosphere_daytime.png"
|
||||
hovertext: qsTr("Change the time of day")
|
||||
}
|
||||
|
||||
ToolbarButton {
|
||||
id: tool_humidity
|
||||
picture: "images/icon_atmosphere_humidity.png"
|
||||
hovertext: qsTr("Humidity factor in the air")
|
||||
}
|
||||
}
|
||||
|
||||
PanelAtmosphereDaytime {
|
||||
|
@ -21,6 +27,13 @@ BaseSection {
|
|||
enabled: false
|
||||
}
|
||||
|
||||
PanelSimpleFloat {
|
||||
id: panel_humidity
|
||||
anchors.left: toolbar.right
|
||||
enabled: false
|
||||
objectName: "atmosphere_humidity"
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "DayTime"
|
||||
|
@ -29,6 +42,14 @@ BaseSection {
|
|||
target: panel_daytime
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "Humidity"
|
||||
when: tool_humidity.selected
|
||||
PropertyChanges {
|
||||
target: panel_humidity
|
||||
enabled: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
19
src/interface/modeler/quickapp/qml/PanelSimpleFloat.qml
Normal file
19
src/interface/modeler/quickapp/qml/PanelSimpleFloat.qml
Normal file
|
@ -0,0 +1,19 @@
|
|||
import QtQuick 2.0
|
||||
|
||||
// Simple panel with a single float slider
|
||||
BasePanel {
|
||||
id: panel
|
||||
property alias objectName: slider.objectName
|
||||
property alias minimumValue: slider.minimumValue
|
||||
property alias maximumValue: slider.maximumValue
|
||||
width: 40
|
||||
|
||||
BaseSlider {
|
||||
id: slider
|
||||
minimumValue: 0
|
||||
maximumValue: 1
|
||||
orientation: Qt.Vertical
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
}
|
||||
}
|
|
@ -15,20 +15,13 @@ BaseSection {
|
|||
}
|
||||
}
|
||||
|
||||
BasePanel {
|
||||
PanelSimpleFloat {
|
||||
id: panel_water_level
|
||||
width: 40
|
||||
anchors.left: toolbar.right
|
||||
enabled: false
|
||||
|
||||
BaseSlider {
|
||||
objectName: "water_height"
|
||||
minimumValue: -1
|
||||
maximumValue: 1
|
||||
orientation: Qt.Vertical
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
}
|
||||
anchors.left: toolbar.right
|
||||
minimumValue: -1
|
||||
maximumValue: 1
|
||||
objectName: "water_height"
|
||||
}
|
||||
|
||||
states: [
|
||||
|
|
|
@ -42,5 +42,6 @@
|
|||
<file>WaterSection.qml</file>
|
||||
<file>BaseSection.qml</file>
|
||||
<file>AtmosphereSection.qml</file>
|
||||
<file>PanelSimpleFloat.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -33,7 +33,7 @@ static inline void _applyWeatherEffects(AtmosphereDefinition* definition, Atmosp
|
|||
}
|
||||
|
||||
double distance = result->distance;
|
||||
double max_distance = 100.0 - 90.0 * definition->humidity;
|
||||
double max_distance = 100.0 - 90.0 * definition->propHumidity()->getValue();
|
||||
double distancefactor, dayfactor;
|
||||
|
||||
if (distance > max_distance)
|
||||
|
@ -44,33 +44,35 @@ static inline void _applyWeatherEffects(AtmosphereDefinition* definition, Atmosp
|
|||
/* TODO Get day lighting from model */
|
||||
dayfactor = _getDayFactor(definition->propDayTime()->getValue());
|
||||
|
||||
double humidity = definition->propHumidity()->getValue();
|
||||
|
||||
/* Fog masking */
|
||||
if (definition->humidity > 0.3)
|
||||
if (humidity > 0.3)
|
||||
{
|
||||
result->mask.r = result->mask.g = result->mask.b = (10.0 - 8.0 * definition->humidity) * dayfactor;
|
||||
result->mask.a = distancefactor * (definition->humidity - 0.3) / 0.7;
|
||||
result->mask.r = result->mask.g = result->mask.b = (10.0 - 8.0 * humidity) * dayfactor;
|
||||
result->mask.a = distancefactor * (humidity - 0.3) / 0.7;
|
||||
}
|
||||
|
||||
/* Scattering tweaking */
|
||||
if (definition->humidity < 0.15)
|
||||
if (humidity < 0.15)
|
||||
{
|
||||
/* Limit scattering on ultra clear day */
|
||||
double force = (0.15 - definition->humidity) / 0.15;
|
||||
double force = (0.15 - humidity) / 0.15;
|
||||
result->inscattering.limitPower(100.0 - 90.0 * pow(force, 0.1));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Scattering boost */
|
||||
double force = 1.2 * (definition->humidity < 0.5 ? sqrt((definition->humidity - 0.15) / 0.35) : 1.0 - (definition->humidity - 0.5) / 0.5);
|
||||
result->inscattering.r *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
|
||||
result->inscattering.g *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
|
||||
result->inscattering.b *= 1.0 + force * distancefactor * (definition->humidity - 0.15) / 0.85;
|
||||
double force = 1.2 * (humidity < 0.5 ? sqrt((humidity - 0.15) / 0.35) : 1.0 - (humidity - 0.5) / 0.5);
|
||||
result->inscattering.r *= 1.0 + force * distancefactor * (humidity - 0.15) / 0.85;
|
||||
result->inscattering.g *= 1.0 + force * distancefactor * (humidity - 0.15) / 0.85;
|
||||
result->inscattering.b *= 1.0 + force * distancefactor * (humidity - 0.15) / 0.85;
|
||||
}
|
||||
|
||||
/* Attenuation */
|
||||
result->attenuation.r *= 1.0 - 0.4 * distancefactor * definition->humidity;
|
||||
result->attenuation.g *= 1.0 - 0.4 * distancefactor * definition->humidity;
|
||||
result->attenuation.b *= 1.0 - 0.4 * distancefactor * definition->humidity;
|
||||
result->attenuation.r *= 1.0 - 0.4 * distancefactor * humidity;
|
||||
result->attenuation.g *= 1.0 - 0.4 * distancefactor * humidity;
|
||||
result->attenuation.b *= 1.0 - 0.4 * distancefactor * humidity;
|
||||
|
||||
result->updateFinal();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue