2013-11-13 19:07:35 +00:00
|
|
|
#include "SurfaceMaterial.h"
|
|
|
|
|
|
|
|
#include "PackStream.h"
|
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
SurfaceMaterial::SurfaceMaterial():
|
|
|
|
SurfaceMaterial(COLOR_BLACK)
|
2013-11-13 19:07:35 +00:00
|
|
|
{
|
2013-12-25 18:45:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceMaterial::SurfaceMaterial(const Color &color)
|
|
|
|
{
|
|
|
|
base = colorToHSL(color);
|
|
|
|
hardness = 0.5;
|
|
|
|
reflection = 0.0;
|
|
|
|
shininess = 0.0;
|
|
|
|
receive_shadows = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceMaterial::save(PackStream* stream) const
|
|
|
|
{
|
|
|
|
stream->write(&base.h);
|
|
|
|
stream->write(&base.l);
|
|
|
|
stream->write(&base.s);
|
2013-11-13 19:07:35 +00:00
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
stream->write(&hardness);
|
|
|
|
stream->write(&reflection);
|
|
|
|
stream->write(&shininess);
|
2013-11-13 19:07:35 +00:00
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
stream->write(&receive_shadows);
|
2013-11-13 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
void SurfaceMaterial::load(PackStream* stream)
|
2013-11-13 19:07:35 +00:00
|
|
|
{
|
2013-12-25 18:45:56 +00:00
|
|
|
stream->read(&base.h);
|
|
|
|
stream->read(&base.l);
|
|
|
|
stream->read(&base.s);
|
2013-11-13 19:07:35 +00:00
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
stream->read(&hardness);
|
|
|
|
stream->read(&reflection);
|
|
|
|
stream->read(&shininess);
|
2013-11-13 19:07:35 +00:00
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
stream->read(&receive_shadows);
|
2013-11-13 19:07:35 +00:00
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
validate();
|
2013-11-13 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 18:45:56 +00:00
|
|
|
void SurfaceMaterial::validate()
|
2013-11-13 19:07:35 +00:00
|
|
|
{
|
2013-12-25 18:45:56 +00:00
|
|
|
_rgb = colorFromHSL(base);
|
2013-11-13 19:07:35 +00:00
|
|
|
}
|