(TapGesture) Added min/max taps, removed touches as it's unsupported
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / mesh-actor-impl.h
1 #ifndef __DALI_INTERNAL_MESH_ACTOR_H__
2 #define __DALI_INTERNAL_MESH_ACTOR_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 // EXTERNAL INCLUDES
22 #include <cstddef>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/actors/mesh-actor.h>
27 #include <dali/public-api/geometry/mesh.h>
28 #include <dali/internal/event/actors/actor-impl.h>
29 #include <dali/internal/event/actors/actor-declarations.h>
30 #include <dali/internal/event/modeling/material-impl.h>
31 #include <dali/internal/event/actor-attachments/mesh-attachment-impl.h>
32 #include <dali/internal/event/actors/renderable-actor-impl.h>
33
34 namespace Dali
35 {
36 class Mesh;
37
38
39 namespace Internal
40 {
41
42 class MeshActor : public RenderableActor
43 {
44 public:
45
46   /**
47    * Create an un-intialised mesh actor
48    * @return A smart-pointer to a newly allocated mesh actor
49    */
50   static MeshActorPtr New();
51
52   /**
53    * Create an intialised mesh actor from the given mesh
54    * @param[in] mesh An object containing mesh data
55    * @return A smart-pointer to a newly allocated mesh actor
56    */
57   static MeshActorPtr New(Dali::Mesh mesh);
58
59     /**
60    * Create an intialised mesh actor from the given mesh
61    * @param[in] mesh An object containing mesh data
62    * @return A smart-pointer to a newly allocated mesh actor
63    */
64   static MeshActorPtr New(Dali::AnimatableMesh mesh);
65
66 public:
67
68   /**
69    * Add a mesh to this actor.
70    * @param[in] mesh A mesh structure
71    */
72   void SetMesh(Dali::Mesh mesh);
73
74   /**
75    * Add an animated mesh to this actor
76    * @param[in] mesh An animatable mesh
77    */
78   void SetMesh(Dali::AnimatableMesh mesh);
79
80   /**
81    * Add a mesh resource to this actor
82    * @param[in] mesh A mesh resource
83    */
84   void SetMesh(MeshIPtr meshPtr);
85
86   /**
87    * @copydoc Dali::MeshActor::SetMaterial(Material material)
88    */
89   void SetMaterial(const Dali::Material material);
90
91   /**
92    * Get a material for a given mesh.
93    * @return The material
94    */
95   Dali::Material GetMaterial() const;
96
97   /**
98    * Search the actor tree for all named bones in the mesh array and connect them.
99    * @param[in] rootActor - the root actor of the actor tree.
100    */
101   void BindBonesToMesh(Internal::ActorPtr rootActor);
102
103 private: // From RenderableActor
104
105   /**
106    * @copydoc RenderableActor::GetRenderableAttachment
107    */
108   virtual RenderableAttachment& GetRenderableAttachment() const
109   {
110     DALI_ASSERT_DEBUG( mMeshAttachment );
111     return *mMeshAttachment;
112   }
113
114 protected:
115   /**
116    * Protected constructor; see also MeshActor::New()
117    */
118   MeshActor();
119
120   /**
121    * A reference counted object may only be deleted by calling Unreference()
122    */
123   virtual ~MeshActor();
124
125 private:
126   Internal::MeshAttachmentPtr mMeshAttachment;
127   // To keep a reference to the AnimatableMesh so it would not be destroyed before the MeshActor object
128   Dali::Handle                mAnimatableMeshHandle;
129 };
130
131 } // namespace Internal
132
133 // Helpers for public-api forwarding methods
134
135 inline Internal::MeshActor& GetImplementation(Dali::MeshActor& meshActor)
136 {
137   DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
138
139   BaseObject& handle = meshActor.GetBaseObject();
140
141   return static_cast<Internal::MeshActor&>(handle);
142 }
143
144 inline const Internal::MeshActor& GetImplementation(const Dali::MeshActor& meshActor)
145 {
146   DALI_ASSERT_ALWAYS( meshActor && "MeshActor handle is empty" );
147
148   const BaseObject& handle = meshActor.GetBaseObject();
149
150   return static_cast<const Internal::MeshActor&>(handle);
151 }
152
153 } // namespace Internal
154
155 #endif // __DALI_INTERNAL_MESH_ACTOR_H__