[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / public-api / common / light.h
1 #ifndef __DALI_LIGHT_H__
2 #define __DALI_LIGHT_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // EXTERNAL INCLUDES
21 #include <string>
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/object/base-handle.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Internal DALI_INTERNAL
30 {
31 class Light;
32 }
33
34 class Light;
35
36 /**
37  * Light source types
38  */
39 enum LightType
40 {
41   AMBIENT,        ///< Lights everything evenly
42   DIRECTIONAL,    ///< Casts light evenly in a specific direction.
43   SPOT,           ///< Casts light from a single point in the shape of a cone. Objects outside the cone are unlit. (EG: a search light)
44   POINT           ///< Casts light outward from a single point in all directions. (EG: a light bulb)
45 };
46
47 /**
48  * Encapsulates the data describing a light source
49  */
50 class Light : public BaseHandle
51 {
52 public:
53   /**
54    * Create an initialized Light.
55    * @param[in] name The light's name
56    * @return A handle to a newly allocated Dali resource.
57    */
58   static Light New(const std::string& name);
59
60   /**
61    * Downcast an Object handle to Light handle. If handle points to a Light object the
62    * downcast produces valid handle. If not the returned handle is left uninitialized.
63    * @param[in] handle to An object
64    * @return handle to a Light object or an uninitialized handle
65    */
66   static Light DownCast( BaseHandle handle );
67
68   /**
69    * Create an uninitialized light; this can be initialized with Light::New()
70    * Calling member functions with an uninitialized Dali::Object is not allowed.
71    */
72   Light()
73   {
74   }
75
76   /**
77    * Virtual destructor.
78    */
79   virtual ~Light();
80
81   /**
82    * @copydoc Dali::BaseHandle::operator=
83    */
84   using BaseHandle::operator=;
85
86   /**
87    * Set the light's name
88    * @param[in] name The light's name
89    */
90   void SetName(const std::string& name);
91
92   /**
93    * Get the light's name
94    * @return The light's name
95    */
96   const std::string& GetName() const;
97
98   /**
99    * Set the light's type
100    * @param[in] type The type of light
101    */
102   void SetType(LightType type);
103
104   /**
105    * Get the lights type.
106    * @return The light's type
107    */
108   LightType GetType() const;
109
110   /**
111    * Set the distances at which the light's intensity starts to fall off and reaches zero
112    * @param[in] fallOff The fall off start and end. The start is in the x component and end is in the y component.
113    */
114   void SetFallOff(const Vector2& fallOff);
115
116   /**
117    * Get the distances at which the light's intensity starts to fall off and reaches zero.
118    * @return The distances at which the light's intensity starts to fall off, and reaches zero.
119    * See @ref SetFallOff
120    */
121   const Vector2& GetFallOff() const;
122
123   /**
124    * Set the spotlight's inner and outer cone angles
125    * @param[in] angle The spotlight's inner and outer cone angles.
126    *                  The inner is in the x component and outer is in the y component.
127    */
128   void SetSpotAngle(const Vector2& angle);
129
130   /**
131    * Get the spotlight's inner and outer cone angles
132    * @return The spotlight's inner and outer cone angles
133    */
134   const Vector2& GetSpotAngle() const;
135
136   /**
137    * Set the ambient color for the light
138    * The color is composed of rgb
139    * @param[in] color The color to set.
140    */
141   void SetAmbientColor(const Vector3& color);
142
143   /**
144    * Get the light's ambient color
145    * @return the light's color as rgb
146    */
147   const Vector3& GetAmbientColor() const;
148
149   /**
150    * Set the diffuse color for the light
151    * The color is composed of rgb
152    * @param[in] color The color to set.
153    */
154   void SetDiffuseColor(const Vector3& color);
155
156   /**
157    * Get the light's ambient color
158    * @return the light's color as rgb
159    */
160   const Vector3& GetDiffuseColor() const;
161
162   /**
163    * Set the specular color for the light
164    * The color is composed of rgb
165    * @param[in] color The color to set.
166    */
167   void SetSpecularColor(const Vector3& color);
168
169   /**
170    * Get the light's specular color
171    * @return the light's specular color as rgb
172    */
173   const Vector3& GetSpecularColor() const;
174
175   /**
176    * Set the direction in which the light's rays are cast.
177    * Valid when the light's type is DIRECTIONAL (see @ref Dali::LightType).
178    * @param [in] direction The direction in which the light's rays are cast.
179    */
180   void SetDirection(const Vector3& direction);
181
182   /**
183    * Get the direction in which the light's rays are cast.
184    * Valid when the light's type is DIRECTIONAL (see @ref LightType).
185    * @return The direction in which the light's rays are cast.
186    */
187   const Vector3& GetDirection() const;
188
189 public: // Not intended for application developers
190
191   /**
192    * This constructor is used by Dali New() methods
193    * @param [in] light A pointer to a newly allocated Dali resource
194    */
195   explicit DALI_INTERNAL Light(Internal::Light* light);
196 };
197
198 } // namespace Dali
199
200 #endif // __DALI_LIGHT_H__