Changed methods slightly to ensure non-magic projectiles do not receive lights

pull/113/head
mrohrlach 8 years ago
parent 83945cf280
commit 49ce80346c

@ -138,7 +138,7 @@ namespace MWWorld
}; };
void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, std::string texture) void ProjectileManager::createModel(State &state, const std::string &model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, bool isMagic, std::string texture)
{ {
state.mNode = new osg::PositionAttitudeTransform; state.mNode = new osg::PositionAttitudeTransform;
state.mNode->setNodeMask(MWRender::Mask_Effect); state.mNode->setNodeMask(MWRender::Mask_Effect);
@ -169,21 +169,25 @@ namespace MWWorld
mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, findVisitor.mFoundNode); mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, findVisitor.mFoundNode);
} }
// Add projectile light if (isMagic)
osg::ref_ptr<osg::Light> projectileLight(new osg::Light); {
projectileLight->setDiffuse(osg::Vec4(0.95f, 0.71f, 0.25f, 1.0f)); // Add magic bolt light
projectileLight->setAmbient(osg::Vec4(0.32f, 0.08f, 0.01f, 1.0f)); osg::ref_ptr<osg::Light> projectileLight(new osg::Light);
projectileLight->setSpecular(osg::Vec4(0, 0, 0, 0)); projectileLight->setDiffuse(osg::Vec4(0.95f, 0.71f, 0.25f, 1.0f));
projectileLight->setLinearAttenuation(0.5f / 15); projectileLight->setAmbient(osg::Vec4(0.32f, 0.08f, 0.01f, 1.0f));
projectileLight->setPosition(osg::Vec4(pos, 1.0)); projectileLight->setSpecular(osg::Vec4(0, 0, 0, 0));
projectileLight->setLinearAttenuation(0.5f / 15);
// Add projectile light source projectileLight->setPosition(osg::Vec4(pos, 1.0));
SceneUtil::LightSource* projectileLightSource = new SceneUtil::LightSource;
projectileLightSource->setNodeMask(MWRender::Mask_Lighting); // Add magic bolt light source
projectileLightSource->setRadius(66.f); SceneUtil::LightSource* projectileLightSource = new SceneUtil::LightSource;
projectileLightSource->setNodeMask(MWRender::Mask_Lighting);
state.mNode->addChild(projectileLightSource); projectileLightSource->setRadius(66.f);
projectileLightSource->setLight(projectileLight);
// Attach to scene node
state.mNode->addChild(projectileLightSource);
projectileLightSource->setLight(projectileLight);
}
SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor; SceneUtil::DisableFreezeOnCullVisitor disableFreezeOnCullVisitor;
@ -248,7 +252,7 @@ namespace MWWorld
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0)); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), state.mIdMagic.at(0));
MWWorld::Ptr ptr = ref.getPtr(); MWWorld::Ptr ptr = ref.getPtr();
createModel(state, ptr.getClass().getModel(ptr), pos, orient, true, texture); createModel(state, ptr.getClass().getModel(ptr), pos, orient, true, true, texture);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
for (size_t it = 0; it != state.mSoundIds.size(); it++) for (size_t it = 0; it != state.mSoundIds.size(); it++)
@ -272,7 +276,7 @@ namespace MWWorld
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId()); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId());
MWWorld::Ptr ptr = ref.getPtr(); MWWorld::Ptr ptr = ref.getPtr();
createModel(state, ptr.getClass().getModel(ptr), pos, orient, false); createModel(state, ptr.getClass().getModel(ptr), pos, orient, false, false);
mProjectiles.push_back(state); mProjectiles.push_back(state);
} }
@ -478,9 +482,9 @@ namespace MWWorld
bool ProjectileManager::readRecord(ESM::ESMReader &reader, uint32_t type) bool ProjectileManager::readRecord(ESM::ESMReader &reader, uint32_t type)
{ {
if (type == ESM::REC_PROJ) if (type == ESM::REC_PROJ)
{ {
ESM::ProjectileState esm; ESM::ProjectileState esm;
esm.load(reader); esm.load(reader);
ProjectileState state; ProjectileState state;
@ -502,14 +506,14 @@ namespace MWWorld
return true; return true;
} }
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), false); createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), false, false);
mProjectiles.push_back(state); mProjectiles.push_back(state);
return true; return true;
} }
else if (type == ESM::REC_MPRJ) else if (type == ESM::REC_MPRJ)
{ {
ESM::MagicBoltState esm; ESM::MagicBoltState esm;
esm.load(reader); esm.load(reader);
MagicBoltState state; MagicBoltState state;
@ -537,7 +541,7 @@ namespace MWWorld
return true; return true;
} }
createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), true, texture); createModel(state, model, osg::Vec3f(esm.mPosition), osg::Quat(esm.mOrientation), true, true, texture);
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();

@ -122,7 +122,7 @@ namespace MWWorld
void moveProjectiles(float dt); void moveProjectiles(float dt);
void moveMagicBolts(float dt); void moveMagicBolts(float dt);
void createModel (State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, std::string texture = ""); void createModel (State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient, bool rotate, bool isMagic, std::string texture = "");
void update (State& state, float duration); void update (State& state, float duration);
void operator=(const ProjectileManager&); void operator=(const ProjectileManager&);

Loading…
Cancel
Save