Adding chipmunk implementation for physics adaptor
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / light / light.h
1 #ifndef DALI_SCENE3D_LIGHT_H
2 #define DALI_SCENE3D_LIGHT_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
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
21 // EXTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-scene3d/public-api/api.h>
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 namespace Internal DALI_INTERNAL
33 {
34 class Light;
35 }
36
37 /**
38  * @addtogroup dali_toolkit_controls_light
39  * @{
40  */
41
42 /**
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
54  * @code
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);
60  * @endcode
61  * @SINCE_2_2.32
62  */
63 class DALI_SCENE3D_API Light : public Dali::CustomActor
64 {
65 public:
66   /**
67    * @brief Create an initialized Light.
68    *
69    * @SINCE_2_2.32
70    * @return A handle to a newly allocated Dali resource
71    */
72   static Light New();
73
74   /**
75    * @brief Creates an uninitialized Light.
76    *
77    * Only derived versions can be instantiated. Calling member
78    * functions with an uninitialized Dali::Object is not allowed.
79    *
80    * @SINCE_2_2.32
81    */
82   Light();
83
84   /**
85    * @brief Destructor.
86    *
87    * This is non-virtual since derived Handle types must not contain data or virtual methods.
88    *
89    * @SINCE_2_2.32
90    */
91   ~Light();
92
93   /**
94    * @brief Copy constructor.
95    *
96    * @SINCE_2_2.32
97    * @param[in] light Handle to an object
98    */
99   Light(const Light& light);
100
101   /**
102    * @brief Move constructor
103    *
104    * @SINCE_2_2.32
105    * @param[in] rhs A reference to the moved handle
106    */
107   Light(Light&& rhs) noexcept;
108
109   /**
110    * @brief Assignment operator.
111    *
112    * @SINCE_2_2.32
113    * @param[in] light Handle to an object
114    * @return reference to this
115    */
116   Light& operator=(const Light& light);
117
118   /**
119    * @brief Move assignment
120    *
121    * @SINCE_2_2.32
122    * @param[in] rhs A reference to the moved handle
123    * @return A reference to this
124    */
125   Light& operator=(Light&& rhs) noexcept;
126
127   /**
128    * @brief Downcasts an Object handle to Light.
129    *
130    * If handle points to a Light, the downcast produces valid handle.
131    * If not, the returned handle is left uninitialized.
132    *
133    * @SINCE_2_2.32
134    * @param[in] handle Handle to an object
135    * @return Handle to a Light or an uninitialized handle
136    */
137   static Light DownCast(BaseHandle handle);
138
139   /**
140    * @brief Enables this light.
141    * The Light is turned on when the Light object is added on SceneView and enabled.
142    * @SINCE_2_2.32
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.
145    */
146   void Enable(bool enable);
147
148   /**
149    * @brief Checks whether this light is enabled or not.
150    * @SINCE_2_2.32
151    * @return True if this light is enabled.
152    */
153   bool IsEnabled() const;
154
155   /**
156    * @brief Retrieves maximum enabled light count.
157    * @SINCE_2_2.32
158    * @return The number of maximum enabled light count.
159    */
160   static uint32_t GetMaximumEnabledLightCount();
161
162 public: // Not intended for application developers
163   /// @cond internal
164   /**
165    * @brief Creates a handle using the Toolkit::Internal implementation.
166    *
167    * @param[in] implementation The Control implementation
168    */
169   DALI_INTERNAL Light(Internal::Light& implementation);
170
171   /**
172    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
173    *
174    * @param[in] internal A pointer to the internal CustomActor
175    */
176   DALI_INTERNAL Light(Dali::Internal::CustomActor* internal);
177   /// @endcond
178 };
179
180 /**
181  * @}
182  */
183 } // namespace Scene3D
184
185 } // namespace Dali
186
187 #endif // DALI_SCENE3D_LIGHT_H