1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-19 19:53:53 +00:00
openmw/components/sceneutil/lightutil.cpp

33 lines
948 B
C++
Raw Normal View History

2016-01-06 12:19:15 +00:00
#include "lightutil.hpp"
#include <osg/Light>
namespace SceneUtil
{
void configureLight(osg::Light *light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic,
float quadraticValue, float quadraticRadiusMult, bool useLinear, float linearRadiusMult, float linearValue)
{
bool quadratic = useQuadratic && (!outQuadInLin || isExterior);
float quadraticAttenuation = 0;
float linearAttenuation = 0;
if (quadratic)
{
float r = radius * quadraticRadiusMult;
quadraticAttenuation = quadraticValue / std::pow(r, 2);
}
if (useLinear)
{
float r = radius * linearRadiusMult;
linearAttenuation = linearValue / r;
}
light->setLinearAttenuation(linearAttenuation);
light->setQuadraticAttenuation(quadraticAttenuation);
light->setConstantAttenuation(0.f);
}
}