1 #ifndef DALI_SCENE3D_LIGHT_IMPL_H
2 #define DALI_SCENE3D_LIGHT_IMPL_H
5 * Copyright (c) 2024 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-impl.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/object/weak-handle.h>
25 #include <string_view>
28 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
29 #include <dali-scene3d/public-api/light/light.h>
36 * @addtogroup dali_scene3d_light
43 * @brief This is the internal base class for custom node of Light.
47 class DALI_SCENE3D_API Light : public Toolkit::Internal::Control
50 // Creation & Destruction
52 * @brief Creates a new LightImpl instance that does not require touch by default.
54 * If touch is required, then the user can connect to this class' touch signal.
56 * @return A handle to the Light instance
58 static Scene3D::Light New();
62 * @brief Virtual destructor.
67 public: // From Internal::Control.
69 * @copydoc Dali::Toolkit::Internal::Control::OnInitialize()
71 void OnInitialize() override;
73 protected: // From CustomActorImpl. Note that it will make we can ignore many codes what Internal::Control using now.
75 * @copydoc CustomActorImpl::OnSceneConnection()
76 * @note If overridden, then an up-call to Light::OnSceneConnection MUST be made at the end.
78 void OnSceneConnection(int depth) override;
81 * @copydoc CustomActorImpl::OnSceneDisconnection()
82 * @note If overridden, then an up-call to Light::OnSceneDisconnection MUST be made at the end.
84 void OnSceneDisconnection() override;
87 * @copydoc CustomActorImpl::OnChildAdd()
88 * @note If overridden, then an up-call to Light::OnChildAdd MUST be made at the end.
90 void OnChildAdd(Actor& child) override;
93 * @copydoc CustomActorImpl::OnChildRemove()
94 * @note If overridden, then an up-call to Light::OnChildRemove MUST be made at the end.
96 void OnChildRemove(Actor& child) override;
99 * @copydoc CustomActorImpl::OnSizeSet()
100 * @note If overridden, then an up-call to Light::OnSizeSet MUST be made at the end.
102 void OnSizeSet(const Vector3& targetSize) override;
105 * @copydoc CustomActorImpl::OnSizeAnimation()
106 * @note If overridden, then an up-call to Light::OnSizeAnimation MUST be made at the end.
108 void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override;
111 * @copydoc CustomActorImpl::OnRelayout()
113 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
116 * @copydoc CustomActorImpl::OnSetResizePolicy()
118 void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) override;
121 * @copydoc CustomActorImpl::GetNaturalSize()
123 Vector3 GetNaturalSize() override;
126 * @copydoc CustomActorImpl::CalculateChildSize()
128 float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) override;
131 * @copydoc CustomActorImpl::GetHeightForWidth()
133 float GetHeightForWidth(float width) override;
136 * @copydoc CustomActorImpl::GetWidthForHeight()
138 float GetWidthForHeight(float height) override;
141 * @copydoc CustomActorImpl::RelayoutDependentOnChildren()
143 bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) override;
146 * @copydoc CustomActorImpl::OnCalculateRelayoutSize()
148 void OnCalculateRelayoutSize(Dimension::Type dimension) override;
151 * @copydoc CustomActorImpl::OnLayoutNegotiated()
153 void OnLayoutNegotiated(float size, Dimension::Type dimension) override;
159 * @brief Light constructor.
163 public: // Public Method
165 * @copydoc Scene3D::Light::Enable()
167 void Enable(bool enable);
170 * @copydoc Scene3D::Light::IsEnabled()
172 bool IsEnabled() const;
175 * @copydoc Scene3D::Light::EnableShadow()
177 void EnableShadow(bool enable);
180 * @copydoc Scene3D::Light::IsShadowEnabled()
182 bool IsShadowEnabled() const;
185 * @copydoc Scene3D::Light::GetCamera()
187 CameraActor GetCamera() const;
190 * @copydoc Scene3D::Light::EnableShadowSoftFiltering()
192 void EnableShadowSoftFiltering(bool useSoftFiltering);
195 * @copydoc Scene3D::Light::IsShadowSoftFilteringEnabled()
197 bool IsShadowSoftFilteringEnabled() const;
200 * @copydoc Scene3D::Light::SetShadowIntensity()
202 void SetShadowIntensity(float shadowIntensity);
205 * @copydoc Scene3D::Light::GetShadowIntensity()
207 float GetShadowIntensity() const;
210 * @copydoc Scene3D::Light::SetShadowBias()
212 void SetShadowBias(float shadowBias);
215 * @copydoc Scene3D::Light::GetShadowBias()
217 float GetShadowBias() const;
219 public: // Public Static Method
221 * @copydoc Scene3D::Light::GetMaximumEnabledLightCount()
223 static uint32_t GetMaximumEnabledLightCount();
226 * @brief Retrieves Light Enabled Uniform Name for shader()
227 * @return string_view for LightEnabledUniformName
229 static std::string_view GetLightCountUniformName();
232 * @brief Retrieves Light Direction Uniform Name for shader()
233 * @return string_view for LightDirectionUniformName
235 static std::string_view GetLightDirectionUniformName();
238 * @brief Retrieves Light Color Uniform Name for shader()
239 * @return string_view for LightColorUniformName
241 static std::string_view GetLightColorUniformName();
244 * @brief Retrieves Uniform Name to define shadow is enabled or not.
245 * @return string_view for ShadowEnabledUniformName
247 static std::string_view GetShadowEnabledUniformName();
250 * @brief Retrieves Uniform Name for View/Projection matrix of the Shadow.
251 * @return string_view for ShadowViewProjectionMatrixUniformName
253 static std::string_view GetShadowViewProjectionMatrixUniformName();
256 void UpdateShadowUniforms();
261 // Not copyable or movable
262 DALI_INTERNAL Light(const Light&) = delete; ///< Deleted copy constructor.
263 DALI_INTERNAL Light(Light&&) = delete; ///< Deleted move constructor.
264 DALI_INTERNAL Light& operator=(const Light&) = delete; ///< Deleted copy assignment operator.
265 DALI_INTERNAL Light& operator=(Light&&) = delete; ///< Deleted move assignment operator.
268 Dali::CameraActor mLightSourceActor;
269 WeakHandle<Scene3D::SceneView> mParentSceneView;
270 bool mIsEnabled{true};
271 bool mIsShadowEnabled{false};
272 bool mUseSoftFiltering{false};
273 float mShadowIntensity{0.5f};
274 float mShadowBias{0.001f};
279 * @brief Gets implementation from the handle.
282 * @return Implementation
283 * @pre handle is initialized and points to a node
285 DALI_SCENE3D_API Internal::Light& GetImplementation(Dali::Scene3D::Light& handle);
288 * @brief Gets implementation from the handle.
291 * @return Implementation
292 * @pre Handle is initialized and points to a node.
294 DALI_SCENE3D_API const Internal::Light& GetImplementation(const Dali::Scene3D::Light& handle);
296 } // namespace Internal
301 } // namespace Scene3D
305 #endif // DALI_SCENE3D_LIGHT_IMPL_H