Merge "Print line numbers with shader source."
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / model-actor-factory-impl.h
1 #ifndef __DALI_INTERNAL_MODEL_ACTOR_FACTORY_H__
2 #define __DALI_INTERNAL_MODEL_ACTOR_FACTORY_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/modeling/model.h>
22 #include <dali/internal/event/modeling/model-data-impl.h>
23 #include <dali/internal/event/actors/actor-declarations.h>
24 #include <dali/internal/event/animation/animation-impl.h>
25
26 namespace Dali
27 {
28
29 class Model;
30 class Entity;
31
32 namespace Internal
33 {
34
35 /**
36  * This factory class is used to generate a tree of actors and mesh actors.
37  */
38 class ModelActorFactory
39 {
40 public:
41
42   /**
43    * @copydoc Dali::ModelActorFactory::BuildActorTree
44    */
45   static ActorPtr BuildActorTree(Dali::Model& model, const std::string& name);
46
47
48   /**
49    * Create an animation on the actor and child actors using the named animation map.
50    * If the animation map does not exist in the model, then this returns an uninitialised
51    * handle.
52    * @param[in] model A model resource handle
53    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
54    * @param[in] animationName The name of the animation to build
55    * @return A pointer to an animation.
56    */
57   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName);
58
59   /**
60    * Create an animation on the actor and child actors using the named animation map.
61    * If the animation map does not exist in the model, then this returns an uninitialised
62    * handle.
63    * @param[in] model A model resource handle
64    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
65    * @param[in] animationName The name of the animation to build
66    * @param[in] durationSeconds The duration over which to run the animation
67    * @return A pointer to an animation.
68    */
69   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, float durationSeconds);
70
71   /**
72    * Create an animation on the actor and child actors using the named animation map.
73    * If the animation map does not exist in the model, then this returns an uninitialised
74    * handle.
75    * @param[in] model A model resource handle
76    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
77    * @param[in] animationName The name of the animation to build
78    * @param[in] alpha The alpha function to apply to the overall progress
79    * @return A pointer to an animation.
80    */
81   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha);
82
83   /**
84    * Create an animation on the actor and child actors using the named animation map.
85    * If the animation map does not exist in the model, then this returns an uninitialised
86    * handle.
87    * @param[in] model A model resource handle
88    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
89    * @param[in] animationName The name of the animation to build
90    * @param[in] alpha The alpha function to apply to the overall progress
91    * @param[in] durationSeconds The duration over which to run the animation
92    * @return A pointer to an animation.
93    */
94   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha, float durationSeconds);
95
96   /**
97    * Create an animation on the actor and child actors using the indexed animation map.
98    * If the animation map does not exist in the model, then this returns an uninitialised
99    * handle.
100    * @param[in] model A model resource handle
101    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
102    * @param[in] index The index of the animation
103    * @return A handle to an animation, or uninitialised.
104    */
105   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index);
106
107   /**
108    * Create an animation on the actor and child actors using the indexed animation map.
109    * If the animation map does not exist in the model, then this returns an uninitialised
110    * handle.
111    * @param[in] model A model resource handle
112    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
113    * @param[in] index The index of the animation
114    * @param[in] durationSeconds The duration over which to run the animation
115    * @return A handle to an animation, or uninitialised.
116    */
117   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, float durationSeconds);
118
119   /**
120    * Create an animation on the actor and child actors using the indexed animation map.
121    * If the animation map does not exist in the model, then this returns an uninitialised
122    * handle.
123    * @param[in] model A model resource handle
124    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
125    * @param[in] index The index of the animation
126    * @param[in] alpha The alpha function to apply to the overall progress
127    * @return A handle to an animation, or uninitialised.
128    */
129   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha);
130
131   /**
132    * Create an animation on the actor and child actors using the indexed animation map.
133    * If the animation map does not exist in the model, then this returns an uninitialised
134    * handle.
135    * @param[in] model A model resource handle
136    * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
137    * @param[in] index The index of the animation
138    * @param[in] alpha The alpha function to apply to the overall progress
139    * @param[in] durationSeconds The duration over which to run the animation
140    * @return A handle to an animation, or uninitialised.
141    */
142   static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha, float durationSeconds);
143
144
145
146 private:
147   /**
148    * Recursively descend entity tree, creating either actors or meshActors.
149    * @param[in] modelData The model data source.
150    * @param[in] entity The entity to create and descend
151    * @return an Actor representing the entity (May be a handle to a MeshActor)
152    */
153   static ActorPtr RecurseNew(ModelDataPtr modelData, Dali::Entity entity);
154
155   /**
156    * Recursive method which descends the actor tree from actor. For
157    * any mesh actor found, bind it's bones, searching from the
158    * rootActor. (If a mesh is affected by bones, there is no
159    * requirement that they are below it's entity in the model's entity
160    * tree and corresponding actor tree)
161    *
162    * @param[in] rootActor - the actor to search for bones
163    * @param[in] actor     - the current actor to check for meshes.
164    */
165   static void BindBonesToMeshActors(ActorPtr rootActor, ActorPtr actor);
166
167   /**
168    * Create animation and connect each animator in the animation map to the
169    * relevant actor matching entity. This uses the root actor as a point to
170    * search for entity names, so it's advised to use the topmost actor generated
171    * by BuildActorTree.
172    *
173    * @param[in] rootActor The root actor created from the model,
174    * @param[in] animationData The animation map containing entity animator data.
175    * @param[in] alpha The alpha function to apply to the overall progress
176    * @param[in] durationSeconds The duration over which the animation will occur.
177    * @return animation The generated animation
178    */
179   static AnimationPtr CreateAnimation(Actor& rootActor, const ModelAnimationMap* animationData, AlphaFunction alpha, float durationSeconds);
180
181 };
182
183 } // Internal
184 } // namespace Dali
185
186 #endif /* _DALI_INTERNAL_MODEL_ACTOR_FACTORY_H_ */