1 #ifndef DALI_SCENE3D_LIGHT_H
2 #define DALI_SCENE3D_LIGHT_H
5 * Copyright (c) 2023 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.
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali/public-api/common/dali-common.h>
26 #include <dali-scene3d/public-api/api.h>
32 namespace Internal DALI_INTERNAL
38 * @addtogroup dali_toolkit_controls_light
43 * @brief This class is to define 3D Light source.
44 * Currently this Light class supports Directional Light that lits every position from the same direction. (e.g, Sun light)
45 * If a Light object is added on SceneView, the 3D objects in the SceneView are shined the Light.
46 * DALi Scene3D limits the maximum enabled light count per each SceneView.
47 * Currently the maximum number is set to 5, and it can be retrieved by using GetMaximumEnabledLightCount().
48 * If more than 5 enabled Light objects are added on SceneView, SceneView turns on only 5 lights in the order the lights were added.
49 * This Light can be added to SceneView directly but also it can be added on other Actor.
50 * When a parent actor is added to a SceneView, its Light behaves in the SceneView the same as if it were added directly to the SceneView.
51 * @note Light inherits Actor, so Light color and direction can be controlled by setting Actor's COLOR and ORIENTATION Property.
52 * Dali::DevelActor::LookAt() method can be used to set light direction easily.
53 * @note Default light direction is to Z-axis
55 * Scene3D::SceneView sceneView = Scene3D::SceneView::New();
56 * Scene3D::Lightlight = Scene3D::Light::New();
57 * light.SetProperty(Dali::Actor::Property::COLOR, Color::BROWN);
58 * Dali::DevelActor::LookAt(light, Vector3(1.0f, 1.0f, 1.0f));
59 * sceneView.Add(light);
63 class DALI_SCENE3D_API Light : public Dali::CustomActor
67 * @brief Create an initialized Light.
70 * @return A handle to a newly allocated Dali resource
75 * @brief Creates an uninitialized Light.
77 * Only derived versions can be instantiated. Calling member
78 * functions with an uninitialized Dali::Object is not allowed.
87 * This is non-virtual since derived Handle types must not contain data or virtual methods.
94 * @brief Copy constructor.
97 * @param[in] light Handle to an object
99 Light(const Light& light);
102 * @brief Move constructor
105 * @param[in] rhs A reference to the moved handle
107 Light(Light&& rhs) noexcept;
110 * @brief Assignment operator.
113 * @param[in] light Handle to an object
114 * @return reference to this
116 Light& operator=(const Light& light);
119 * @brief Move assignment
122 * @param[in] rhs A reference to the moved handle
123 * @return A reference to this
125 Light& operator=(Light&& rhs) noexcept;
128 * @brief Downcasts an Object handle to Light.
130 * If handle points to a Light, the downcast produces valid handle.
131 * If not, the returned handle is left uninitialized.
134 * @param[in] handle Handle to an object
135 * @return Handle to a Light or an uninitialized handle
137 static Light DownCast(BaseHandle handle);
140 * @brief Enables this light.
141 * The Light is turned on when the Light object is added on SceneView and enabled.
143 * @note SceneView can turn on only up to maximum enabled light count that can be retrieved by GetMaximumEnabledLightCount().
144 * @param[in] enable True to make this Light enable.
146 void Enable(bool enable);
149 * @brief Checks whether this light is enabled or not.
151 * @return True if this light is enabled.
153 bool IsEnabled() const;
156 * @brief Retrieves maximum enabled light count.
158 * @return The number of maximum enabled light count.
160 static uint32_t GetMaximumEnabledLightCount();
162 public: // Not intended for application developers
165 * @brief Creates a handle using the Toolkit::Internal implementation.
167 * @param[in] implementation The Control implementation
169 DALI_INTERNAL Light(Internal::Light& implementation);
172 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
174 * @param[in] internal A pointer to the internal CustomActor
176 DALI_INTERNAL Light(Dali::Internal::CustomActor* internal);
183 } // namespace Scene3D
187 #endif // DALI_SCENE3D_LIGHT_H