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 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/object/constrainable.h>
24 #include <dali/public-api/geometry/animatable-vertex.h>
25 #include <dali/public-api/modeling/material.h>
29 class AnimatableVertex;
31 namespace Internal DALI_INTERNAL
37 * @brief An animatable mesh can have any of its vertices animated using Dali's animation and
40 * It is recommended that the vertices of the mesh remain in the bounds -0.5 - 0.5, which
41 * will match the actor size boundaries. The origin of the mesh matches the actor's position.
43 class DALI_IMPORT_API AnimatableMesh : public Constrainable
47 * @brief Vector of face indices.
49 typedef std::vector<unsigned short> Faces;
50 typedef Faces::iterator FacesIter; ///< Iterator for Dali::AnimatableMesh::Faces
51 typedef Faces::const_iterator FacesConstIter; ///< Const Iterator for Dali::AnimatableMesh::Faces
54 * @brief Create an uninitialized handle, this can be initialized with New().
56 * Calling member functions on an uninitialized handle will result
62 * @brief Create a new animatable mesh with a given number of vertices and triangles.
64 * This will assert if any index is out of range.
65 * Using this constructor enables the vertex color property.
66 * AnimatableMesh does not take ownership of the faceIndices.
67 * @param[in] numVertices The number of vertices in the mesh
68 * @param[in] faceIndices A set of vertex indices, 3 per face.
69 * @return an initialized handle to the animatable mesh
70 * @note The maximum number of supported vertices is 3333333.
72 static AnimatableMesh New( unsigned int numVertices,
73 const Faces& faceIndices );
76 * @brief Create a new animatable mesh with a given number of vertices and triangles.
78 * This will assert if any index is out of range.
79 * Using this constructor disables the vertex color property.
80 * AnimatableMesh does not take ownership of the faceIndices.
81 * @param[in] numVertices The number of vertices in the mesh
82 * @param[in] faceIndices A set of vertex indices, 3 per face.
83 * @param[in] material Material used to render mesh
84 * @return an initialized handle to the animatable mesh
85 * @note The maximum number of supported vertices is 3333333.
87 static AnimatableMesh New( unsigned int numVertices,
88 const Faces& faceIndices,
89 Dali::Material material );
92 * @brief Downcast an Object handle to AnimatableMesh.
94 * If the handle points to an AnimatableMesh objec, the downcast
95 * produces a valid handle. If not, the handle is left
98 * @param[in] handle to an Object
99 * @return handle to an AnimatableMesh or an uninitialized handle
101 static AnimatableMesh DownCast( BaseHandle handle );
106 * This is non-virtual since derived Handle types must not contain data or virtual methods.
111 * @brief This copy constructor is required for (smart) pointer semantics.
113 * @param [in] handle A reference to the copied handle
115 AnimatableMesh(const AnimatableMesh& handle);
118 * @brief This assignment operator is required for (smart) pointer semantics.
120 * @param [in] rhs A reference to the copied handle
121 * @return A reference to this
123 AnimatableMesh& operator=(const AnimatableMesh& rhs);
126 * @brief Get the number of vertices with which this mesh was created.
128 * @return number of vertices in this mesh
130 unsigned int GetNumberOfVertices() const;
133 * @brief Array subscript operator overload.
135 * @pre The vertex index is in range
136 * @param[in] index subscript
137 * @return the vertex at the given index
139 AnimatableVertex operator[]( unsigned int index ) const;
142 * @brief Get a property index for a given vertex.
144 * @pre The vertex index and property is in range
145 * @param[in] vertex The vertex
146 * @param[in] property The vertex attribute
147 * @return A property index for use in constraints or animations
149 Property::Index GetPropertyIndex( unsigned int vertex, Property::Index property) const;
152 * @brief Get the property for a given vertex.
154 * @pre The vertex index and property is in range
155 * @param[in] vertex The vertex
156 * @param[in] property The vertex attribute
157 * @return A property index for use in constraints or animations
159 Property GetVertexProperty( unsigned int vertex, Property::Index property );
161 public: // Not for use by application developer
164 * @brief This constructor is used by Dali New() methods
166 * @param [in] mesh A pointer to a newly allocated Dali resource
168 explicit DALI_INTERNAL AnimatableMesh(Internal::AnimatableMesh* mesh);