1 #ifndef __DALI_MODEL_DATA_H__
2 #define __DALI_MODEL_DATA_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <dali/public-api/modeling/model-animation-map.h>
27 #include <dali/public-api/object/base-handle.h>
29 namespace Dali DALI_IMPORT_API
37 namespace Internal DALI_INTERNAL
43 * @brief Encapsulates a Dali 3D model/scene.
45 * This is usually generated by an external model loader (and is also
46 * used internally with the default model loader).
48 class ModelData : public BaseHandle
53 * @brief Constructs an uninitialized handle.
58 * @brief Create an initialized ModelData.
60 * @param[in] name The name of the model.
61 * @return A handle to a newly allocated Dali resource.
63 static ModelData New(const std::string& name);
66 * @brief Downcast an Object handle to ModelData handle.
68 * If handle points to a ModelData object the downcast produces
69 * valid handle. If not the returned handle is left uninitialized.
71 * @param[in] handle to An object
72 * @return handle to a ModelData object or an uninitialized handle
74 static ModelData DownCast( BaseHandle handle );
79 * This is non-virtual since derived Handle types must not contain data or virtual methods.
84 * @brief This copy constructor is required for (smart) pointer semantics.
86 * @param [in] handle A reference to the copied handle
88 ModelData(const ModelData& handle);
91 * @brief This assignment operator is required for (smart) pointer semantics.
93 * @param [in] rhs A reference to the copied handle
94 * @return A reference to this
96 ModelData& operator=(const ModelData& rhs);
99 * @brief This method is defined to allow assignment of the NULL value,
100 * and will throw an exception if passed any other value.
102 * Assigning to NULL is an alias for Reset().
103 * @param [in] rhs A NULL pointer
104 * @return A reference to this handle
106 ModelData& operator=(BaseHandle::NullType* rhs);
109 * @brief Returns the name of the model.
111 * @return The model name
113 const std::string& GetName() const;
116 * @brief Set the root Entity of the model.
118 * @param root A handle to the root entity
120 void SetRootEntity(Entity root);
123 * @brief Get the root Entity of the model.
125 * @return The root entity
127 Entity GetRootEntity() const;
130 * @brief Add a mesh to the model.
132 * @param mesh The mesh data to add.
134 void AddMesh(MeshData& mesh);
137 * @brief Get a mesh by index.
139 * @param[in] index The zero based index to a mesh
142 const MeshData& GetMesh(unsigned int index) const;
145 * @brief Get a mesh by index.
147 * @param[in] index The zero based index to a mesh
150 MeshData& GetMesh(unsigned int index);
153 * @brief Get Mesh count.
155 * @returns number of meshes
157 unsigned int NumberOfMeshes() const;
160 * @brief Add material to the model.
162 * @param[in] material - the material to add to the model
164 void AddMaterial(Material material);
167 * @brief Get a material by index.
169 * @param[in] index The index to a material
170 * @return A handle to a material, or NULL.
172 Material GetMaterial(unsigned int index) const;
175 * @brief Get material count.
177 * @return The Number of materials
179 unsigned int NumberOfMaterials() const;
182 * @brief Get animation map container.
184 * @return reference to the animation map container.
186 ModelAnimationMapContainer& GetAnimationMapContainer();
189 * @brief Find the index for the given animation name.
191 * @param[in] name The name of the animation map to search for.
192 * @param[out] index The index of the found map
193 * @return true if the name was found, false otherwise.
195 bool FindAnimation (const std::string& name, unsigned int& index) const;
198 * @return the number of animations defined for this model
200 unsigned int NumberOfAnimationMaps() const;
203 * @brief Add a light to the model.
205 * @param light - the light to add to the model
207 void AddLight(Light light);
210 * @brief Get a light by index.
212 * @param[in] index The zero based index to a light
213 * @return A pointer to a light, or NULL.
215 Light GetLight(unsigned int index) const;
218 * @brief Get the number of lights contained in the model.
220 * @return The number of lights contained in the model.
222 unsigned int NumberOfLights() const;
225 * @brief Read the model data from an open streambuf.
227 * @param[in] buf A streambuf opened for reading
228 * @return true if data was read successfully.
230 bool Read(std::streambuf& buf);
233 * @brief Write the model data to an open streambuf.
235 * @param[in] buf A streambuf opened for writing
236 * @return true if data was written successfully.
238 bool Write(std::streambuf& buf) const;
240 public: // Not intended for application developers
242 * @brief This constructor is used by Dali New() methods.
244 * @param[in] modelData A pointer to a newly allocated modelData
246 explicit DALI_INTERNAL ModelData(Internal::ModelData* modelData);
248 }; // Class ModelData
252 #endif // __DALI_MODEL_DATA_H__