1 #ifndef __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_H__
2 #define __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_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.
21 #include <dali/public-api/object/ref-object.h>
22 #include <dali/public-api/geometry/animatable-mesh.h>
23 #include <dali/internal/event/common/proxy-object.h>
24 #include <dali/internal/event/modeling/modeling-declarations.h>
31 typedef IntrusivePtr<AnimatableMesh> AnimatableMeshPtr;
40 class AnimatableMesh : public ProxyObject
45 * @param[in] updateManager
46 * @param[in] sceneObject - pointer to a newly created scene object
47 * @param[in] mesh - pointer to a newly created Mesh object
48 * @param[in] numberOfVertices - The number of vertices to create
50 AnimatableMesh( SceneGraph::UpdateManager& updateManager,
51 SceneGraph::AnimatableMesh* sceneObject,
53 int numberOfVertices );
56 * Construct an animated mesh. Uses vertex color
58 static AnimatableMeshPtr New( unsigned int numVertices,
59 const Dali::AnimatableMesh::Faces& faceIndices );
62 * Construct an animated mesh. Uses material
64 static AnimatableMeshPtr New( unsigned int numVertices,
65 const Dali::AnimatableMesh::Faces& faceIndices,
66 Dali::Material material);
69 * Catch-all constructor. Performs all checks on input data
71 static AnimatableMeshPtr New( unsigned int numVertices,
72 const Dali::AnimatableMesh::Faces& faceIndices,
73 Dali::Material material,
82 * Return the number of vertices in the mesh
83 * @return vertexNumber
85 unsigned int GetNumberOfVertices() const;
88 * Get the property index from the vertex index and the vertex property enumeration
90 using ProxyObject::GetPropertyIndex;
91 Property::Index GetPropertyIndex( unsigned int vertex, Property::Index property ) const;
94 * Set the given vertex position
96 void SetPosition( unsigned int vertexIndex, const Vector3& position);
99 * Set the given vertex color. Note, alpha is ignored with current internal vertex format
101 void SetColor( unsigned int vertexIndex, const Vector4& color);
104 * Set the given texture coords.
106 void SetTextureCoords( unsigned int vertexIndex, const Vector2& coords);
109 * Get the current position of the vertex
111 const Vector3& GetCurrentPosition( unsigned int vertexIndex) const;
114 * Get the current color of the vertex
116 const Vector4& GetCurrentColor( unsigned int vertexIndex) const;
119 * Get the current texture coord of the vertex
121 const Vector2& GetCurrentTextureCoords( unsigned int vertexIndex) const;
124 * Set whether the mesh should use the vertex color property or not.
125 * If it uses the vertex colors, then the material is not used for rendering.
127 void SetUseColor(bool color);
130 * Get whether the mesh should use the color property or not
131 * @return true if the mesh is using vertex colors
136 * Set whether the mesh should use the vertex TextureCoords property or not.
137 * If it uses the vertex TextureCoords, then the material is not used for rendering.
139 void SetUseTextureCoords(bool TextureCoords);
142 * Get whether the mesh should use the TextureCoords property or not
143 * @return true if the mesh is using vertex texture coords
145 bool GetUseTextureCoords();
148 // Intended for internal use only.
151 public: // Implementation of ProxyObject
153 * @copydoc Dali::Internal::ProxyObject::Supports()
155 virtual bool Supports( Capability capability ) const;
158 * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
160 virtual bool IsSceneObjectRemovable() const;
163 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
165 virtual unsigned int GetDefaultPropertyCount() const;
168 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
170 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
173 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
175 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
178 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
180 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
183 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
185 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
188 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
190 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
193 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
195 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
198 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
200 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
203 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
205 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
208 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
210 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
213 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
215 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
218 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
220 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
223 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
225 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
228 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
230 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
233 AnimatableMesh( const AnimatableMesh& );
234 AnimatableMesh operator=(const AnimatableMesh& rhs);
237 SceneGraph::UpdateManager& mUpdateManager; ///< The update manager
238 SceneGraph::AnimatableMesh* mSceneObject; ///< The mesh property owner
239 MeshIPtr mMesh; ///< The mesh ticket holder
241 unsigned int mNumberOfVertices;
244 // Default properties
245 typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
246 static DefaultPropertyLookup* mDefaultPropertyLookup;
251 inline Internal::AnimatableMesh& GetImplementation(Dali::AnimatableMesh& animatableMesh)
253 DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
254 BaseObject& handle = animatableMesh.GetBaseObject();
255 return static_cast<Internal::AnimatableMesh&>(handle);
258 inline const Internal::AnimatableMesh& GetImplementation(const Dali::AnimatableMesh& animatableMesh)
260 DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
261 const BaseObject& handle = animatableMesh.GetBaseObject();
262 return static_cast<const Internal::AnimatableMesh&>(handle);