paysages3d/src/definition/SurfaceMaterial.cpp

75 lines
1.4 KiB
C++
Raw Normal View History

2013-11-13 19:07:35 +00:00
#include "SurfaceMaterial.h"
#include "PackStream.h"
#include "Color.h"
2013-11-13 19:07:35 +00:00
static SurfaceMaterial DEFAULT;
SurfaceMaterial::SurfaceMaterial():
SurfaceMaterial(COLOR_BLACK)
2013-11-13 19:07:35 +00:00
{
}
SurfaceMaterial::SurfaceMaterial(const Color &color)
{
base = new Color(color);
hardness = 0.5;
reflection = 0.0;
shininess = 0.0;
receive_shadows = 1.0;
}
SurfaceMaterial::~SurfaceMaterial()
{
delete base;
}
const SurfaceMaterial &SurfaceMaterial::getDefault()
{
return DEFAULT;
}
void SurfaceMaterial::setColor(double r, double g, double b, double a)
{
base->r = r;
base->g = g;
base->b = b;
base->a = a;
}
void SurfaceMaterial::save(PackStream* stream) const
{
base->save(stream);
2013-11-13 19:07:35 +00:00
stream->write(&hardness);
stream->write(&reflection);
stream->write(&shininess);
2013-11-13 19:07:35 +00:00
stream->write(&receive_shadows);
2013-11-13 19:07:35 +00:00
}
void SurfaceMaterial::load(PackStream* stream)
2013-11-13 19:07:35 +00:00
{
base->load(stream);
2013-11-13 19:07:35 +00:00
stream->read(&hardness);
stream->read(&reflection);
stream->read(&shininess);
2013-11-13 19:07:35 +00:00
stream->read(&receive_shadows);
2013-11-13 19:07:35 +00:00
}
2015-10-15 18:28:05 +00:00
void SurfaceMaterial::copy(SurfaceMaterial *destination) const
{
*destination->base = *base;
destination->hardness = hardness;
destination->reflection = reflection;
destination->shininess = shininess;
destination->receive_shadows = receive_shadows;
destination->validate();
}
void SurfaceMaterial::validate()
2013-11-13 19:07:35 +00:00
{
}