29 namespace SkyX {
namespace VClouds
35 , mSceneNodes(std::vector<
Ogre::SceneNode*>())
37 , mLightningColor(
Ogre::Vector3(1,0.925f,0.85f))
38 , mLightningTimeMultiplier(2.0f)
39 , mAverageLightningApparitionTime(1.5f)
40 , mRemainingTime(1.5f)
41 , mVolCloudsLightningMaterial(
Ogre::MaterialPtr())
42 , mLightningMaterial(
Ogre::MaterialPtr())
43 , mListeners(std::vector<
Listener*>())
57 mVolCloudsLightningMaterial =
static_cast<Ogre::MaterialPtr
>(Ogre::MaterialManager::getSingleton().getByName(
"SkyX_VolClouds_Lightning"));
58 mLightningMaterial =
static_cast<Ogre::MaterialPtr
>(Ogre::MaterialManager::getSingleton().getByName(
"SkyX_Lightning"));
62 SkyXLOG(
"Error while creating SkyX::VClouds::LightningManager, material not found");
87 for(Ogre::uint32 k = 0; k <
mLightnings.size(); k++)
125 Ogre::Real prob = Ogre::Math::RangeRandom(0,1);
132 Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5),
mVClouds->
getGeometrySettings().
Height.x + 0.2*
mVClouds->
getGeometrySettings().
Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)),
134 Ogre::Vector3(0,-1,0),
143 Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5),
mVClouds->
getGeometrySettings().
Height.x + 0.2*
mVClouds->
getGeometrySettings().
Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)),
145 Ogre::Vector3(Ogre::Math::RangeRandom(-1,1),Ogre::Math::RangeRandom(-0.1,0.1),Ogre::Math::RangeRandom(-1,1)).normalisedCopy(),
154 Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5),
mVClouds->
getGeometrySettings().
Height.x + 0.2*
mVClouds->
getGeometrySettings().
Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)),
156 Ogre::Vector3(0,-1,0),
162 Ogre::Vector3(c->getDerivedPosition().x + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5),
mVClouds->
getGeometrySettings().
Height.x + 0.2*
mVClouds->
getGeometrySettings().
Height.y, c->getDerivedPosition().z + Ogre::Math::RangeRandom(-c->getFarClipDistance()*0.5,c->getFarClipDistance()*0.5)/Ogre::Math::RangeRandom(1,5)),
164 Ogre::Vector3(Ogre::Math::RangeRandom(-1,1),Ogre::Math::RangeRandom(-0.1,0.1),Ogre::Math::RangeRandom(-1,1)).normalisedCopy(),
176 if ((*it)->isFinished())
178 Ogre::SceneNode* sn = (*it)->getSceneNode();
188 sn->getParentSceneNode()->removeAndDestroyChild(sn);
196 (*it)->update(timeSinceLastFrame);
212 Lightning* lightning =
new Lightning(
mVClouds->
getSceneManager(), sn, Ogre::Vector3(0,0,0), d, l, div, 3,
mLightningTimeMultiplier,
mVClouds->
getGeometrySettings().
Radius/9500);
222 for(Ogre::uint32 k = 0; k <
mListeners.size(); k++)
234 for(Ogre::uint32 k = 0; k < 3; k++)
241 getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uLightning" + Ogre::StringConverter::toString(k),
242 Ogre::Vector4(pos.x, pos.y, pos.z,
mLightnings.at(k)->getIntensity()));
247 getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant(
"uLightning" + Ogre::StringConverter::toString(k),
248 Ogre::Vector4(0,0,0,0));
273 if ((*it) == listener)
300 for(Ogre::uint32 k = 0; k <
mLightnings.size(); k++)
308 for(Ogre::uint32 k = 0; k <
mLightnings.size(); k++)
310 mLightnings.at(k)->getBillboardSet()->setVisible(v);