1 #ifndef DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r
2 #define DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
21 // EXTERNAL INCLUDES
\r
22 #include <dali/devel-api/adaptor-framework/file-loader.h>
\r
23 #include <dali/devel-api/adaptor-framework/image-loading.h>
\r
24 #include <dali/public-api/object/base-object.h>
\r
25 #include <dali/public-api/rendering/shader.h>
\r
28 // INTERNAL INCLUDES
\r
29 #include <dali-toolkit/devel-api/controls/scene3d-view/scene3d-view.h>
\r
30 #include <dali-toolkit/internal/controls/scene3d-view/gltf-loader.h>
\r
31 #include <dali-toolkit/public-api/controls/control-impl.h>
\r
48 * Scene3dView implementation class
\r
50 class Scene3dView : public Control
\r
55 CROSS_HORIZONTAL = 0, // Cross horizontal style cube map
\r
56 ARRAY_HORIZONTAL, // array horizontal style cube map
\r
61 * @copydoc Dali::Toolkit::Scene3dView::Scene3dView
\r
66 * @copydoc Dali::Toolkit::Scene3dView::~Scene3dView
\r
68 virtual ~Scene3dView();
\r
71 * @copydoc Dali::Toolkit::Scene3dView::New( const std::string& filePath )
\r
73 static Dali::Toolkit::Scene3dView New(const std::string& filePath);
\r
76 * @copydoc Dali::Toolkit::Scene3dView::New( const std::string& filePath, const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor )
\r
78 static Dali::Toolkit::Scene3dView New(const std::string& filePath, const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor);
\r
81 * @copydoc Dali::Toolkit::Scene3dView::CreateScene()
\r
86 * @copydoc Dali::Toolkit::Scene3dView::GetAnimationCount()
\r
88 uint32_t GetAnimationCount();
\r
91 * @copydoc Dali::Toolkit::Scene3dView::PlayAnimation()
\r
93 bool PlayAnimation(uint32_t index);
\r
96 * @copydoc Dali::Toolkit::Scene3dView::PlayAnimations()
\r
98 bool PlayAnimations();
\r
101 * @copydoc Dali::Toolkit::Scene3dView::SetLight( Toolkit::Scene3dView::LightType type, Vector3 lightVector, Vector3 lightColor )
\r
103 bool SetLight(Toolkit::Scene3dView::LightType type, Vector3 lightVector, Vector3 lightColor);
\r
106 * @brief Set default CameraActor specified in the each scene format specification.
\r
107 * Default input values are derived from glTF default camera format.
\r
108 * with Dali::Camera::Type = Dali::Camera::LOOK_AT_TARGET,
\r
109 * near clipping plane = 0.1,
\r
110 * and camera position = Vector3( 0.0, 0.0, 0.0 ).
\r
112 bool SetDefaultCamera(const Dali::Camera::Type type = Dali::Camera::LOOK_AT_TARGET, const float nearPlane = 0.1, const Vector3 cameraPosition = Vector3(0.0, 0.0, 0.0));
\r
115 * @brief Add CameraActor loaded from scene format file.
\r
117 void AddCamera(CameraActor cameraActor);
\r
120 * @brief Add Animation loaded from scene format file.
\r
122 void AddAnimation(Animation animation);
\r
125 * @brief Add new Shader.
\r
126 * Actors can share same Shader if they use same properties.
\r
127 * If a property changes in a shader, then the property of all actors that use the shader change.
\r
129 void AddShader(Shader shader);
\r
132 * @brief Get Root Actor.
\r
137 * @copydoc Dali::Toolkit::Scene3dView::GetDefaultCamera()
\r
139 CameraActor GetDefaultCamera();
\r
142 * @copydoc Dali::Toolkit::Scene3dView::GetCameraCount()
\r
144 uint32_t GetCameraCount();
\r
147 * @copydoc Dali::Toolkit::Scene3dView::GetCamera( uint32_t cameraIndex )
\r
149 CameraActor GetCamera(uint32_t cameraIndex);
\r
152 * @brief Get light type.
\r
154 Toolkit::Scene3dView::LightType GetLightType();
\r
157 * @brief Get light vector.
\r
158 * Return light position when light type is LightType::POINT_LIGHT
\r
159 * Return light direction when light type is LightType::DIRECTIONAL_LIGHT
\r
161 Vector3 GetLightVector();
\r
164 * @brief Get light color.
\r
166 Vector3 GetLightColor();
\r
169 * @brief Get Scaling factor of IBL.
\r
171 Vector4 GetIBLScaleFactor();
\r
174 * @brief Get BRDF Texture.
\r
176 Texture GetBRDFTexture();
\r
179 * @brief Get diffuse cube map texture.
\r
181 Texture GetDiffuseTexture();
\r
184 * @brief Get specular cube map texture.
\r
186 Texture GetSpecularTexture();
\r
190 * @brief Get Cropped image buffer.
\r
191 * For each direction, Offset + faceSize must be width or height or less then them.
\r
193 uint8_t* GetCroppedBuffer(uint8_t* sourceBuffer, uint32_t bytesPerPixel, uint32_t width, uint32_t height, uint32_t xOffset, uint32_t yOffset, uint32_t xFaceSize, uint32_t yFaceSize);
\r
196 * @brief Upload cube map texture.
\r
198 void UploadTextureFace(Texture& texture, Devel::PixelBuffer pixelBuffer, uint32_t faceIndex);
\r
201 * @brief Set diffuse and specular cube map textures.
\r
203 void SetCubeMap(const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor = Vector4(1.0, 1.0, 1.0, 1.0));
\r
205 virtual void OnInitialize();
\r
208 * @brief Load 2D texture.
\r
209 * @param[in] imageUrl Image URL of the texture.
\r
210 * @param[in] generateMipmaps If generateMipmaps is true, then generate mipmap of this texture.
\r
211 * @return Texture loaded from imageUrl.
\r
213 Texture LoadTexture(const char* imageUrl, bool generateMipmaps);
\r
216 Actor mRoot; // Root actor that contains scene graph
\r
217 std::string mFilePath; // Full file path of scene file
\r
219 std::vector<Shader> mShaderArray; // Shader Array to change properties of scene such as lighting.
\r
221 std::vector<CameraActor> mCameraActorArray; // CameraActer array loaded from scene format file.
\r
222 CameraActor mDefaultCamera; // Default CameraActor for the empty mCameraActorArray.
\r
224 std::vector<Animation> mAnimationArray; // Animation array loaded from scene format file.
\r
226 Toolkit::Scene3dView::LightType mLightType; // Light type
\r
227 Vector3 mLightVector; // Light position when mLightType is LightType::POINT_LIGHT
\r
228 // Light direction when mLightType is LightType::DIRECTIONAL_LIGHT
\r
229 Vector3 mLightColor; // Light color
\r
231 Vector4 mIBLScaleFactor; // IBL scaling factor for the IBL rendering
\r
232 Texture mBRDFTexture; // BRDF texture for the PBR rendering
\r
233 Texture mSpecularTexture; // Specular cube map texture
\r
234 Texture mDiffuseTexture; // Diffuse cube map texture
\r
237 // Undefined copy constructor.
\r
238 Scene3dView(const Scene3dView&);
\r
240 // Undefined assignment operator.
\r
241 Scene3dView& operator=(const Scene3dView&);
\r
244 } // namespace Internal
\r
246 // Helpers for public-api forwarding methods
\r
247 inline const Internal::Scene3dView& GetImpl(const Toolkit::Scene3dView& scene3dView)
\r
249 DALI_ASSERT_ALWAYS(scene3dView && "Scene3dView handle is empty");
\r
250 const Dali::RefObject& handle = scene3dView.GetImplementation();
\r
252 return static_cast<const Toolkit::Internal::Scene3dView&>(handle);
\r
255 inline Internal::Scene3dView& GetImpl(Toolkit::Scene3dView& scene3dView)
\r
257 DALI_ASSERT_ALWAYS(scene3dView && "Scene3dView handle is empty");
\r
259 Dali::RefObject& handle = scene3dView.GetImplementation();
\r
261 return static_cast<Toolkit::Internal::Scene3dView&>(handle);
\r
264 } //namespace Toolkit
\r
268 #endif // DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r