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