15 SLight::SLight(
SScene* parent,
const std::string& lightName) :
SNode(parent, lightName,
SNode::LIGHT_TYPE_ID)
17 mShadowFarDistance = 0;
31 SLight::SLight() :
SNode(0,
"",
SNode::LIGHT_TYPE_ID)
38 SAFE_DELETE(mLightShaft);
50 void SLight::UpdateVolumetric(
bool force)
52 float nrange = mRange;
53 Ogre::Radian fov = Ogre::Degree(120.0f);
57 fov = Ogre::Degree(160.0f);
61 fov = Ogre::Degree(120.0f);
67 fov = O3Light->getSpotlightOuterAngle();
72 if (force && mVolumetric && O3Light->isVisible())
74 SAFE_DELETE(mLightShaft);
75 mLightShaft =
new SLightShaft(
this, 0.0001f, nrange * 0.01f, nrange, fov);
79 if (mVolumetric && O3Light->isVisible() && !mLightShaft)
80 mLightShaft =
new SLightShaft(
this, 0.0001f, nrange * 0.01f, nrange, fov);
81 else if ((!O3Light->isVisible() || !mVolumetric) && mLightShaft)
82 SAFE_DELETE(mLightShaft);
87 mLightShaft->
SetColor(O3Light->getDiffuseColour() * O3Light->getPowerScale());
90 mLightShaft->
SetAttenuation(Ogre::Vector4(mRange, 0.1, 4.5f / mRange, 7.5f / (mRange*mRange)));
107 O3Light->setDiffuseColour(color);
113 O3Light->setSpecularColour(color);
139 float power = std::max(0.01f, powerScale);
140 O3Light->setPowerScale(power);
146 return static_cast <float> (O3Light->getPowerScale());
151 O3Light->setVisible(isVisible);
158 SAFE_DELETE(mLightShaft);
169 return O3Light->isVisible();
174 mRange = std::max(0.01f, range);
175 if (O3Light->getType() == Ogre::Light::LT_DIRECTIONAL)
176 O3Light->setAttenuation(100000.0f, constant, 0.0f, 0.0f);
178 O3Light->setAttenuation(range, constant, linear, quadratic);
189 return Ogre::Vector4(O3Light->getAttenuationRange(),
190 O3Light->getAttenuationConstant(),
191 O3Light->getAttenuationLinear(),
192 O3Light->getAttenuationQuadric());
197 O3Light->setShadowFarDistance(distance);
198 mShadowFarDistance = distance;
203 if (mShadowFarDistance == 0)
204 O3Light->setShadowFarDistance(distance);
209 O3Light->setShadowNearClipDistance(0.1f);
210 O3Light->setShadowFarClipDistance(distance);
215 return O3Light->getShadowFarDistance();
220 O3Light->setType(
static_cast <Ogre::Light::LightTypes
> (type));
222 UpdateVolumetric(
true);
232 O3Light->setSpotlightInnerAngle(Ogre::Radian(radianAngle));
237 return static_cast <float> (O3Light->getSpotlightInnerAngle().valueRadians());
242 O3Light->setSpotlightOuterAngle(Ogre::Radian(radianAngle));
248 return static_cast <float> (O3Light->getSpotlightOuterAngle().valueRadians());
253 O3Light->setSpotlightFalloff(value);
258 return O3Light->getSpotlightFalloff();
263 O3Light->setSourceSize(x, y);
269 return O3Light->getSourceSize();
274 O3Light->setCastShadows(castShadows);
283 return O3Light->getCastShadows();
288 return O3Light->setRenderingDistance(distance);
293 return O3Light->getRenderingDistance();
301 return O3Light->getBoundingBox().getSize();
306 return O3Light->getBoundingBox().getCenter();
314 return O3Light->getWorldBoundingBox(
true).getSize();
319 return O3Light->getWorldBoundingBox(
true).getCenter();
virtual void SetRenderingDistance(const float &distance)
void SetAttenuation(const float &range, const float &constant, const float &linear, const float &quadratic)
virtual float GetRenderingDistance()
void SetSpotlightInnerAngle(const float &radianAngle)
virtual bool GetCastShadows()
Ogre::Vector2f GetSourceSize()
virtual void SetCastShadows(const bool &castShadows)
void SetDiffuseColour(const int &diffuseColor)
Ogre::Light * GetOgreLightPointer()
void SetPowerScale(const float &powerScale)
float GetSpotlightInnerAngle()
Ogre::Vector4 GetAttenuation()
void SetSpotlightOuterAngle(const float &radianAngle)
void SetShadowFarDistance(const float &distance)
virtual Ogre::Vector3 GetBoundingBoxCenter(const bool &childs=false)
virtual Ogre::Vector3 GetWorldBoundingBoxSize(const bool &childs=false)
void SetSpotlightFalloff(const float &value)
void SetVisible(const bool &isVisible)
void SetType(const LightType &type)
void SetSourceSize(float x, float y)
void UpdateShadowFarDistance(const float &distance)
float GetSpotlightOuterAngle()
void SetSpecularColour(const int &specularColor)
void SetVolumetric(bool state)
virtual Ogre::Vector3 GetBoundingBoxSize(const bool &childs=false)
float GetSpotlightFalloff()
float GetShadowFarDistance()
void UpdateShadowFarClipDistance(const float &distance)
virtual Ogre::Vector3 GetWorldBoundingBoxCenter(const bool &childs=false)
void SetLightClipping(float nearClip, float farClip)
void SetColor(Ogre::ColourValue col)
void SetAttenuation(Ogre::Vector4 attenuation)
void SetLightFov(Ogre::Radian fov)
Ogre::Vector3 GetSonsWorldBoundingBox()
Ogre::SceneNode * O3SceneNode
Ogre::MovableObject * ogreMovableObject
Ogre::Vector3 GetSonsBoundingBox()
Ogre::SceneManager * O3SceneManager
void SetShadowType(const SShadowManager::ShadowType &shadowType)
SShadowManager::ShadowType GetShadowType()
Ogre::SceneManager * GetOgreScenePointer()