ecc628933674015b072d5afeafc5c7c5b27b8129
[platform/core/uifw/dali-core.git] / dali / internal / event / modeling / animatable-mesh-impl.h
1 #ifndef __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_H__
2 #define __DALI_INTERNAL_ANIMATABLE_MESH_EFFECT_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 class AnimatableMesh;
32 typedef IntrusivePtr<AnimatableMesh> AnimatableMeshPtr;
33
34 namespace SceneGraph
35 {
36 class UpdateManager;
37 class AnimatableMesh;
38 }
39
40
41 class AnimatableMesh : public ProxyObject
42 {
43 public:
44   /**
45    * Constructor
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
50    */
51   AnimatableMesh( SceneGraph::UpdateManager& updateManager,
52                   SceneGraph::AnimatableMesh* sceneObject,
53                   MeshIPtr mesh,
54                   int numberOfVertices );
55
56   /**
57    * Construct an animated mesh. Uses vertex color
58    */
59   static AnimatableMeshPtr New( unsigned int numVertices,
60                                 const Dali::AnimatableMesh::Faces& faceIndices );
61
62   /**
63    * Construct an animated mesh. Uses material
64    */
65   static AnimatableMeshPtr New( unsigned int numVertices,
66                                 const Dali::AnimatableMesh::Faces& faceIndices,
67                                 Dali::Material material);
68
69   /**
70    * Catch-all constructor. Performs all checks on input data
71    */
72   static AnimatableMeshPtr New( unsigned int numVertices,
73                                 const Dali::AnimatableMesh::Faces& faceIndices,
74                                 Dali::Material material,
75                                 bool useColor );
76
77   /**
78    * Destructor
79    */
80   ~AnimatableMesh();
81
82   /**
83    * Return the number of vertices in the mesh
84    * @return vertexNumber
85    */
86   unsigned int GetNumberOfVertices() const;
87
88   /**
89    * Get the property index from the vertex index and the vertex property enumeration
90    */
91   Property::Index GetVertexPropertyIndex( unsigned int vertex, Property::Index property ) const;
92
93   /**
94    * Set the given vertex position
95    */
96   void SetPosition( unsigned int vertexIndex, const Vector3& position);
97
98   /**
99    * Set the given vertex color. Note, alpha is ignored with current internal vertex format
100    */
101   void SetColor( unsigned int vertexIndex, const Vector4& color);
102
103   /**
104    * Set the given texture coords.
105    */
106   void SetTextureCoords( unsigned int vertexIndex, const Vector2& coords);
107
108   /**
109    * Get the current position of the vertex
110    */
111   const Vector3& GetCurrentPosition( unsigned int vertexIndex) const;
112
113   /**
114    * Get the current color of the vertex
115    */
116   const Vector4& GetCurrentColor( unsigned int vertexIndex) const;
117
118   /**
119    * Get the current texture coord of the vertex
120    */
121   const Vector2& GetCurrentTextureCoords( unsigned int vertexIndex) const;
122
123   /**
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.
126    */
127   void SetUseColor(bool color);
128
129   /**
130    * Get whether the mesh should use the color property or not
131    * @return true if the mesh is using vertex colors
132    */
133   bool GetUseColor();
134
135   /**
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.
138    */
139   void SetUseTextureCoords(bool TextureCoords);
140
141   /**
142    * Get whether the mesh should use the TextureCoords property or not
143    * @return true if the mesh is using vertex texture coords
144    */
145   bool GetUseTextureCoords();
146
147
148   // Intended for internal use only.
149   MeshIPtr GetMesh();
150
151 public: // Implementation of ProxyObject
152   /**
153    * @copydoc Dali::Internal::ProxyObject::Supports()
154    */
155   virtual bool Supports( Capability capability ) const;
156
157   /**
158    * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
159    */
160   virtual bool IsSceneObjectRemovable() const;
161
162   /**
163    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
164    */
165   virtual unsigned int GetDefaultPropertyCount() const;
166
167   /**
168    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
169    */
170   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
171
172   /**
173    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
174    */
175   virtual const char* GetDefaultPropertyName(Property::Index index) const;
176
177   /**
178    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
179    */
180   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
181
182   /**
183    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
184    */
185   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
186
187   /**
188    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
189    */
190   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
191
192   /**
193    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
194    */
195   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
196
197   /**
198    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
199    */
200   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
201
202   /**
203    * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
204    */
205   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
206
207   /**
208    * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
209    */
210   virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
211
212   /**
213    * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
214    */
215   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
216
217   /**
218    * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
219    */
220   virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
221
222   /**
223    * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
224    */
225   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
226
227   /**
228    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
229    */
230   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
231
232   /**
233    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
234    */
235   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
236
237 private:
238   AnimatableMesh( const AnimatableMesh& );
239   AnimatableMesh operator=(const AnimatableMesh& rhs);
240
241 private:
242   SceneGraph::UpdateManager&  mUpdateManager; ///< The update manager
243   SceneGraph::AnimatableMesh* mSceneObject;   ///< The mesh property owner
244   MeshIPtr                    mMesh;          ///< The mesh ticket holder
245
246   unsigned int mNumberOfVertices;
247   int mPropertyCount;
248
249 };
250
251 }//Internal
252
253 inline Internal::AnimatableMesh& GetImplementation(Dali::AnimatableMesh& animatableMesh)
254 {
255   DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
256   BaseObject& handle = animatableMesh.GetBaseObject();
257   return static_cast<Internal::AnimatableMesh&>(handle);
258 }
259
260 inline const Internal::AnimatableMesh& GetImplementation(const Dali::AnimatableMesh& animatableMesh)
261 {
262   DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
263   const BaseObject& handle = animatableMesh.GetBaseObject();
264   return static_cast<const Internal::AnimatableMesh&>(handle);
265 }
266
267 }//Dali
268
269 #endif