26 namespace SkyX {
namespace VClouds
28 Lightning::Lightning(Ogre::SceneManager* sm, Ogre::SceneNode* sn,
const Ogre::Vector3& orig,
const Ogre::Vector3& dir,
29 const Ogre::Real& l,
const Ogre::uint32& d,
const Ogre::uint32& rec,
const Ogre::Real& tm,
const Ogre::Real& wm,
const Ogre::Vector2& b)
39 , mWidthMultiplier(wm)
41 , mAngleRange(
Ogre::Vector2(
Ogre::Math::RangeRandom(0.3,0.5),
Ogre::Math::RangeRandom(0.6,0.8)))
42 , mTimeMultipliers(
Ogre::Vector3(
Ogre::Math::RangeRandom(1.75,4.25),
Ogre::Math::RangeRandom(0.4,1.25f),
Ogre::Math::RangeRandom(0.2,1.0f)))
62 Ogre::Vector3 current, last =
mOrigin;
70 Ogre::Math::RangeRandom(-1, 1), Ogre::Math::RangeRandom(-1, 1), Ogre::Math::RangeRandom(-1, 1));
90 for(Ogre::uint32 k = 0; k <
mSegments.size(); k++)
93 bounds = Ogre::Vector2(k*delta,(k+1)*delta);
99 bb->setColour(Ogre::ColourValue(0,bounds.x,bounds.y));
103 bb->setDimensions(width, width);
104 bb->setColour(Ogre::ColourValue(1,bounds.x,bounds.x));
108 bb->setDimensions(width, width);
109 bb->setColour(Ogre::ColourValue(1,bounds.y,bounds.y));
119 mBillboardSet->setCustomParameter(0, Ogre::Vector4(1,0,0,0));
126 Ogre::Real lengthMult;
127 for (Ogre::uint32 k = 0; k <
mDivisions-1; k++)
135 dir.x *= Ogre::Math::RangeRandom(0.8f, 1.2f);
136 dir.y *= Ogre::Math::RangeRandom(0.8f, 1.2f);
137 dir.z *= Ogre::Math::RangeRandom(0.8f, 1.2f);
143 lengthMult = Ogre::Math::RangeRandom(0.1f, 0.7f);
168 for(Ogre::uint32 k = 0; k <
mChildren.size(); k++)
194 Ogre::Real alpha = 0.5f;
195 Ogre::Real maxAlpha = 1.5f;
205 alpha += (
mTime-0.8f)*(maxAlpha/0.2f);
216 alpha += (0.2f-(
mTime-1.0f))*(maxAlpha/0.2f);
233 alpha += Ogre::Math::Abs(Ogre::Math::Sin((2-1.2f)*1.5f*
mTimeMultipliers.x));
246 for(Ogre::uint32 k = 0; k <
mChildren.size(); k++)
248 mChildren.at(k)->_updateRenderQueueGroup(rqg);
254 Ogre::Vector4 params = Ogre::Vector4(alpha,currentPos,(3-
mRecursivity)*0.075f+(
mBounds.x*1.5f+0.2f)*0.85f,0);
256 if (parentTime > 1 && parentTime < 2.2f)
258 params.z *= Ogre::Math::Clamp<Ogre::Real>(1.5-parentTime,0.2f,1);
260 else if (parentTime > 2.2f)
262 params.z *= Ogre::Math::Clamp<Ogre::Real>((-2.2f+parentTime)*1.25f,0.2f,1);
267 for(Ogre::uint32 k = 0; k <
mChildren.size(); k++)
269 mChildren.at(k)->_updateData(alpha*0.75f, currentPos, parentTime);