Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / effects / runtime / FUiEffects_RuntimePointLight.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 /**
18  * @file        FUiEffects_RuntimePointLight.cpp
19  * @brief       This file contains an implementation of PointLight class methods
20  *
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FBaseDataType.h>
25 #include <FUiEffects_RuntimePointLight.h>
26
27 using namespace Tizen::Ui::Effects::_Utils;
28 using namespace std;
29
30 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
31 {
32
33 PointLight::PointLight(const string& name)
34                                 : UnitLight(name)
35                                 , isPositionChanged(false)
36                                 , __position(0.f, 0.f, 0.f)
37 {
38
39 }
40
41 PointLight::PointLight(bool enabled,
42                                                 const string& name,
43                                                 const Vec3f& colour,
44                                                 float intensity,
45                                                 const Vec3f& position)
46                                                         : UnitLight(enabled, name, colour, intensity)
47                                                         , isPositionChanged(false)
48                                                         , __position(position)
49 {
50
51 }
52
53 PointLight::~PointLight(void)
54 {
55
56 }
57
58 PointLight*
59 PointLight::CreatePointLight(const string& name)
60 {
61         PointLight* pPointLight = new (std::nothrow) PointLight(name);
62         AddUnitLightToPool(pPointLight);
63         return pPointLight;
64 }
65
66 PointLight*
67 PointLight::CreatePointLight(bool isEnabled,
68                                                         const std::string& name,
69                                                         const Vec3f& colour,
70                                                         float intensity,
71                                                         const Vec3f& position)
72 {
73         PointLight* pPointLight = new (std::nothrow) PointLight(isEnabled,
74                                                                                                                         name,
75                                                                                                                         colour,
76                                                                                                                         intensity,
77                                                                                                                         position);
78         AddUnitLightToPool(pPointLight);
79         return pPointLight;
80 }
81
82 const Vec3f&
83 PointLight::GetPosition(void) const
84 {
85         return __position;
86 }
87
88 void
89 PointLight::SetPosition(const Tizen::Ui::Effects::_Utils::Vec3f& position)
90 {
91         SetPosition(position.x, position.y, position.z);
92         return;
93 }
94
95 void
96 PointLight::SetPosition(float x, float y, float z)
97 {
98         if (fabs(__position.x - x) > EFFECT_EPSILONF
99                 || fabs(__position.y - y) > EFFECT_EPSILONF
100                 || fabs(__position.z - z) > EFFECT_EPSILONF)
101         {
102                 __position.x = x;
103                 __position.y = y;
104                 __position.z = z;
105                 isPositionChanged = true;
106                 isSomethingChanged = true;
107         }
108         return;
109 }
110
111 TypeUnitLight
112 PointLight::GetType(void) const
113 {
114         return TYPE_UNIT_LIGHT_POINT;
115 }
116
117 void
118 PointLight::ResetSigns(void)
119 {
120         UnitLight::ResetSigns();
121         isPositionChanged = false;
122 }
123
124 } } } } // Tizen::Ui::Effects::_Runtime