1 #ifndef __DALI_ANIMATABLE_MESH__H__
2 #define __DALI_ANIMATABLE_MESH__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.
22 * @addtogroup CAPI_DALI_GEOMETRY_MODULE
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/object/constrainable.h>
29 #include <dali/public-api/geometry/animatable-vertex.h>
30 #include <dali/public-api/modeling/material.h>
32 namespace Dali DALI_IMPORT_API
34 class AnimatableVertex;
36 namespace Internal DALI_INTERNAL
42 * @brief An animatable mesh can have any of its vertices animated using Dali's animation and
45 * It is recommended that the vertices of the mesh remain in the bounds -0.5 - 0.5, which
46 * will match the actor size boundaries. The origin of the mesh matches the actor's position.
48 class AnimatableMesh : public Constrainable
52 * @brief Vector of face indices.
54 typedef std::vector<unsigned short> Faces;
55 typedef Faces::iterator FacesIter; ///< Iterator for Dali::AnimatableMesh::Faces
56 typedef Faces::const_iterator FacesConstIter; ///< Const Iterator for Dali::AnimatableMesh::Faces
59 * @brief Create an uninitialized handle, this can be initialized with New().
61 * Calling member functions on an uninitialized handle will result
67 * @brief Create a new animatable mesh with a given number of vertices and triangles.
69 * This will assert if any index is out of range.
70 * Using this constructor enables the vertex color property.
71 * AnimatableMesh does not take ownership of the faceIndices.
72 * @param[in] numVertices The number of vertices in the mesh
73 * @param[in] faceIndices A set of vertex indices, 3 per face.
74 * @return an initialized handle to the animatable mesh
75 * @note The maximum number of supported vertices is 3333333.
77 static AnimatableMesh New( unsigned int numVertices,
78 const Faces& faceIndices );
81 * @brief Create a new animatable mesh with a given number of vertices and triangles.
83 * This will assert if any index is out of range.
84 * Using this constructor disables the vertex color property.
85 * AnimatableMesh does not take ownership of the faceIndices.
86 * @param[in] numVertices The number of vertices in the mesh
87 * @param[in] faceIndices A set of vertex indices, 3 per face.
88 * @param[in] material Material used to render mesh
89 * @return an initialized handle to the animatable mesh
90 * @note The maximum number of supported vertices is 3333333.
92 static AnimatableMesh New( unsigned int numVertices,
93 const Faces& faceIndices,
94 Dali::Material material );
97 * @brief Downcast an Object handle to AnimatableMesh.
99 * If the handle points to an AnimatableMesh objec, the downcast
100 * produces a valid handle. If not, the handle is left
103 * @param[in] handle to an Object
104 * @return handle to an AnimatableMesh or an uninitialized handle
106 static AnimatableMesh DownCast( BaseHandle handle );
111 virtual ~AnimatableMesh();
114 * @brief Get the number of vertices with which this mesh was created.
116 * @return number of vertices in this mesh
118 unsigned int GetNumberOfVertices() const;
121 * @copydoc Dali::BaseHandle::operator=
123 using BaseHandle::operator=;
126 * @brief Array subscript operator overload.
128 * @pre The vertex index is in range
129 * @param[in] index subscript
130 * @return the vertex at the given index
132 AnimatableVertex operator[]( unsigned int index ) const;
135 * @brief Get a property index for a given vertex.
137 * @pre The vertex index and property is in range
138 * @param[in] vertex The vertex
139 * @param[in] property The vertex attribute
140 * @return A property index for use in constraints or animations
142 Property::Index GetPropertyIndex( unsigned int vertex, Property::Index property) const;
145 * @brief Get the property for a given vertex.
147 * @pre The vertex index and property is in range
148 * @param[in] vertex The vertex
149 * @param[in] property The vertex attribute
150 * @return A property index for use in constraints or animations
152 Property GetVertexProperty( unsigned int vertex, Property::Index property );
154 public: // Not for use by application developer
157 * @brief This constructor is used by Dali New() methods
159 * @param [in] mesh A pointer to a newly allocated Dali resource
161 explicit DALI_INTERNAL AnimatableMesh(Internal::AnimatableMesh* mesh);