mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 18:45:38 +00:00
Merge branch 'load_esm4_lights' into 'master'
Adds ESM4 light into ESM4 Cells See merge request OpenMW/openmw!2692
This commit is contained in:
commit
944931c9bf
24 changed files with 237 additions and 25 deletions
|
@ -44,8 +44,10 @@
|
|||
#include "../../model/world/data.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/esmbridge.hpp>
|
||||
#include <components/resource/resourcesystem.hpp>
|
||||
#include <components/resource/scenemanager.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
#include <components/sceneutil/lightutil.hpp>
|
||||
|
||||
|
@ -167,7 +169,7 @@ void CSVRender::Object::update()
|
|||
if (light)
|
||||
{
|
||||
bool isExterior = false; // FIXME
|
||||
SceneUtil::addLight(mBaseNode, light, Mask_Lighting, isExterior);
|
||||
SceneUtil::addLight(mBaseNode, SceneUtil::LightCommon(*light), Mask_Lighting, isExterior);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ add_openmw_dir (mwphysics
|
|||
add_openmw_dir (mwclass
|
||||
classes activator creature npc weapon armor potion apparatus book clothing container door
|
||||
ingredient creaturelevlist itemlevlist light lockpick misc probe repair static actor bodypart
|
||||
light4
|
||||
)
|
||||
|
||||
add_openmw_dir (mwmechanics
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "ingredient.hpp"
|
||||
#include "itemlevlist.hpp"
|
||||
#include "light.hpp"
|
||||
#include "light4.hpp"
|
||||
#include "lockpick.hpp"
|
||||
#include "misc.hpp"
|
||||
#include "npc.hpp"
|
||||
|
@ -49,5 +50,6 @@ namespace MWClass
|
|||
BodyPart::registerSelf();
|
||||
|
||||
ESM4Static::registerSelf();
|
||||
ESM4Light::registerSelf();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/objectstate.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -242,4 +243,5 @@ namespace MWClass
|
|||
{
|
||||
return ptr.get<ESM::Light>()->mBase->mSound;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ namespace MWClass
|
|||
|
||||
const ESM::RefId& getSound(const MWWorld::ConstPtr& ptr) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
61
apps/openmw/mwclass/light4.cpp
Normal file
61
apps/openmw/mwclass/light4.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#include "light4.hpp"
|
||||
#include "classmodel.hpp"
|
||||
|
||||
#include "../mwphysics/physicssystem.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
ESM4Light::ESM4Light()
|
||||
: MWWorld::RegisteredClass<ESM4Light>(ESM4::Light::sRecordId)
|
||||
{
|
||||
}
|
||||
|
||||
void ESM4Light ::insertObjectRendering(
|
||||
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM4::Light>* ref = ptr.get<ESM4::Light>();
|
||||
|
||||
// Insert even if model is empty, so that the light is added
|
||||
renderingInterface.getObjects().insertModel(ptr, model, !(ref->mBase->mData.flags & ESM4::Light::OffDefault));
|
||||
}
|
||||
|
||||
void ESM4Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
insertObjectPhysics(ptr, model, rotation, physics);
|
||||
}
|
||||
|
||||
void ESM4Light::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
std::string ESM4Light::getModel(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return getClassModel<ESM4::Light>(ptr);
|
||||
}
|
||||
|
||||
std::string_view ESM4Light ::getName(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ESM4Light::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MWWorld::Ptr ESM4Light::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM4::Light>* ref = ptr.get<ESM4::Light>();
|
||||
|
||||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
}
|
34
apps/openmw/mwclass/light4.hpp
Normal file
34
apps/openmw/mwclass/light4.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef OPENW_MWCLASS_LIGHT4
|
||||
#define OPENW_MWCLASS_LIGHT4
|
||||
#include "../mwworld/registeredclass.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class ESM4Light : public MWWorld::RegisteredClass<ESM4Light>
|
||||
{
|
||||
friend MWWorld::RegisteredClass<ESM4Light>;
|
||||
|
||||
ESM4Light();
|
||||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const override;
|
||||
|
||||
public:
|
||||
void insertObjectRendering(const MWWorld::Ptr& ptr, const std::string& model,
|
||||
MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||
|
||||
std::string getModel(const MWWorld::ConstPtr& ptr) const override;
|
||||
};
|
||||
}
|
||||
#endif
|
|
@ -13,6 +13,7 @@
|
|||
#include <components/resource/scenemanager.hpp>
|
||||
|
||||
#include <components/sceneutil/attach.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
#include <components/sceneutil/lightutil.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
|
@ -557,7 +558,7 @@ namespace MWRender
|
|||
|
||||
osg::Vec4f ambient(1, 1, 1, 1);
|
||||
osg::ref_ptr<SceneUtil::LightSource> lightSource
|
||||
= SceneUtil::createLightSource(esmLight, Mask_Lighting, exterior, ambient);
|
||||
= SceneUtil::createLightSource(SceneUtil::LightCommon(*esmLight), Mask_Lighting, exterior, ambient);
|
||||
|
||||
mInsert->addChild(lightSource);
|
||||
|
||||
|
|
|
@ -23,9 +23,11 @@
|
|||
#include <components/esm3/loadmgef.hpp>
|
||||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/loadrace.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
#include <components/misc/pathhelpers.hpp>
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
|
||||
#include <components/sceneutil/keyframe.hpp>
|
||||
|
||||
|
@ -1510,7 +1512,7 @@ namespace MWRender
|
|||
}
|
||||
}
|
||||
|
||||
void Animation::addExtraLight(osg::ref_ptr<osg::Group> parent, const ESM::Light* esmLight)
|
||||
void Animation::addExtraLight(osg::ref_ptr<osg::Group> parent, const SceneUtil::LightCommon& esmLight)
|
||||
{
|
||||
bool exterior = mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior();
|
||||
|
||||
|
@ -1854,7 +1856,9 @@ namespace MWRender
|
|||
mObjectRoot, mResourceSystem, ptr.getClass().getEnchantmentColor(ptr));
|
||||
}
|
||||
if (ptr.getType() == ESM::Light::sRecordId && allowLight)
|
||||
addExtraLight(getOrCreateObjectRoot(), ptr.get<ESM::Light>()->mBase);
|
||||
addExtraLight(getOrCreateObjectRoot(), SceneUtil::LightCommon(*ptr.get<ESM::Light>()->mBase));
|
||||
if (ptr.getType() == ESM4::Light::sRecordId && allowLight)
|
||||
addExtraLight(getOrCreateObjectRoot(), SceneUtil::LightCommon(*ptr.get<ESM4::Light>()->mBase));
|
||||
|
||||
if (!allowLight && mObjectRoot)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace SceneUtil
|
|||
class LightSource;
|
||||
class LightListCallback;
|
||||
class Skeleton;
|
||||
struct LightCommon;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
|
@ -333,7 +334,7 @@ namespace MWRender
|
|||
void addSingleAnimSource(const std::string& model, const std::string& baseModel);
|
||||
|
||||
/** Adds an additional light to the given node using the specified ESM record. */
|
||||
void addExtraLight(osg::ref_ptr<osg::Group> parent, const ESM::Light* light);
|
||||
void addExtraLight(osg::ref_ptr<osg::Group> parent, const SceneUtil::LightCommon& light);
|
||||
|
||||
void clearAnimSources();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <components/sceneutil/actorutil.hpp>
|
||||
#include <components/sceneutil/depth.hpp>
|
||||
#include <components/sceneutil/keyframe.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
#include <components/sceneutil/visitor.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
|
@ -664,7 +665,7 @@ namespace MWRender
|
|||
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
|
||||
Misc::ResourceHelpers::correctMeshPath(light->mModel, vfs), false, nullptr, true);
|
||||
if (mObjectParts[ESM::PRT_Shield])
|
||||
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light);
|
||||
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), SceneUtil::LightCommon(*light));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1042,8 @@ namespace MWRender
|
|||
if (mesh.empty())
|
||||
reserveIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1);
|
||||
if (iter->getType() == ESM::Light::sRecordId && mObjectParts[ESM::PRT_Shield])
|
||||
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), iter->get<ESM::Light>()->mBase);
|
||||
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(),
|
||||
SceneUtil::LightCommon(*iter->get<ESM::Light>()->mBase));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <components/esm3/npcstate.hpp>
|
||||
#include <components/esm3/objectstate.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/misc/tuplehelpers.hpp>
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace ESM4
|
|||
struct Cell;
|
||||
struct Reference;
|
||||
struct Static;
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -73,7 +74,7 @@ namespace MWWorld
|
|||
CellRefList<ESM::Lockpick>, CellRefList<ESM::Miscellaneous>, CellRefList<ESM::NPC>, CellRefList<ESM::Probe>,
|
||||
CellRefList<ESM::Repair>, CellRefList<ESM::Static>, CellRefList<ESM::Weapon>, CellRefList<ESM::BodyPart>,
|
||||
|
||||
CellRefList<ESM4::Static>>;
|
||||
CellRefList<ESM4::Static>, CellRefList<ESM4::Light>>;
|
||||
|
||||
/// \brief Mutable state of a cell
|
||||
class CellStore
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <components/esm4/common.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/esm4/reader.hpp>
|
||||
|
@ -279,6 +280,7 @@ namespace MWWorld
|
|||
case ESM::REC_WEAP:
|
||||
case ESM::REC_BODY:
|
||||
case ESM::REC_STAT4:
|
||||
case ESM::REC_LIGH4:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace ESM4
|
|||
struct Static;
|
||||
struct Cell;
|
||||
struct Reference;
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
|
@ -105,7 +106,7 @@ namespace MWWorld
|
|||
// Special entry which is hardcoded and not loaded from an ESM
|
||||
Store<ESM::Attribute>,
|
||||
|
||||
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Reference>>;
|
||||
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Reference>, Store<ESM4::Light>>;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
@ -1250,5 +1251,6 @@ template class MWWorld::TypedDynamicStore<ESM::Static>;
|
|||
template class MWWorld::TypedDynamicStore<ESM::Weapon>;
|
||||
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Static>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Light>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Reference>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Cell>;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <components/esm3/esmwriter.hpp>
|
||||
#include <components/esm4/common.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/esm4/reader.hpp>
|
||||
|
|
|
@ -66,7 +66,7 @@ add_component_dir (sceneutil
|
|||
clone attach visitor util statesetupdater controller skeleton riggeometry morphgeometry lightcontroller
|
||||
lightmanager lightutil positionattitudetransform workqueue pathgridutil waterutil writescene serialize optimizer
|
||||
actorutil detourdebugdraw navmesh agentpath shadow mwshadowtechnique recastmesh shadowsbin osgacontroller rtt
|
||||
screencapture depth color riggeometryosgaextension extradata unrefqueue
|
||||
screencapture depth color riggeometryosgaextension extradata unrefqueue lightcommon
|
||||
)
|
||||
|
||||
add_component_dir (nif
|
||||
|
|
|
@ -33,8 +33,9 @@
|
|||
|
||||
void ESM4::Light::load(ESM4::Reader& reader)
|
||||
{
|
||||
mFormId = reader.hdr().record.id;
|
||||
reader.adjustFormId(mFormId);
|
||||
FormId formId = reader.hdr().record.id;
|
||||
reader.adjustFormId(formId);
|
||||
mId = ESM::RefId::formIdRefId(formId);
|
||||
mFlags = reader.hdr().record.flags;
|
||||
std::uint32_t esmVer = reader.esmVersion();
|
||||
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
#include "formid.hpp"
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
class Reader;
|
||||
|
@ -39,6 +42,20 @@ namespace ESM4
|
|||
|
||||
struct Light
|
||||
{
|
||||
enum Flag
|
||||
{
|
||||
Dynamic = 0x01,
|
||||
Carryable = 0x02,
|
||||
Negative = 0x04,
|
||||
Flicker = 0x08,
|
||||
OffDefault = 0x020,
|
||||
FlickerSlow = 0x040,
|
||||
Pulse = 0x080,
|
||||
PulseSlow = 0x100,
|
||||
SpotLight = 0x200,
|
||||
SpotShadow = 0x400,
|
||||
};
|
||||
|
||||
struct Data
|
||||
{
|
||||
std::uint32_t time; // FO/FONV only
|
||||
|
@ -67,7 +84,7 @@ namespace ESM4
|
|||
float weight;
|
||||
};
|
||||
|
||||
FormId mFormId; // from the header
|
||||
ESM::RefId mId; // from the header
|
||||
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
|
||||
|
||||
std::string mEditorId;
|
||||
|
@ -87,6 +104,8 @@ namespace ESM4
|
|||
void load(ESM4::Reader& reader);
|
||||
// void save(ESM4::Writer& writer) const;
|
||||
|
||||
static constexpr ESM::RecNameInts sRecordId = ESM::REC_LIGH4;
|
||||
|
||||
// void blank();
|
||||
};
|
||||
}
|
||||
|
|
33
components/sceneutil/lightcommon.cpp
Normal file
33
components/sceneutil/lightcommon.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
#include "lightcommon.hpp"
|
||||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/sceneutil/util.hpp>
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
LightCommon::LightCommon(const ESM::Light& light)
|
||||
: mFlicker(light.mData.mFlags & ESM::Light::Flicker)
|
||||
, mFlickerSlow(light.mData.mFlags & ESM::Light::FlickerSlow)
|
||||
, mNegative(light.mData.mFlags & ESM::Light::Negative)
|
||||
, mPulse(light.mData.mFlags & ESM::Light::Pulse)
|
||||
, mPulseSlow(light.mData.mFlags & ESM::Light::PulseSlow)
|
||||
, mOffDefault(light.mData.mFlags & ESM::Light::OffDefault)
|
||||
, mColor(SceneUtil::colourFromRGB(light.mData.mColor))
|
||||
, mRadius(light.mData.mRadius)
|
||||
|
||||
{
|
||||
}
|
||||
LightCommon::LightCommon(const ESM4::Light& light)
|
||||
: mFlicker(light.mData.flags & ESM4::Light::Flicker)
|
||||
, mFlickerSlow(light.mData.flags & ESM4::Light::FlickerSlow)
|
||||
, mNegative(light.mData.flags & ESM::Light::Negative)
|
||||
, mPulse(light.mData.flags & ESM4::Light::Pulse)
|
||||
, mPulseSlow(light.mData.flags & ESM4::Light::PulseSlow)
|
||||
, mOffDefault(light.mData.flags & ESM4::Light::OffDefault)
|
||||
, mColor(SceneUtil::colourFromRGB(light.mData.colour))
|
||||
, mRadius(light.mData.radius)
|
||||
|
||||
{
|
||||
}
|
||||
}
|
38
components/sceneutil/lightcommon.hpp
Normal file
38
components/sceneutil/lightcommon.hpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
|
||||
#ifndef COMPONENTS_SCENEUTIL_LIGHTCOMMON
|
||||
#define COMPONENTS_SCENEUTIL_LIGHTCOMMON
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
#include <osg/Vec4>
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
struct LightCommon
|
||||
{
|
||||
explicit LightCommon(const ESM::Light& light);
|
||||
explicit LightCommon(const ESM4::Light& light);
|
||||
|
||||
bool mFlicker;
|
||||
bool mFlickerSlow;
|
||||
bool mNegative;
|
||||
bool mPulse;
|
||||
bool mPulseSlow;
|
||||
bool mOffDefault;
|
||||
|
||||
osg::Vec4 mColor;
|
||||
float mRadius;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
#include <components/sceneutil/lightcommon.hpp>
|
||||
|
||||
#include "lightcontroller.hpp"
|
||||
#include "lightmanager.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 SceneUtil::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 SceneUtil::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);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace ESM
|
|||
namespace SceneUtil
|
||||
{
|
||||
class LightSource;
|
||||
struct LightCommon;
|
||||
|
||||
/// @brief Set up global attenuation settings for an osg::Light.
|
||||
/// @param radius The radius of the light source.
|
||||
|
@ -32,15 +33,15 @@ namespace SceneUtil
|
|||
/// @param lightMask Mask to assign to the newly created LightSource.
|
||||
/// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use.
|
||||
osg::ref_ptr<LightSource> addLight(
|
||||
osg::Group* node, const ESM::Light* esmLight, unsigned int lightMask, bool isExterior);
|
||||
osg::Group* node, const SceneUtil::LightCommon& esmLight, unsigned int lightMask, bool isExterior);
|
||||
|
||||
/// @brief Convert an ESM::Light to a SceneUtil::LightSource, and return it.
|
||||
/// @param esmLight The light definition coming from the game files containing radius, color, flicker, etc.
|
||||
/// @param lightMask Mask to assign to the newly created LightSource.
|
||||
/// @param isExterior Is the light outside? May be used for deciding which attenuation settings to use.
|
||||
/// @param ambient Ambient component of the light.
|
||||
osg::ref_ptr<LightSource> createLightSource(const ESM::Light* esmLight, unsigned int lightMask, bool isExterior,
|
||||
const osg::Vec4f& ambient = osg::Vec4f(0, 0, 0, 1));
|
||||
osg::ref_ptr<LightSource> createLightSource(const SceneUtil::LightCommon& esmLight, unsigned int lightMask,
|
||||
bool isExterior, const osg::Vec4f& ambient = osg::Vec4f(0, 0, 0, 1));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue