1 #ifndef DALI_SCENE3D_INTERNAL_SCENE_VIEW_H
2 #define DALI_SCENE3D_INTERNAL_SCENE_VIEW_H
5 * Copyright (c) 2022 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/internal/visuals/image/image-visual.h>
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali/public-api/actors/camera-actor.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/animation/animation.h>
27 #include <dali/public-api/object/weak-handle.h>
28 #include <dali/public-api/render-tasks/render-task.h>
29 #include <dali/public-api/rendering/frame-buffer.h>
30 #include <dali/public-api/rendering/texture.h>
33 #include <dali-scene3d/public-api/controls/model-view/model-view.h>
34 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
45 * @brief Impl class for SceneView.
47 class SceneView : public Dali::Toolkit::Internal::Control
51 * @brief Creates a new SceneView.
53 * @return A public handle to the newly allocated SceneView.
55 static Dali::Scene3D::SceneView New();
58 * @copydoc SceneView::AddCamera()
60 void AddCamera(Dali::CameraActor camera);
63 * @copydoc SceneView::RemoveCamera()
65 void RemoveCamera(CameraActor camera);
68 * @copydoc SceneView::GetCameraCount()
70 uint32_t GetCameraCount() const;
73 * @copydoc SceneView::GetSelectedCamera()
75 CameraActor GetSelectedCamera() const;
78 * @copydoc SceneView::GetCamera()
80 CameraActor GetCamera(uint32_t index) const;
83 * @copydoc SceneView::GetCamera()
85 CameraActor GetCamera(const std::string& name) const;
88 * @copydoc SceneView::SelectCamera()
90 void SelectCamera(uint32_t index);
93 * @copydoc SceneView::SelectCamera()
95 void SelectCamera(const std::string& name);
98 * @brief Register a ModelView.
99 * Some works like ibl setting should be applied on the only ModelView not the all child actors.
100 * SceneView contains child ModelView list to apply the works effectively.
102 * @param[in] modelView ModelView to be registered.
104 void RegisterModelView(Scene3D::ModelView modelView);
107 * @brief Unregister a ModelView
109 * @param[in] modelView ModelView to be unregistered.
111 void UnregisterModelView(Scene3D::ModelView modelView);
114 * @copydoc SceneView::SetImageBasedLightSource()
116 void SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor);
119 * @copydoc SceneView::SetImageBasedLightScaleFactor()
121 void SetImageBasedLightScaleFactor(float scaleFactor);
124 * @copydoc SceneView::GetImageBasedLightScaleFactor()
126 float GetImageBasedLightScaleFactor() const;
129 * @copydoc SceneView::UseFramebuffer()
131 void UseFramebuffer(bool useFramebuffer);
134 * @copydoc SceneView::IsUsingFramebuffer()
136 bool IsUsingFramebuffer() const;
140 * @brief Constructs a new SceneView.
145 * A reference counted object may only be deleted by calling Unreference()
147 virtual ~SceneView();
151 * @copydoc CustomActorImpl::OnSceneConnection()
153 void OnSceneConnection(int depth) override;
156 * @copydoc CustomActorImpl::OnSceneDisconnection()
158 void OnSceneDisconnection() override;
161 * @copydoc Toolkit::Control::OnInitialize()
163 void OnInitialize() override;
166 * @copydoc Toolkit::Control::OnChildAdd()
168 void OnChildAdd(Actor& child) override;
171 * @copydoc Toolkit::Control::OnChildRemove()
173 void OnChildRemove(Actor& child) override;
176 * @copydoc Toolkit::Control::GetHeightForWidth()
178 float GetHeightForWidth(float width) override;
181 * @copydoc Toolkit::Control::GetWidthForHeight()
183 float GetWidthForHeight(float height) override;
186 * @copydoc Toolkit::Control::OnRelayout()
188 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
191 * @copydoc Toolkit::Control::IsResourceReady()
193 bool IsResourceReady() const override;
196 * @brief Changes main camera as a input camera
198 * @param camera CameraActor that will be a main camera of the SceneView
200 void UpdateCamera(CameraActor camera);
203 * @brief Updates RenderTask to use selected camera and to make framebuffer
205 void UpdateRenderTask();
208 Toolkit::Visual::Base mVisual;
210 /////////////////////////////////////////////////////////////
211 // FrameBuffer and Rendertask to render child objects as a 3D Scene
212 CameraActor mDefaultCamera;
213 CameraActor mSelectedCamera;
214 std::vector<CameraActor> mCameras;
215 std::vector<Scene3D::ModelView> mModels;
216 Dali::FrameBuffer mRenderTarget;
217 Dali::Texture mTexture;
218 Dali::RenderTask mRenderTask;
222 Dali::Texture mSpecularTexture;
223 Dali::Texture mDiffuseTexture;
224 float mIblScaleFactor{1.0f};
225 bool mUseFrameBuffer{false};
226 bool mIBLResourceReady{true};
228 // TODO : Light Source
231 } // namespace Internal
233 // Helpers for public-api forwarding methods
234 inline Dali::Scene3D::Internal::SceneView& GetImpl(Dali::Scene3D::SceneView& obj)
236 DALI_ASSERT_ALWAYS(obj);
237 Dali::RefObject& handle = obj.GetImplementation();
238 return static_cast<Dali::Scene3D::Internal::SceneView&>(handle);
241 inline const Dali::Scene3D::Internal::SceneView& GetImpl(const Dali::Scene3D::SceneView& obj)
243 DALI_ASSERT_ALWAYS(obj);
244 const Dali::RefObject& handle = obj.GetImplementation();
245 return static_cast<const Dali::Scene3D::Internal::SceneView&>(handle);
248 } // namespace Scene3D
252 #endif // DALI_SCENE3D_INTERNAL_SCENE_VIEW_H