1 #ifndef __DALI_LIGHT_H__
2 #define __DALI_LIGHT_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/object/base-handle.h>
29 * The top level DALi namespace
31 namespace Dali DALI_IMPORT_API
34 namespace Internal DALI_INTERNAL
42 * @brief Light source types.
46 AMBIENT, ///< Lights everything evenly
47 DIRECTIONAL, ///< Casts light evenly in a specific direction.
48 SPOT, ///< Casts light from a single point in the shape of a cone. Objects outside the cone are unlit. (EG: a search light)
49 POINT ///< Casts light outward from a single point in all directions. (EG: a light bulb)
53 * @brief Encapsulates the data describing a light source.
55 class Light : public BaseHandle
59 * @brief Create an initialized Light.
61 * @param[in] name The light's name
62 * @return A handle to a newly allocated Dali resource.
64 static Light New(const std::string& name);
67 * @brief Downcast an Object handle to Light handle.
69 * If handle points to a Light object the downcast produces valid
70 * handle. If not the returned handle is left uninitialized.
71 * @param[in] handle to An object
72 * @return handle to a Light object or an uninitialized handle
74 static Light DownCast( BaseHandle handle );
77 * @brief Create an uninitialized light; this can be initialized with Light::New().
79 * Calling member functions with an uninitialized Dali::Object is not allowed.
88 * This is non-virtual since derived Handle types must not contain data or virtual methods.
93 * @brief This copy constructor is required for (smart) pointer semantics.
95 * @param [in] handle A reference to the copied handle
97 Light(const Light& handle);
100 * @brief This assignment operator is required for (smart) pointer semantics.
102 * @param [in] rhs A reference to the copied handle
103 * @return A reference to this
105 Light& operator=(const Light& rhs);
108 * @brief This method is defined to allow assignment of the NULL value,
109 * and will throw an exception if passed any other value.
111 * Assigning to NULL is an alias for Reset().
112 * @param [in] rhs A NULL pointer
113 * @return A reference to this handle
115 Light& operator=(BaseHandle::NullType* rhs);
118 * @brief Set the light's name.
120 * @param[in] name The light's name
122 void SetName(const std::string& name);
125 * @brief Get the light's name.
127 * @return The light's name
129 const std::string& GetName() const;
132 * @brief Set the light's type.
134 * @param[in] type The type of light
136 void SetType(LightType type);
139 * @brief Get the lights type.
141 * @return The light's type
143 LightType GetType() const;
146 * @brief Set the distances at which the light's intensity starts to fall off and reaches zero.
148 * @param[in] fallOff The fall off start and end. The start is in the x component and end is in the y component.
150 void SetFallOff(const Vector2& fallOff);
153 * @brief Get the distances at which the light's intensity starts to fall off and reaches zero.
155 * @return The distances at which the light's intensity starts to fall off, and reaches zero.
156 * See @ref SetFallOff
158 const Vector2& GetFallOff() const;
161 * @brief Set the spotlight's inner and outer cone angles.
163 * @param[in] angle The spotlight's inner and outer cone angles.
164 * The inner is in the x component and outer is in the y component.
166 void SetSpotAngle(const Vector2& angle);
169 * @brief Get the spotlight's inner and outer cone angles.
171 * @return The spotlight's inner and outer cone angles
173 const Vector2& GetSpotAngle() const;
176 * @brief Set the ambient color for the light.
178 * The color is composed of rgb
179 * @param[in] color The color to set.
181 void SetAmbientColor(const Vector3& color);
184 * @brief Get the light's ambient color.
186 * @return the light's color as rgb
188 const Vector3& GetAmbientColor() const;
191 * @brief Set the diffuse color for the light.
193 * The color is composed of rgb
194 * @param[in] color The color to set.
196 void SetDiffuseColor(const Vector3& color);
199 * @brief Get the light's ambient color.
201 * @return the light's color as rgb
203 const Vector3& GetDiffuseColor() const;
206 * @brief Set the specular color for the light.
208 * The color is composed of rgb
209 * @param[in] color The color to set.
211 void SetSpecularColor(const Vector3& color);
214 * @brief Get the light's specular color.
216 * @return the light's specular color as rgb
218 const Vector3& GetSpecularColor() const;
221 * @brief Set the direction in which the light's rays are cast.
223 * Valid when the light's type is DIRECTIONAL (see @ref Dali::LightType).
224 * @param [in] direction The direction in which the light's rays are cast.
226 void SetDirection(const Vector3& direction);
229 * @brief Get the direction in which the light's rays are cast.
231 * Valid when the light's type is DIRECTIONAL (see @ref LightType).
232 * @return The direction in which the light's rays are cast.
234 const Vector3& GetDirection() const;
236 public: // Not intended for application developers
239 * @brief This constructor is used by Dali New() methods.
241 * @param [in] light A pointer to a newly allocated Dali resource
243 explicit DALI_INTERNAL Light(Internal::Light* light);
248 #endif // __DALI_LIGHT_H__