2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiEffects_RuntimeSpotLight.cpp
19 * @brief This file contains an implementation of SpotLight class methods
23 #include <FBaseSysLog.h>
24 #include <FBaseDataType.h>
25 #include <FUiEffects_RuntimeSpotLight.h>
27 using namespace Tizen::Ui::Effects::_Utils;
30 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
33 SpotLight::SpotLight(const std::string& name)
35 , isTargetChanged(false)
36 , isAngleOpeningChanged(false)
37 , isAngleFadeOutChanged(false)
38 , __target(0.f, 0.f, -1.f)
39 , __angleOpening(30.f / 180.f * M_PI)
40 , __angleFadeOut(5.f / 180.f * M_PI)
45 SpotLight::SpotLight(bool isEnabled,
49 const Vec3f& position,
53 : PointLight(isEnabled, name, colour, intensity, position)
54 , isTargetChanged(false)
55 , isAngleOpeningChanged(false)
56 , isAngleFadeOutChanged(false)
58 , __angleOpening(angleOpening)
59 , __angleFadeOut(angleFadeOut)
64 SpotLight::~SpotLight(void)
70 SpotLight::CreateSpotLight(const std::string& name)
72 SpotLight* pSpotLight = new (std::nothrow) SpotLight(name);
73 AddUnitLightToPool(pSpotLight);
78 SpotLight::CreateSpotLight(bool isEnabled,
79 const std::string& name,
82 const Vec3f& position,
87 SpotLight* pSpotLight = new (std::nothrow) SpotLight(isEnabled,
95 AddUnitLightToPool(pSpotLight);
100 SpotLight::GetTarget(void) const
106 SpotLight::GetAngleOpening(void) const
108 return __angleOpening;
112 SpotLight::GetAngleFadeOut(void) const
114 return __angleFadeOut;
118 SpotLight::SetTarget(const Vec3f& target)
120 SetTarget(target.x, target.y, target.z);
125 SpotLight::SetTarget(float x, float y, float z)
127 if (fabs(__target.x - x) > EFFECT_EPSILONF
128 || fabs(__target.y - y) > EFFECT_EPSILONF
129 || fabs(__target.z - z) > EFFECT_EPSILONF)
134 isTargetChanged = true;
135 isSomethingChanged = true;
141 SpotLight::SetAngleOpening(float angleOpening)
143 if (fabs(__angleOpening - angleOpening) > EFFECT_EPSILONF)
145 if (angleOpening < 0 || angleOpening > 2 * M_PI)
149 __angleOpening = angleOpening;
150 isAngleOpeningChanged = true;
151 isSomethingChanged = true;
157 SpotLight::SetAngleFadeOut(float angleFadeOut)
159 if (fabs(__angleFadeOut - angleFadeOut) > EFFECT_EPSILONF)
161 if (angleFadeOut < 0 || angleFadeOut > M_PI - __angleOpening / 2.f)
165 __angleFadeOut = angleFadeOut;
166 isAngleFadeOutChanged = true;
167 isSomethingChanged = true;
173 SpotLight::GetType(void) const
175 return TYPE_UNIT_LIGHT_SPOT;
179 SpotLight::ResetSigns(void)
181 PointLight::ResetSigns();
182 isTargetChanged = false;
183 isAngleOpeningChanged = false;
184 isAngleFadeOutChanged = false;
187 } } } } // Tizen::Ui::Effects::_Runtime