Revert "[Tizen] Modify codes for Dali Windows backend"
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / scene / scene.h
1 #ifndef DALI_TOOLKIT_SCENE_H\r
2 #define DALI_TOOLKIT_SCENE_H\r
3 \r
4 /*\r
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
6  *\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
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\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
18  *\r
19  */\r
20 \r
21 // INTERNAL INCLUDES\r
22 #include <dali/public-api/actors/camera-actor.h>\r
23 #include <dali-toolkit/public-api/controls/control.h>\r
24 #include <dali/public-api/rendering/texture.h>\r
25 \r
26 namespace Dali\r
27 {\r
28 \r
29 namespace Toolkit\r
30 {\r
31 \r
32 namespace Internal DALI_INTERNAL\r
33 {\r
34 \r
35 /**\r
36  * Scene implementation class\r
37  */\r
38 class Scene;\r
39 \r
40 }\r
41 \r
42 /**\r
43  *\r
44  * Scene is a class for containing scene elements loaded from scene format file(e.g., glTF). Scene elements mean scene graph, cameras, and animations.\r
45  *\r
46  * Basic idea:-\r
47  *\r
48  * 1) The Scene is initialized with diffuse and specular cube map for the Image Based Lighting.\n\r
49  *    If the Scene initialized without cube map, the objects of the Scene cannot be rendered with IBL.\n\r
50  * 2) The Scene is loaded from each scene format file(e.g., glTF).\n\r
51  * 3) The Scene can have a point light or a directional light.(optional)\n\r
52  * 4) The Scene playes each actor's animation.\n\r
53  *\r
54  *\r
55  * Usage example: -\r
56  *\r
57  * @code\r
58  *\r
59  * void SceneExample::Create( Application& application )\r
60  * {\r
61  *   // Use 'Scene::New( URL_SCENE_FILE )', if you don't want to render with IBL.\r
62  *   Scene scene = Scene::New( URL_SCENE_FILE, URL_DIFFUSE_TEXTURE, URL_SPECULAR_TEXTURE );\r
63  *\r
64  *   Stage::GetCurrent().Add( scene );\r
65  *   scene.PlayAnimations();\r
66  *\r
67  *   scene.SetLight( Scene::LightType::DIRECTIONAL_LIGHT, Vector3( 1.0, 1.0, -1.0 ), Vector3( 0.3, 0.3, 0.3 ) );\r
68  * }\r
69  *\r
70  * @endcode\r
71  *\r
72  * @remarks This control makes 3D Layer internally. Therefore, if any 2D UI\r
73  * control is added as a child of this Scene, the functionality of the 2D UI\r
74  * may not work well.\r
75  */\r
76 \r
77 class DALI_TOOLKIT_API Scene : public Control\r
78 {\r
79 public:\r
80 \r
81   enum LightType\r
82   {\r
83     // Scene doesn't use both of point and directional light\r
84     NONE = 0,\r
85     // Scene use point light\r
86     POINT_LIGHT,\r
87     // Scene use directional light\r
88     DIRECTIONAL_LIGHT,\r
89     // Scene use Image Based Lighting\r
90     IMAGE_BASED_LIGHT,\r
91     // Scene use Image Based Lighting and point light\r
92     IMAGE_BASED_LIGHT_AND_POINT_LIGHT,\r
93     // Scene use Image Based Lighting and directional light\r
94     IMAGE_BASED_LIGHT_AND_DIRECTIONAL_LIGHT\r
95   };\r
96 \r
97   /**\r
98    * @brief Create an uninitialized Scene; this can be initialized with Scene::New()\r
99    * Calling member functions with an uninitialized Dali::Object is not allowed.\r
100    */\r
101   Scene();\r
102 \r
103   /**\r
104    * @brief Copy constructor. Creates another handle that points to the same real object\r
105    */\r
106   Scene( const Scene& handle );\r
107 \r
108   /**\r
109    * @brief Assignment operator. Changes this handle to point to another real object\r
110    */\r
111   Scene& operator=( const Scene& handle );\r
112 \r
113   /**\r
114    * @brief Destructor\r
115    * This is non-virtual since derived Handle types must not contain data or virtual methods.\r
116    */\r
117   ~Scene();\r
118 \r
119   /**\r
120    * @brief Downcast an Object handle to Scene. If handle points to a Scene the\r
121    * downcast produces valid handle. If not the returned handle is left uninitialized.\r
122    * @param[in] handle Handle to an object\r
123    * @return handle to a Scene or an uninitialized handle\r
124    */\r
125   static Scene DownCast( BaseHandle handle );\r
126 \r
127   /**\r
128    * @brief Create an initialized Scene.\r
129    * @param[in] filePath File path of scene format file (e.g., glTF).\r
130    * @return A handle to a newly allocated Dali resource\r
131    */\r
132   static Scene New( const std::string& filePath );\r
133 \r
134   /**\r
135    * @brief Create an initialized Scene.\r
136    * @param[in] filePath File path of scene format file (e.g., glTF).\r
137    * @param[in] diffuseTexturePath The texture path of diffuse cube map that used to render with Image Based Lighting.\r
138    * @param[in] specularTexturePath The texture path of specular cube map that used to render with Image Based Lighting.\r
139    * @param[in] ScaleFactor Scaling factor for the Image Based Lighting. Default value is initialized with Vector4( 1.0, 1.0, 1.0, 1.0 ).\r
140    * @return A handle to a newly allocated Dali resource\r
141    */\r
142   static Scene New( const std::string& filePath, const std::string& diffuseTexturePath, const std::string& specularTexturePath, Vector4 ScaleFactor = Vector4( 1.0, 1.0, 1.0, 1.0 ) );\r
143 \r
144   /**\r
145    * @brief Get animation count.\r
146    * @return number of animations.\r
147    */\r
148   uint32_t GetAnimationCount();\r
149 \r
150   /**\r
151    * @brief Play an animations.\r
152    * @param[in] index Animation index\r
153    * @return true if animation is played.\r
154    */\r
155   bool PlayAnimation( uint32_t index );\r
156 \r
157   /**\r
158    * @brief Play all animations.\r
159    * @return true if animations are played.\r
160    */\r
161   bool PlayAnimations();\r
162 \r
163   /**\r
164    * @brief Set point light or directional light. If SetLight is not called, this scene doesn't use these kind of light.\r
165    * @param[in] type The light type. If the light is point light set this LightType::POINT_LIGHT,\r
166    * or if the light is directional light set this LightType::DIRECTIONAL_LIGHT.\r
167    * @param[in] lightVector The point light position when light type is LightType::POINT_LIGHT.\r
168    * The light direction when light type is LightType::DIRECTIONAL_LIGHT.\r
169    * @param[in] lightColor Vector3 value that denotes the light color of point light or directional light. Since this is the light color, we don't need to use alpha value.\r
170    * @return true if point light or directional light is set.\r
171    */\r
172   bool SetLight( LightType type, Vector3 lightVector, Vector3 lightColor = Vector3( 1.0, 1.0, 1.0 ) );\r
173 \r
174   /**\r
175    * @brief Get default CameraActor. Dali::Camera::Type = Dali::Camera::LOOK_AT_TARGET , near clipping plane = 0.1, and camera position = Vector3( 0.0, 0.0, 0.0 ).\r
176    * @return CameraActor.\r
177    */\r
178   CameraActor GetDefaultCamera();\r
179 \r
180   /**\r
181    * @brief Get CameraActor. If there is no CameraActor in the list, then returns default CameraActor.\r
182    * @return CameraActor.\r
183    */\r
184   CameraActor GetCamera( int cameraIndex = -1 );\r
185 \r
186   // Not intended for developer use\r
187 public:\r
188 \r
189   /**\r
190    * @brief Creates a handle using the Toolkit::Internal implementation.\r
191    * @param[in]  implementation  The UI Control implementation.\r
192    */\r
193   DALI_INTERNAL Scene( Toolkit::Internal::Scene& implementation );\r
194 \r
195   explicit DALI_INTERNAL Scene( Dali::Internal::CustomActor* internal );\r
196 };\r
197 \r
198 } // namespace Toolkit\r
199 \r
200 } // namespace Dali\r
201 \r
202 #endif // DALI_TOOLKIT_SCENE_H\r