mirror of https://github.com/OpenMW/openmw.git
Move configureLight to a separate file
parent
fb849014bd
commit
438b30d6f0
@ -0,0 +1,32 @@
|
||||
#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);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#ifndef OPENMW_COMPONENTS_LIGHTUTIL_H
|
||||
#define OPENMW_COMPONENTS_LIGHTUTIL_H
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Light;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
|
||||
/// @brief Configures a light's attenuation according to vanilla Morrowind attenuation settings.
|
||||
void configureLight(osg::Light* light, float radius, bool isExterior, bool outQuadInLin, bool useQuadratic,
|
||||
float quadraticValue, float quadraticRadiusMult, bool useLinear, float linearRadiusMult,
|
||||
float linearValue);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue