1 #ifndef __DALI_INTERNAL_MODEL_ACTOR_FACTORY_H__
2 #define __DALI_INTERNAL_MODEL_ACTOR_FACTORY_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
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>
36 * This factory class is used to generate a tree of actors and mesh actors.
38 class ModelActorFactory
43 * @copydoc Dali::ModelActorFactory::BuildActorTree
45 static ActorPtr BuildActorTree(Dali::Model& model, const std::string& name);
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
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.
57 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName);
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
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.
69 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, float durationSeconds);
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
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.
81 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha);
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
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.
94 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha, float durationSeconds);
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
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.
105 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index);
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
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.
117 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, float durationSeconds);
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
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.
129 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha);
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
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.
142 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha, float durationSeconds);
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)
153 static ActorPtr RecurseNew(ModelDataPtr modelData, Dali::Entity entity);
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)
162 * @param[in] rootActor - the actor to search for bones
163 * @param[in] actor - the current actor to check for meshes.
165 static void BindBonesToMeshActors(ActorPtr rootActor, ActorPtr actor);
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
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
179 static AnimationPtr CreateAnimation(Actor& rootActor, const ModelAnimationMap* animationData, AlphaFunction alpha, float durationSeconds);
186 #endif /* _DALI_INTERNAL_MODEL_ACTOR_FACTORY_H_ */