00001
00008 #include "SO3Light.h"
00009 #include "SO3Scene.h"
00010 #include "../SO3Utils/SO3ConversionTools.h"
00011
00012 namespace SO3
00013 {
00014
00015 SLight::SLight(SScene* parent, std::string lightName) : SNode(parent, lightName, SNode::LIGHT_TYPE_ID)
00016 {
00017 O3Light = currentScene->GetOgreScenePointer()->createLight(lightName);
00018 ogreMovableObject = O3Light;
00019 O3SceneNode->attachObject(O3Light);
00020
00021
00022
00023
00024 }
00025
00026 SLight::SLight() : SNode(0, "", SNode::LIGHT_TYPE_ID)
00027 {
00028
00029 }
00030
00031 SLight::~SLight()
00032 {
00033 O3SceneNode->detachObject(O3Light);
00034 currentScene->GetOgreScenePointer()->destroyLight(O3Light);
00035 O3Light = 0;
00036 ogreMovableObject = 0;
00037 }
00038
00039 Ogre::Light* SLight::GetOgreLightPointer()
00040 {
00041 return O3Light;
00042 }
00043
00044 void SLight::SetDiffuseColour(int diffuseColor)
00045 {
00046 O3Light->setDiffuseColour(ConversionTools::ScolToOgreColorRGBA(diffuseColor));
00047 }
00048
00049 int SLight::GetDiffuseColour()
00050 {
00051 return ConversionTools::OgreToScolColorRGBA(O3Light->getDiffuseColour());
00052 }
00053
00054 void SLight::SetSpecularColour(int specularColor)
00055 {
00056 O3Light->setSpecularColour(ConversionTools::ScolToOgreColorRGBA(specularColor));
00057 }
00058
00059 int SLight::GetSpecularColour()
00060 {
00061 return ConversionTools::OgreToScolColorRGBA(O3Light->getSpecularColour());
00062 }
00063
00064 void SLight::SetPowerScale(float powerScale)
00065 {
00066 O3Light->setPowerScale(powerScale);
00067 }
00068
00069 float SLight::GetPowerScale()
00070 {
00071 return static_cast <float> (O3Light->getPowerScale());
00072 }
00073
00074 void SLight::SetVisible(bool isVisible)
00075 {
00076 O3Light->setVisible(isVisible);
00077 }
00078
00079 bool SLight::GetVisible()
00080 {
00081 return O3Light->isVisible();
00082 }
00083
00084 void SLight::SetAttenuation(float range, float constant, float linear, float quadratic)
00085 {
00086 O3Light->setAttenuation(range, constant, linear, quadratic);
00087 }
00088
00089 void SLight::SetAttenuation(float range)
00090 {
00091 O3Light->setAttenuation(range, 1.0f, 4.5f/range, 75.0f/(range*range));
00092 }
00093
00094 Ogre::Vector4 SLight::GetAttenuation()
00095 {
00096 return Ogre::Vector4(O3Light->getAttenuationRange(),
00097 O3Light->getAttenuationConstant(),
00098 O3Light->getAttenuationLinear(),
00099 O3Light->getAttenuationQuadric());
00100 }
00101
00102 void SLight::SetShadowFarDistance(float distance)
00103 {
00104 O3Light->setShadowFarDistance(distance);
00105 }
00106
00107 float SLight::GetShadowFarDistance()
00108 {
00109 return O3Light->getShadowFarDistance();
00110 }
00111
00112 void SLight::SetType(LightType type)
00113 {
00114 O3Light->setType(static_cast <Ogre::Light::LightTypes> (type));
00115 }
00116
00117 SLight::LightType SLight::GetType()
00118 {
00119 return static_cast <SLight::LightType> (O3Light->getType());
00120 }
00121
00122 void SLight::SetSpotlightInnerAngle(float radianAngle)
00123 {
00124 O3Light->setSpotlightInnerAngle(Ogre::Radian(radianAngle));
00125 }
00126
00127 float SLight::GetSpotlightInnerAngle()
00128 {
00129 return static_cast <float> (O3Light->getSpotlightInnerAngle().valueRadians());
00130 }
00131
00132 void SLight::SetSpotlightOuterAngle(float radianAngle)
00133 {
00134 O3Light->setSpotlightOuterAngle(Ogre::Radian(radianAngle));
00135 }
00136
00137 float SLight::GetSpotlightOuterAngle()
00138 {
00139 return static_cast <float> (O3Light->getSpotlightOuterAngle().valueRadians());
00140 }
00141
00142 void SLight::SetSpotlightFalloff(float value)
00143 {
00144 O3Light->setSpotlightFalloff(value);
00145 }
00146
00147 float SLight::GetSpotlightFalloff()
00148 {
00149 return O3Light->getSpotlightFalloff();
00150 }
00151
00152 void SLight::SetCastShadows(bool castShadows)
00153 {
00154 O3Light->setCastShadows(castShadows);
00155 }
00156
00157 bool SLight::GetCastShadows()
00158 {
00159 return O3Light->getCastShadows();
00160 }
00161
00162 void SLight::SetRenderingDistance(float distance)
00163 {
00164 return O3Light->setRenderingDistance(distance);
00165 }
00166
00167 float SLight::GetRenderingDistance()
00168 {
00169 return O3Light->getRenderingDistance();
00170 }
00171
00172 Ogre::Vector3 SLight::GetBoundingBoxSize(bool childs)
00173 {
00174 if (childs)
00175 return GetSonsBoundingBox();
00176
00177 return O3Light->getBoundingBox().getSize();
00178 }
00179
00180 Ogre::Vector3 SLight::GetBoundingBoxCenter(bool childs)
00181 {
00182 return O3Light->getBoundingBox().getCenter();
00183 }
00184
00185 }