You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
948 B
C++
33 lines
948 B
C++
9 years ago
|
#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);
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|