1 #ifndef __DALI_MODEL_DATA_H__
2 #define __DALI_MODEL_DATA_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
25 #include <dali/public-api/modeling/model-animation-map.h>
26 #include <dali/public-api/object/base-handle.h>
28 namespace Dali DALI_IMPORT_API
36 namespace Internal DALI_INTERNAL
42 * @brief Encapsulates a Dali 3D model/scene.
44 * This is usually generated by an external model loader (and is also
45 * used internally with the default model loader).
47 class ModelData : public BaseHandle
52 * @brief Constructs an uninitialized handle.
57 * @brief Create an initialized ModelData.
59 * @param[in] name The name of the model.
60 * @return A handle to a newly allocated Dali resource.
62 static ModelData New(const std::string& name);
65 * @brief Downcast an Object handle to ModelData handle.
67 * If handle points to a ModelData object the downcast produces
68 * valid handle. If not the returned handle is left uninitialized.
70 * @param[in] handle to An object
71 * @return handle to a ModelData object or an uninitialized handle
73 static ModelData DownCast( BaseHandle handle );
76 * @brief Virtual destructor.
78 * Dali::Object derived classes typically do not contain member data.
83 * @copydoc Dali::BaseHandle::operator=
85 using BaseHandle::operator=;
88 * @brief Returns the name of the model.
90 * @return The model name
92 const std::string& GetName() const;
95 * @brief Set the root Entity of the model.
97 * @param root A handle to the root entity
99 void SetRootEntity(Entity root);
102 * @brief Get the root Entity of the model.
104 * @return The root entity
106 Entity GetRootEntity() const;
109 * @brief Add a mesh to the model.
111 * @param mesh The mesh data to add.
113 void AddMesh(MeshData& mesh);
116 * @brief Get a mesh by index.
118 * @param[in] index The zero based index to a mesh
121 const MeshData& GetMesh(unsigned int index) const;
124 * @brief Get a mesh by index.
126 * @param[in] index The zero based index to a mesh
129 MeshData& GetMesh(unsigned int index);
132 * @brief Get Mesh count.
134 * @returns number of meshes
136 unsigned int NumberOfMeshes() const;
139 * @brief Add material to the model.
141 * @param[in] material - the material to add to the model
143 void AddMaterial(Material material);
146 * @brief Get a material by index.
148 * @param[in] index The index to a material
149 * @return A handle to a material, or NULL.
151 Material GetMaterial(unsigned int index) const;
154 * @brief Get material count.
156 * @return The Number of materials
158 unsigned int NumberOfMaterials() const;
161 * @brief Get animation map container.
163 * @return reference to the animation map container.
165 ModelAnimationMapContainer& GetAnimationMapContainer();
168 * @brief Get an animation map from the model data.
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.
174 const ModelAnimationMap* GetAnimationMap (unsigned int index) const;
177 * @brief Get the animation for the given name.
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.
183 const ModelAnimationMap* GetAnimationMap (const std::string& name) const;
186 * @brief Find the index for the given animation name.
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.
192 bool FindAnimation (const std::string& name, unsigned int& index) const;
195 * @return the number of animations defined for this model
197 unsigned int NumberOfAnimationMaps() const;
200 * @brief Add a light to the model.
202 * @param light - the light to add to the model
204 void AddLight(Light light);
207 * @brief Get a light by index.
209 * @param[in] index The zero based index to a light
210 * @return A pointer to a light, or NULL.
212 Light GetLight(unsigned int index) const;
215 * @brief Get the number of lights contained in the model.
217 * @return The number of lights contained in the model.
219 unsigned int NumberOfLights() const;
222 * @brief Read the model data from an open streambuf.
224 * @param[in] buf A streambuf opened for reading
225 * @return true if data was read successfully.
227 bool Read(std::streambuf& buf);
230 * @brief Write the model data to an open streambuf.
232 * @param[in] buf A streambuf opened for writing
233 * @return true if data was written successfully.
235 bool Write(std::streambuf& buf) const;
237 public: // Not intended for application developers
239 * @brief This constructor is used by Dali New() methods.
241 * @param[in] modelData A pointer to a newly allocated modelData
243 explicit DALI_INTERNAL ModelData(Internal::ModelData* modelData);
245 }; // Class ModelData
249 #endif // __DALI_MODEL_DATA_H__