1 #ifndef DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r
2 #define DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r
5 * Copyright (c) 2018 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
23 #include <dali/public-api/object/base-object.h>
\r
24 #include <dali/public-api/rendering/shader.h>
\r
25 #include <dali/devel-api/adaptor-framework/image-loading.h>
\r
26 #include <dali/devel-api/adaptor-framework/file-loader.h>
\r
28 // INTERNAL INCLUDES
\r
29 #include <dali-toolkit/public-api/controls/control-impl.h>
\r
30 #include <dali-toolkit/devel-api/controls/scene3d-view/scene3d-view.h>
\r
31 #include <dali-toolkit/internal/controls/scene3d-view/gltf-loader.h>
\r
52 * Scene3dView implementation class
\r
54 class Scene3dView : public Control
\r
60 CROSS_HORIZONTAL = 0, // Cross horizontal style cube map
\r
61 ARRAY_HORIZONTAL, // array horizontal style cube map
\r
67 * @copydoc Dali::Toolkit::Scene3dView::Scene3dView
\r
72 * @copydoc Dali::Toolkit::Scene3dView::~Scene3dView
\r
74 virtual ~Scene3dView();
\r
77 * @copydoc Dali::Toolkit::Scene3dView::New( const std::string& filePath )
\r
79 static Dali::Toolkit::Scene3dView New( const std::string& filePath );
\r
82 * @copydoc Dali::Toolkit::Scene3dView::New( const std::string& filePath, const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor )
\r
84 static Dali::Toolkit::Scene3dView New( const std::string& filePath, const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor );
\r
87 * @copydoc Dali::Toolkit::Scene3dView::CreateScene()
\r
92 * @copydoc Dali::Toolkit::Scene3dView::GetAnimationCount()
\r
94 uint32_t GetAnimationCount();
\r
97 * @copydoc Dali::Toolkit::Scene3dView::PlayAnimation()
\r
99 bool PlayAnimation( uint32_t index );
\r
102 * @copydoc Dali::Toolkit::Scene3dView::PlayAnimations()
\r
104 bool PlayAnimations();
\r
107 * @copydoc Dali::Toolkit::Scene3dView::SetLight( Toolkit::Scene3dView::LightType type, Vector3 lightVector, Vector3 lightColor )
\r
109 bool SetLight( Toolkit::Scene3dView::LightType type, Vector3 lightVector, Vector3 lightColor );
\r
112 * @brief Set default CameraActor specified in the each scene format specification.
\r
113 * Default input values are derived from glTF default camera format.
\r
114 * with Dali::Camera::Type = Dali::Camera::LOOK_AT_TARGET,
\r
115 * near clipping plane = 0.1,
\r
116 * and camera position = Vector3( 0.0, 0.0, 0.0 ).
\r
118 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
121 * @brief Add CameraActor loaded from scene format file.
\r
123 void AddCamera( CameraActor cameraActor );
\r
126 * @brief Add Animation loaded from scene format file.
\r
128 void AddAnimation( Animation animation );
\r
131 * @brief Add new Shader.
\r
132 * Actors can share same Shader if they use same properties.
\r
133 * If a property changes in a shader, then the property of all actors that use the shader change.
\r
135 void AddShader( Shader shader );
\r
138 * @brief Get Root Actor.
\r
143 * @copydoc Dali::Toolkit::Scene3dView::GetDefaultCamera()
\r
145 CameraActor GetDefaultCamera();
\r
148 * @copydoc Dali::Toolkit::Scene3dView::GetCameraCount()
\r
150 uint32_t GetCameraCount();
\r
153 * @copydoc Dali::Toolkit::Scene3dView::GetCamera( uint32_t cameraIndex )
\r
155 CameraActor GetCamera( uint32_t cameraIndex );
\r
158 * @brief Get light type.
\r
160 Toolkit::Scene3dView::LightType GetLightType();
\r
163 * @brief Get light vector.
\r
164 * Return light position when light type is LightType::POINT_LIGHT
\r
165 * Return light direction when light type is LightType::DIRECTIONAL_LIGHT
\r
167 Vector3 GetLightVector();
\r
170 * @brief Get light color.
\r
172 Vector3 GetLightColor();
\r
175 * @brief Get Scaling factor of IBL.
\r
177 Vector4 GetIBLScaleFactor();
\r
180 * @brief Get BRDF Texture.
\r
182 Texture GetBRDFTexture();
\r
185 * @brief Get diffuse cube map texture.
\r
187 Texture GetDiffuseTexture();
\r
190 * @brief Get specular cube map texture.
\r
192 Texture GetSpecularTexture();
\r
196 * @brief Get Cropped image buffer.
\r
197 * For each direction, Offset + faceSize must be width or height or less then them.
\r
199 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
202 * @brief Upload cube map texture.
\r
204 void UploadTextureFace( Texture& texture, Devel::PixelBuffer pixelBuffer, uint32_t faceIndex );
\r
207 * @brief Set diffuse and specular cube map textures.
\r
209 void SetCubeMap( const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 scaleFactor = Vector4( 1.0, 1.0, 1.0, 1.0 ) );
\r
211 virtual void OnInitialize();
\r
215 * @brief Load 2D texture.
\r
216 * @param[in] imageUrl Image URL of the texture.
\r
217 * @param[in] generateMipmaps If generateMipmaps is true, then generate mipmap of this texture.
\r
218 * @return Texture loaded from imageUrl.
\r
220 Texture LoadTexture( const char *imageUrl, bool generateMipmaps );
\r
223 Actor mRoot; // Root actor that contains scene graph
\r
224 std::string mFilePath; // Full file path of scene file
\r
226 std::vector<Shader> mShaderArray; // Shader Array to change properties of scene such as lighting.
\r
228 std::vector<CameraActor> mCameraActorArray; // CameraActer array loaded from scene format file.
\r
229 CameraActor mDefaultCamera; // Default CameraActor for the empty mCameraActorArray.
\r
231 std::vector<Animation> mAnimationArray; // Animation array loaded from scene format file.
\r
233 Toolkit::Scene3dView::LightType mLightType; // Light type
\r
234 Vector3 mLightVector; // Light position when mLightType is LightType::POINT_LIGHT
\r
235 // Light direction when mLightType is LightType::DIRECTIONAL_LIGHT
\r
236 Vector3 mLightColor; // Light color
\r
238 Vector4 mIBLScaleFactor; // IBL scaling factor for the IBL rendering
\r
239 Texture mBRDFTexture; // BRDF texture for the PBR rendering
\r
240 Texture mSpecularTexture; // Specular cube map texture
\r
241 Texture mDiffuseTexture; // Diffuse cube map texture
\r
245 // Undefined copy constructor.
\r
246 Scene3dView( const Scene3dView& );
\r
248 // Undefined assignment operator.
\r
249 Scene3dView& operator=( const Scene3dView& );
\r
252 } // namespace Internal
\r
254 // Helpers for public-api forwarding methods
\r
255 inline const Internal::Scene3dView& GetImpl( const Toolkit::Scene3dView& scene3dView )
\r
257 DALI_ASSERT_ALWAYS( scene3dView && "Scene3dView handle is empty" );
\r
258 const Dali::RefObject& handle = scene3dView.GetImplementation();
\r
260 return static_cast<const Toolkit::Internal::Scene3dView&>( handle );
\r
263 inline Internal::Scene3dView& GetImpl( Toolkit::Scene3dView& scene3dView )
\r
265 DALI_ASSERT_ALWAYS( scene3dView && "Scene3dView handle is empty" );
\r
267 Dali::RefObject& handle = scene3dView.GetImplementation();
\r
269 return static_cast<Toolkit::Internal::Scene3dView&>( handle );
\r
272 }//namespace Toolkit
\r
276 #endif // DALI_TOOLKIT_INTERNAL_SCENE3D_VIEW_H
\r