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 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/object/ref-object.h>
23 #include <dali/public-api/geometry/animatable-mesh.h>
24 #include <dali/internal/event/common/proxy-object.h>
25 #include <dali/internal/event/modeling/modeling-declarations.h>
32 typedef IntrusivePtr<AnimatableMesh> AnimatableMeshPtr;
41 class AnimatableMesh : public ProxyObject
46 * @param[in] updateManager
47 * @param[in] sceneObject - pointer to a newly created scene object
48 * @param[in] mesh - pointer to a newly created Mesh object
49 * @param[in] numberOfVertices - The number of vertices to create
51 AnimatableMesh( SceneGraph::UpdateManager& updateManager,
52 SceneGraph::AnimatableMesh* sceneObject,
54 int numberOfVertices );
57 * Construct an animated mesh. Uses vertex color
59 static AnimatableMeshPtr New( unsigned int numVertices,
60 const Dali::AnimatableMesh::Faces& faceIndices );
63 * Construct an animated mesh. Uses material
65 static AnimatableMeshPtr New( unsigned int numVertices,
66 const Dali::AnimatableMesh::Faces& faceIndices,
67 Dali::Material material);
70 * Catch-all constructor. Performs all checks on input data
72 static AnimatableMeshPtr New( unsigned int numVertices,
73 const Dali::AnimatableMesh::Faces& faceIndices,
74 Dali::Material material,
83 * Return the number of vertices in the mesh
84 * @return vertexNumber
86 unsigned int GetNumberOfVertices() const;
89 * Get the property index from the vertex index and the vertex property enumeration
91 Property::Index GetVertexPropertyIndex( 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::GetDefaultPropertyCount()
160 virtual unsigned int GetDefaultPropertyCount() const;
163 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
165 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
168 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
170 virtual const char* GetDefaultPropertyName(Property::Index index) const;
173 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
175 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
178 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
180 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
183 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
185 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
188 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
190 virtual bool IsDefaultPropertyAConstraintInput( 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;
248 inline Internal::AnimatableMesh& GetImplementation(Dali::AnimatableMesh& animatableMesh)
250 DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
251 BaseObject& handle = animatableMesh.GetBaseObject();
252 return static_cast<Internal::AnimatableMesh&>(handle);
255 inline const Internal::AnimatableMesh& GetImplementation(const Dali::AnimatableMesh& animatableMesh)
257 DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
258 const BaseObject& handle = animatableMesh.GetBaseObject();
259 return static_cast<const Internal::AnimatableMesh&>(handle);