Adds the light into the scene.

Common struct for ESM3 and ESM4 light
This commit is contained in:
florent.teppe 2023-02-06 23:38:35 +01:00
parent a71a86e64a
commit dc961e3189
11 changed files with 77 additions and 20 deletions

View file

@ -5,6 +5,7 @@
#include <osgParticle/ParticleSystem>
#include <components/esm/esmbridge.hpp>
#include <components/esm3/loadligh.hpp>
#include <components/fallback/fallback.hpp>
@ -86,7 +87,7 @@ namespace SceneUtil
}
osg::ref_ptr<LightSource> addLight(
osg::Group* node, const ESM::Light* esmLight, unsigned int lightMask, bool isExterior)
osg::Group* node, const ESM::LightCommon& esmLight, unsigned int lightMask, bool isExterior)
{
SceneUtil::FindByNameVisitor visitor("AttachLight");
node->accept(visitor);
@ -105,19 +106,19 @@ namespace SceneUtil
}
osg::ref_ptr<LightSource> createLightSource(
const ESM::Light* esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient)
const ESM::LightCommon& esmLight, unsigned int lightMask, bool isExterior, const osg::Vec4f& ambient)
{
osg::ref_ptr<SceneUtil::LightSource> lightSource(new SceneUtil::LightSource);
osg::ref_ptr<osg::Light> light(new osg::Light);
lightSource->setNodeMask(lightMask);
float radius = esmLight->mData.mRadius;
float radius = esmLight.mRadius;
lightSource->setRadius(radius);
configureLight(light, radius, isExterior);
osg::Vec4f diffuse = SceneUtil::colourFromRGB(esmLight->mData.mColor);
if (esmLight->mData.mFlags & ESM::Light::Negative)
osg::Vec4f diffuse = esmLight.mColor;
if (esmLight.mNegative)
{
diffuse *= -1;
diffuse.a() = 1;
@ -130,13 +131,13 @@ namespace SceneUtil
osg::ref_ptr<SceneUtil::LightController> ctrl(new SceneUtil::LightController);
ctrl->setDiffuse(light->getDiffuse());
if (esmLight->mData.mFlags & ESM::Light::Flicker)
if (esmLight.mFlicker)
ctrl->setType(SceneUtil::LightController::LT_Flicker);
if (esmLight->mData.mFlags & ESM::Light::FlickerSlow)
if (esmLight.mFlickerSlow)
ctrl->setType(SceneUtil::LightController::LT_FlickerSlow);
if (esmLight->mData.mFlags & ESM::Light::Pulse)
if (esmLight.mPulse)
ctrl->setType(SceneUtil::LightController::LT_Pulse);
if (esmLight->mData.mFlags & ESM::Light::PulseSlow)
if (esmLight.mPulseSlow)
ctrl->setType(SceneUtil::LightController::LT_PulseSlow);
lightSource->addUpdateCallback(ctrl);