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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/modeling/model.h>
23 #include <dali/internal/event/modeling/model-data-impl.h>
24 #include <dali/internal/event/actors/actor-declarations.h>
25 #include <dali/internal/event/animation/animation-impl.h>
37 * This factory class is used to generate a tree of actors and mesh actors.
39 class ModelActorFactory
44 * @copydoc Dali::ModelActorFactory::BuildActorTree
46 static ActorPtr BuildActorTree(Dali::Model& model, const std::string& name);
50 * Create an animation on the actor and child actors using the named animation map.
51 * If the animation map does not exist in the model, then this returns an uninitialised
53 * @param[in] model A model resource handle
54 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
55 * @param[in] animationName The name of the animation to build
56 * @return A pointer to an animation.
58 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName);
61 * Create an animation on the actor and child actors using the named animation map.
62 * If the animation map does not exist in the model, then this returns an uninitialised
64 * @param[in] model A model resource handle
65 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
66 * @param[in] animationName The name of the animation to build
67 * @param[in] durationSeconds The duration over which to run the animation
68 * @return A pointer to an animation.
70 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, float durationSeconds);
73 * Create an animation on the actor and child actors using the named animation map.
74 * If the animation map does not exist in the model, then this returns an uninitialised
76 * @param[in] model A model resource handle
77 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
78 * @param[in] animationName The name of the animation to build
79 * @param[in] alpha The alpha function to apply to the overall progress
80 * @return A pointer to an animation.
82 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha);
85 * Create an animation on the actor and child actors using the named animation map.
86 * If the animation map does not exist in the model, then this returns an uninitialised
88 * @param[in] model A model resource handle
89 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
90 * @param[in] animationName The name of the animation to build
91 * @param[in] alpha The alpha function to apply to the overall progress
92 * @param[in] durationSeconds The duration over which to run the animation
93 * @return A pointer to an animation.
95 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, const std::string& animationName, AlphaFunction alpha, float durationSeconds);
98 * Create an animation on the actor and child actors using the indexed animation map.
99 * If the animation map does not exist in the model, then this returns an uninitialised
101 * @param[in] model A model resource handle
102 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
103 * @param[in] index The index of the animation
104 * @return A handle to an animation, or uninitialised.
106 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index);
109 * Create an animation on the actor and child actors using the indexed animation map.
110 * If the animation map does not exist in the model, then this returns an uninitialised
112 * @param[in] model A model resource handle
113 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
114 * @param[in] index The index of the animation
115 * @param[in] durationSeconds The duration over which to run the animation
116 * @return A handle to an animation, or uninitialised.
118 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, float durationSeconds);
121 * Create an animation on the actor and child actors using the indexed animation map.
122 * If the animation map does not exist in the model, then this returns an uninitialised
124 * @param[in] model A model resource handle
125 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
126 * @param[in] index The index of the animation
127 * @param[in] alpha The alpha function to apply to the overall progress
128 * @return A handle to an animation, or uninitialised.
130 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha);
133 * Create an animation on the actor and child actors using the indexed animation map.
134 * If the animation map does not exist in the model, then this returns an uninitialised
136 * @param[in] model A model resource handle
137 * @param[in] rootActor An actor tree (generated by BuildActorTree) to animate
138 * @param[in] index The index of the animation
139 * @param[in] alpha The alpha function to apply to the overall progress
140 * @param[in] durationSeconds The duration over which to run the animation
141 * @return A handle to an animation, or uninitialised.
143 static AnimationPtr BuildAnimation(Model& model, Actor& rootActor, size_t index, AlphaFunction alpha, float durationSeconds);
149 * Recursively descend entity tree, creating either actors or meshActors.
150 * @param[in] modelData The model data source.
151 * @param[in] entity The entity to create and descend
152 * @return an Actor representing the entity (May be a handle to a MeshActor)
154 static ActorPtr RecurseNew(ModelDataPtr modelData, Dali::Entity entity);
157 * Recursive method which descends the actor tree from actor. For
158 * any mesh actor found, bind it's bones, searching from the
159 * rootActor. (If a mesh is affected by bones, there is no
160 * requirement that they are below it's entity in the model's entity
161 * tree and corresponding actor tree)
163 * @param[in] rootActor - the actor to search for bones
164 * @param[in] actor - the current actor to check for meshes.
166 static void BindBonesToMeshActors(ActorPtr rootActor, ActorPtr actor);
169 * Create animation and connect each animator in the animation map to the
170 * relevant actor matching entity. This uses the root actor as a point to
171 * search for entity names, so it's advised to use the topmost actor generated
174 * @param[in] rootActor The root actor created from the model,
175 * @param[in] animationData The animation map containing entity animator data.
176 * @param[in] alpha The alpha function to apply to the overall progress
177 * @param[in] durationSeconds The duration over which the animation will occur.
178 * @return animation The generated animation
180 static AnimationPtr CreateAnimation(Actor& rootActor, const ModelAnimationMap* animationData, AlphaFunction alpha, float durationSeconds);
187 #endif /* _DALI_INTERNAL_MODEL_ACTOR_FACTORY_H_ */