paysages3d/src/render/software/LightStatus.cpp

34 lines
755 B
C++
Raw Normal View History

2013-12-08 16:56:59 +00:00
#include "LightStatus.h"
#include "LightingManager.h"
#include "Color.h"
#include "SurfaceMaterial.h"
2013-12-08 16:56:59 +00:00
LightStatus::LightStatus(LightingManager *manager, const Vector3 &location, const Vector3 &eye)
{
this->manager = manager;
this->location = location;
this->eye = eye;
}
void LightStatus::pushComponent(LightComponent component)
{
if (manager->alterLight(component, location))
2013-12-08 16:56:59 +00:00
{
components.push_back(component);
2013-12-08 16:56:59 +00:00
}
}
Color LightStatus::apply(const Vector3 &normal, const SurfaceMaterial &material)
{
Color final;
2013-12-08 16:56:59 +00:00
for (auto component: components)
{
final = final.add(manager->applyFinalComponent(component, eye, location, normal, material));
2013-12-08 16:56:59 +00:00
}
final.a = material.base.a;
2013-12-08 16:56:59 +00:00
return final;
}