Emscripten workarounds and llvm syntax fixes
[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 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
10 //
11 //     http://floralicense.org/license/
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 // INTERNAL INCLUDES
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>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class AnimatableMesh;
31 typedef IntrusivePtr<AnimatableMesh> AnimatableMeshPtr;
32
33 namespace SceneGraph
34 {
35 class UpdateManager;
36 class AnimatableMesh;
37 }
38
39
40 class AnimatableMesh : public ProxyObject
41 {
42 public:
43   /**
44    * Constructor
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
49    */
50   AnimatableMesh( SceneGraph::UpdateManager& updateManager,
51                   SceneGraph::AnimatableMesh* sceneObject,
52                   MeshIPtr mesh,
53                   int numberOfVertices );
54
55   /**
56    * Construct an animated mesh. Uses vertex color
57    */
58   static AnimatableMeshPtr New( unsigned int numVertices,
59                                 const Dali::AnimatableMesh::Faces& faceIndices );
60
61   /**
62    * Construct an animated mesh. Uses material
63    */
64   static AnimatableMeshPtr New( unsigned int numVertices,
65                                 const Dali::AnimatableMesh::Faces& faceIndices,
66                                 Dali::Material material);
67
68   /**
69    * Catch-all constructor. Performs all checks on input data
70    */
71   static AnimatableMeshPtr New( unsigned int numVertices,
72                                 const Dali::AnimatableMesh::Faces& faceIndices,
73                                 Dali::Material material,
74                                 bool useColor );
75
76   /**
77    * Destructor
78    */
79   ~AnimatableMesh();
80
81   /**
82    * Return the number of vertices in the mesh
83    * @return vertexNumber
84    */
85   unsigned int GetNumberOfVertices() const;
86
87   /**
88    * Get the property index from the vertex index and the vertex property enumeration
89    */
90   using ProxyObject::GetPropertyIndex;
91   Property::Index GetPropertyIndex( 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 std::string& 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::GetDefaultPropertyType()
194    */
195   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
196
197   /**
198    * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
199    */
200   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
201
202   /**
203    * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
204    */
205   virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
206
207   /**
208    * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
209    */
210   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
211
212   /**
213    * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
214    */
215   virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
216
217   /**
218    * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
219    */
220   virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
221
222   /**
223    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
224    */
225   virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
226
227   /**
228    * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
229    */
230   virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
231
232 private:
233   AnimatableMesh( const AnimatableMesh& );
234   AnimatableMesh operator=(const AnimatableMesh& rhs);
235
236 private:
237   SceneGraph::UpdateManager&  mUpdateManager; ///< The update manager
238   SceneGraph::AnimatableMesh* mSceneObject;   ///< The mesh property owner
239   MeshIPtr                    mMesh;          ///< The mesh ticket holder
240
241   unsigned int mNumberOfVertices;
242   int mPropertyCount;
243
244   // Default properties
245   typedef std::map<std::string, Property::Index> DefaultPropertyLookup;
246   static DefaultPropertyLookup* mDefaultPropertyLookup;
247 };
248
249 }//Internal
250
251 inline Internal::AnimatableMesh& GetImplementation(Dali::AnimatableMesh& animatableMesh)
252 {
253   DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
254   BaseObject& handle = animatableMesh.GetBaseObject();
255   return static_cast<Internal::AnimatableMesh&>(handle);
256 }
257
258 inline const Internal::AnimatableMesh& GetImplementation(const Dali::AnimatableMesh& animatableMesh)
259 {
260   DALI_ASSERT_ALWAYS(animatableMesh && "AnimatableMesh handle is empty");
261   const BaseObject& handle = animatableMesh.GetBaseObject();
262   return static_cast<const Internal::AnimatableMesh&>(handle);
263 }
264
265 }//Dali
266
267 #endif