2013-11-15 22:26:44 +00:00
|
|
|
#include "CloudLayerDefinition.h"
|
|
|
|
|
|
|
|
#include "Curve.h"
|
|
|
|
#include "NoiseGenerator.h"
|
|
|
|
#include "SurfaceMaterial.h"
|
|
|
|
#include "PackStream.h"
|
|
|
|
|
|
|
|
CloudLayerDefinition::CloudLayerDefinition(BaseDefinition* parent):
|
|
|
|
BaseDefinition(parent)
|
|
|
|
{
|
2013-12-04 21:52:18 +00:00
|
|
|
type = CIRRUS;
|
|
|
|
altitude = 0.5;
|
|
|
|
scaling = 0.5;
|
|
|
|
coverage = 0.5;
|
2013-11-15 22:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CloudLayerDefinition::~CloudLayerDefinition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CloudLayerDefinition* CloudLayerDefinition::newCopy(const CloudLayerDefinition& other, BaseDefinition* parent)
|
|
|
|
{
|
|
|
|
CloudLayerDefinition* layer = new CloudLayerDefinition(parent);
|
|
|
|
other.copy(layer);
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloudLayerDefinition* CloudLayerDefinition::newCopy(BaseDefinition* parent) const
|
|
|
|
{
|
|
|
|
CloudLayerDefinition* layer = new CloudLayerDefinition(parent);
|
|
|
|
copy(layer);
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloudLayerDefinition::save(PackStream* stream) const
|
|
|
|
{
|
2013-11-17 21:47:27 +00:00
|
|
|
BaseDefinition::save(stream);
|
|
|
|
|
2013-11-15 22:26:44 +00:00
|
|
|
int clouds_type = (int)type;
|
|
|
|
|
|
|
|
stream->write(&clouds_type);
|
2013-12-04 21:52:18 +00:00
|
|
|
stream->write(&altitude);
|
|
|
|
stream->write(&scaling);
|
|
|
|
stream->write(&coverage);
|
2013-11-15 22:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CloudLayerDefinition::load(PackStream* stream)
|
|
|
|
{
|
2013-11-17 21:47:27 +00:00
|
|
|
BaseDefinition::load(stream);
|
|
|
|
|
2013-11-15 22:26:44 +00:00
|
|
|
int clouds_type;
|
|
|
|
|
|
|
|
stream->read(&clouds_type);
|
|
|
|
type = (CloudsType)clouds_type;
|
2013-12-04 21:52:18 +00:00
|
|
|
stream->read(&altitude);
|
|
|
|
stream->read(&scaling);
|
|
|
|
stream->read(&coverage);
|
2013-11-15 22:26:44 +00:00
|
|
|
|
|
|
|
validate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CloudLayerDefinition::copy(BaseDefinition* _destination) const
|
|
|
|
{
|
2013-11-17 21:47:27 +00:00
|
|
|
BaseDefinition::copy(_destination);
|
|
|
|
|
2013-11-15 22:26:44 +00:00
|
|
|
CloudLayerDefinition* destination = (CloudLayerDefinition*)_destination;
|
|
|
|
|
|
|
|
destination->type = type;
|
2013-12-04 21:52:18 +00:00
|
|
|
destination->altitude = altitude;
|
|
|
|
destination->scaling = scaling;
|
|
|
|
destination->coverage = coverage;
|
2013-11-15 22:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CloudLayerDefinition::validate()
|
|
|
|
{
|
2013-12-04 21:52:18 +00:00
|
|
|
if (scaling < 0.1)
|
2013-11-15 22:26:44 +00:00
|
|
|
{
|
2013-12-04 21:52:18 +00:00
|
|
|
scaling = 0.1;
|
2013-11-15 22:26:44 +00:00
|
|
|
}
|
|
|
|
}
|