paysages3d/src/definition/CloudLayerDefinition.cpp

81 lines
1.7 KiB
C++
Raw Normal View History

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
{
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)
{
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
{
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
}
}