DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-core.git] / dali / public-api / modeling / model-data.h
1 #ifndef __DALI_MODEL_DATA_H__
2 #define __DALI_MODEL_DATA_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21
22 // EXTERNAL INCLUDES
23 #include <string>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/modeling/model-animation-map.h>
27 #include <dali/public-api/object/base-handle.h>
28
29 namespace Dali
30 {
31
32 class Entity;
33 class MeshData;
34 class Material;
35 class Light;
36
37 namespace Internal DALI_INTERNAL
38 {
39 class ModelData;
40 }
41
42 /**
43  * @brief Encapsulates a Dali 3D model/scene.
44  *
45  * This is usually generated by an external model loader (and is also
46  * used internally with the default model loader).
47  */
48 class DALI_IMPORT_API ModelData : public BaseHandle
49 {
50 public:
51
52   /**
53    * @brief Constructs an uninitialized handle.
54    */
55   ModelData();
56
57   /**
58    * @brief Create an initialized ModelData.
59    *
60    * @param[in] name The name of the model.
61    * @return A handle to a newly allocated Dali resource.
62    */
63   static ModelData New(const std::string& name);
64
65   /**
66    * @brief Downcast an Object handle to ModelData handle.
67    *
68    * If handle points to a ModelData object the downcast produces
69    * valid handle. If not the returned handle is left uninitialized.
70    *
71    * @param[in] handle to An object
72    * @return handle to a ModelData object or an uninitialized handle
73    */
74   static ModelData DownCast( BaseHandle handle );
75
76   /**
77    * @brief Destructor
78    *
79    * This is non-virtual since derived Handle types must not contain data or virtual methods.
80    */
81   ~ModelData();
82
83   /**
84    * @brief This copy constructor is required for (smart) pointer semantics.
85    *
86    * @param [in] handle A reference to the copied handle
87    */
88   ModelData(const ModelData& handle);
89
90   /**
91    * @brief This assignment operator is required for (smart) pointer semantics.
92    *
93    * @param [in] rhs  A reference to the copied handle
94    * @return A reference to this
95    */
96   ModelData& operator=(const ModelData& rhs);
97
98   /**
99    * @brief Returns the name of the model.
100    *
101    * @return The model name
102    */
103   const std::string& GetName() const;
104
105   /**
106    * @brief Set the root Entity of the model.
107    *
108    * @param root A handle to the root entity
109    */
110   void SetRootEntity(Entity root);
111
112   /**
113    * @brief Get the root Entity of the model.
114    *
115    * @return The root entity
116    */
117   Entity GetRootEntity() const;
118
119   /**
120    * @brief Add a mesh to the model.
121    *
122    * @param mesh The mesh data to add.
123    */
124   void AddMesh(MeshData& mesh);
125
126   /**
127    * @brief Get a mesh by index.
128    *
129    * @param[in] index The zero based index to a mesh
130    * @return          The mesh.
131    */
132   const MeshData& GetMesh(unsigned int index) const;
133
134   /**
135    * @brief Get a mesh by index.
136    *
137    * @param[in] index The zero based index to a mesh
138    * @return          The mesh.
139    */
140   MeshData& GetMesh(unsigned int index);
141
142   /**
143    * @brief Get Mesh count.
144    *
145    * @returns number of meshes
146    */
147   unsigned int NumberOfMeshes() const;
148
149   /**
150    * @brief Add material to the model.
151    *
152    * @param[in] material - the material to add to the model
153    */
154   void AddMaterial(Material material);
155
156   /**
157    * @brief Get a material by index.
158    *
159    * @param[in] index The index to a material
160    * @return          A handle to a material, or NULL.
161    */
162   Material GetMaterial(unsigned int index) const;
163
164   /**
165    * @brief Get material count.
166    *
167    * @return The Number of materials
168    */
169   unsigned int NumberOfMaterials() const;
170
171   /**
172    * @brief Get animation map container.
173    *
174    * @return reference to the animation map container.
175    */
176    ModelAnimationMapContainer& GetAnimationMapContainer();
177
178   /**
179    * @brief Find the index for the given animation name.
180    *
181    * @param[in] name The name of the animation map to search for.
182    * @param[out] index The index of the found map
183    * @return true if the name was found, false otherwise.
184    */
185   bool FindAnimation (const std::string& name, unsigned int& index) const;
186
187   /**
188    * @return the number of animations defined for this model
189    */
190   unsigned int NumberOfAnimationMaps() const;
191
192   /**
193    * @brief Add a light to the model.
194    *
195    * @param light - the light to add to the model
196    */
197   void AddLight(Light light);
198
199   /**
200    * @brief Get a light by index.
201    *
202    * @param[in] index The zero based index to a light
203    * @return          A pointer to a light, or NULL.
204    */
205   Light GetLight(unsigned int index) const;
206
207   /**
208    * @brief Get the number of lights contained in the model.
209    *
210    * @return The number of lights contained in the model.
211    */
212   unsigned int NumberOfLights() const;
213
214   /**
215    * @brief Read the model data from an open streambuf.
216    *
217    * @param[in] buf A streambuf opened for reading
218    * @return true if data was read successfully.
219    */
220   bool Read(std::streambuf& buf);
221
222   /**
223    * @brief Write the model data to an open streambuf.
224    *
225    * @param[in] buf A streambuf opened for writing
226    * @return true if data was written successfully.
227    */
228   bool Write(std::streambuf& buf) const;
229
230 public: // Not intended for application developers
231   /**
232    * @brief This constructor is used by Dali New() methods.
233    *
234    * @param[in] modelData A pointer to a newly allocated modelData
235    */
236   explicit DALI_INTERNAL ModelData(Internal::ModelData* modelData);
237
238 }; // Class ModelData
239
240 } // namespace Dali
241
242 #endif // __DALI_MODEL_DATA_H__