本文整理汇总了C++中Actor::AddChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Actor::AddChild方法的具体用法?C++ Actor::AddChild怎么用?C++ Actor::AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor::AddChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EX_DETAILS
void Grafkit::SceneLoader::SceneLoaderHelper::Load(Archive &ar, IResourceManager * const & resman)
{
Persist(ar, resman);
LOGGER(Log::Logger().Info("-- ASSIGN --"));
// 5. material -> mesh relation
LOGGER(Log::Logger().Info("Materials: %d", m_materials_to_meshes.size()));
for (auto it = m_materials_to_meshes.begin(); it != m_materials_to_meshes.end(); ++it)
{
USHORT key = it->first;
USHORT val = it->second;
Material * material = m_materials[key];
Model *model = dynamic_cast<Model *>(m_entities[val]);
if (model && material) {
model->SetMaterial(material);
LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, material->GetName().c_str(), val, model->GetName().c_str()));
}
}
// ...
// 6. entitiy -> actor relation
LOGGER(Log::Logger().Info("Entities: %d", m_entities_to_actors.size()));
for (auto it = m_entities_to_actors.begin(); it != m_entities_to_actors.end(); ++it)
{
USHORT key = it->first;
USHORT val = it->second;
Entity3D *entity = m_entities[key];
Actor *actor = m_actors[val];
if (actor && entity) {
actor->AddEntity(entity);
LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, entity->GetName().c_str()), val, actor->GetName().c_str());
}
}
// ...
// 7. actor -> actor relation - scenegraph
LOGGER(Log::Logger().Info("Actors: %d", m_actor_to_actor.size()));
for (auto it = m_actor_to_actor.begin(); it != m_actor_to_actor.end(); ++it)
{
USHORT key = it->first;
USHORT val = it->second;
Actor *child = m_actors[val];
Actor *parent = m_actors[key];
if (parent && child) {
parent->AddChild(child);
LOGGER(Log::Logger().Info("%hu (\"%s\") -> %hu (\"%s\")", key, parent->GetName().c_str(), val, child->GetName().c_str()));
}
}
//8, 9 animation -> actor, entity
LOGGER(Log::Logger().Info("Animations: %d", m_animation_to_actor.size() + m_animation_to_entity.size()));
for (auto it = m_animation_to_actor.cbegin(); it != m_animation_to_actor.cend(); ++it)
{
USHORT key = it->first;
USHORT value = it->second;
ActorAnimation *actor_animation = dynamic_cast<ActorAnimation *>(m_Animations[key]);
if (actor_animation) {
Actor* actor = m_actors[value];
if (actor) {
actor_animation->SetActor(ActorRef(actor));
m_scene->AddAnimation(actor_animation);
LOGGER(Log::Logger().Info("Actor %hu (\"%s\") -> %hu (\"%s\")", key, actor->GetName().c_str(), value, actor_animation->GetName().c_str()));
}
}
}
for (auto it = m_animation_to_entity.cbegin(); it != m_animation_to_entity.cend(); ++it)
{
USHORT key = it->first;
USHORT value = it->second;
EntityAnimation *entity_animation = dynamic_cast<EntityAnimation*>(m_Animations[key]);
if (entity_animation) {
Entity3D* entity = m_entities[value];
if (entity) {
entity_animation->SetEntity(Ref<Entity3D>(entity));
m_scene->AddAnimation(entity_animation);
LOGGER(Log::Logger().Info("Entity %hu -> %hu", key, value));
}
}
}
if (m_actors.empty())
throw new EX_DETAILS(SceneLoadException, "Actors are empty for some reason");
Actor * root = m_actors[0];
m_scene->Initialize(root);
//.........这里部分代码省略.........