# include "config.h"
#endif
+#include <cstring>
#include <Main/fg_props.hxx>
#include <simgear/constants.h>
update_event = 0;
}
-FGClouds::~FGClouds() {
+FGClouds::~FGClouds()
+{
}
int FGClouds::get_update_event(void) const {
void FGClouds::init(void) {
if( snd_lightning == NULL ) {
- snd_lightning = new SGSoundSample(globals->get_fg_root().c_str(), "Sounds/thunder.wav");
+ snd_lightning = new SGSoundSample("Sounds/thunder.wav", SGPath());
snd_lightning->set_max_dist(7000.0f);
snd_lightning->set_reference_dist(3000.0f);
- SGSoundMgr *soundMgr = globals->get_soundmgr();
- soundMgr->add( snd_lightning, "thunder" );
- sgEnviro.set_soundMgr( soundMgr );
+ SGSoundMgr *smgr = globals->get_soundmgr();
+ SGSampleGroup *sgr = smgr->find("weather", true);
+ sgr->add( snd_lightning, "thunder" );
+ sgEnviro.set_sampleGroup( sgr );
}
}
texture_root.append("Sky");
box_def = box_def_root->getChild(name.c_str());
-
+
string base_name = name.substr(0,2);
if( !box_def ) {
if( name[2] == '-' ) {
double y = sg_random() * SGCloudField::fieldSize - (SGCloudField::fieldSize / 2.0);
double z = grid_z_rand * (sg_random() - 0.5);
- sgVec3 pos={x,y,z};
-
-
+ SGVec3f pos(x,y,z);
+
for(int i = 0; i < box_def->nChildren() ; i++) {
SGPropertyNode *abox = box_def->getChild(i);
if( strcmp(abox->getName(), "box") == 0) {
return extent;
}
-void FGClouds::buildLayer(int iLayer, const string& name, double alt, double coverage) {
+void FGClouds::buildLayer(int iLayer, const string& name, double coverage) {
struct {
string name;
double count;
} tCloudVariety[20];
int CloudVarietyCount = 0;
double totalCount = 0.0;
-
+
SGPropertyNode *cloud_def_root = fgGetNode("/environment/cloudlayers/clouds", false);
SGPropertyNode *box_def_root = fgGetNode("/environment/cloudlayers/boxes", false);
SGPropertyNode *layer_def_root = fgGetNode("/environment/cloudlayers/layers", false);
- SGCloudField *layer = thesky->get_cloud_layer(iLayer)->get_layer3D();
+ SGCloudField *layer = thesky->get_cloud_layer(iLayer)->get_layer3D();
layer->clear();
-
+
// If we don't have the required properties, then render the cloud in 2D
if ((! clouds_3d_enabled) || coverage == 0.0 ||
layer_def_root == NULL || cloud_def_root == NULL || box_def_root == NULL) {
thesky->get_cloud_layer(iLayer)->set_enable3dClouds(false);
return;
}
-
+
// If we can't find a definition for this cloud type, then render the cloud in 2D
SGPropertyNode *layer_def=NULL;
layer_def = layer_def_root->getChild(name.c_str());
}
totalCount = 1.0 / totalCount;
- // Determine how much cloud coverage we need in m^2.
- double cov = coverage * SGCloudField::fieldSize * SGCloudField::fieldSize;
+ // Determine how much cloud coverage we need in m^2.
+ double cov = coverage * SGCloudField::fieldSize * SGCloudField::fieldSize;
- while (cov > 0.0f) {
+ while (cov > 0.0f) {
double choice = sg_random();
-
+
for(int i = 0; i < CloudVarietyCount ; i ++) {
choice -= tCloudVariety[i].count * totalCount;
if( choice <= 0.0 ) {
cov -= buildCloud(cloud_def_root,
box_def_root,
tCloudVariety[i].name,
- grid_z_rand,
+ grid_z_rand,
layer);
break;
}
}
- }
+ }
// Now we've built any clouds, enable them and set the density (coverage)
//layer->setCoverage(coverage);
//double wind_speed_kt = metar_root->getDoubleValue("wind-speed-kt");
double temperature_degc = metar_root->getDoubleValue("temperature-sea-level-degc");
- double dewpoint_degc = metar_root->getDoubleValue("dewpoint-sea-level-degc");
- double pressure_mb = metar_root->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0;
-
- double dewp = pow(10.0, 7.5 * dewpoint_degc / (237.7 + dewpoint_degc));
- double temp = pow(10.0, 7.5 * temperature_degc / (237.7 + temperature_degc));
- double rel_humidity = dewp * 100 / temp;
+ double dewpoint_degc = metar_root->getDoubleValue("dewpoint-sea-level-degc");
+ double pressure_mb = metar_root->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0;
+ double rel_humidity = metar_root->getDoubleValue("relative-humidity");
// formule d'Epsy, base d'un cumulus
double cumulus_base = 122.0 * (temperature_degc - dewpoint_degc);
double alt_ft = cloud_root->getDoubleValue("elevation-ft");
double alt_m = alt_ft * SG_FEET_TO_METER;
- string coverage = cloud_root->getStringValue("coverage");
-
+ string coverage = cloud_root->getStringValue("coverage");
+
double coverage_norm = 0.0;
if( coverage == "few" )
coverage_norm = 2.0/8.0; // <1-2
coverage_norm = 8.0/8.0; // 8
string layer_type = "nn";
+
if( coverage == "cirrus" ) {
layer_type = "ci";
} else if( alt_ft > 16500 ) {
layer_type = "sc";
}
}
-
- buildLayer(iLayer, layer_type, alt_m, coverage_norm);
+
+ cloud_root->setStringValue("layer-type",layer_type);
+ buildLayer(iLayer, layer_type, coverage_norm);
}
}
void FGClouds::set_3dClouds(bool enable)
{
- if (enable != clouds_3d_enabled) {
- clouds_3d_enabled = enable;
- buildCloudLayers();
- }
+ if (enable != clouds_3d_enabled) {
+ clouds_3d_enabled = enable;
+ buildCloudLayers();
+ }
}
-bool FGClouds::get_3dClouds() const {
- return clouds_3d_enabled;
+bool FGClouds::get_3dClouds() const
+{
+ return clouds_3d_enabled;
}
-
+