本文整理汇总了C++中Entity::GetChildrenCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetChildrenCount方法的具体用法?C++ Entity::GetChildrenCount怎么用?C++ Entity::GetChildrenCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetChildrenCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SafeRetain
CommandInternalRemoveSceneNode::CommandInternalRemoveSceneNode(Entity* node, bool removeSimilar)
: Command(Command::COMMAND_UNDO_REDO, CommandList::ID_COMMAND_INTERNAL_REMOVE_SCENE_NODE)
{
commandName = "Remove Object";
if (removeSimilar)
commandName += "s";
if (!node || !node->GetParent())
return;
if (removeSimilar)
{
String referenceToOwner;
Entity* nodeParent = node->GetParent();
KeyedArchive *customProperties = node->GetCustomProperties();
if(customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
{
referenceToOwner = customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER);
}
nodesForDeletion.reserve(nodeParent->GetChildrenCount());
for (int32 i = 0; i < nodeParent->GetChildrenCount(); ++i)
{
Entity* child = nodeParent->GetChild(i);
customProperties = child->GetCustomProperties();
if (customProperties && customProperties->IsKeyExists(ResourceEditor::EDITOR_REFERENCE_TO_OWNER))
{
if (customProperties->GetString(ResourceEditor::EDITOR_REFERENCE_TO_OWNER) == referenceToOwner)
{
RemoveNodeRec removeNodeRec;
removeNodeRec.node = SafeRetain(child);
removeNodeRec.nodeParent = nodeParent;
int32 i = GetNodeIndex(removeNodeRec);
if (i >= 0 && i < nodeParent->GetChildrenCount() - 1)
removeNodeRec.insertBeforeNode = nodeParent->GetChild(i + 1);
nodesForDeletion.push_back(removeNodeRec);
}
}
}
}
else
{
RemoveNodeRec removeNodeRec;
removeNodeRec.node = SafeRetain(node);
removeNodeRec.nodeParent = node->GetParent();
int32 i = GetNodeIndex(removeNodeRec);
if (i >= 0 && i < removeNodeRec.nodeParent->GetChildrenCount() - 1)
removeNodeRec.insertBeforeNode = removeNodeRec.nodeParent->GetChild(i + 1);
nodesForDeletion.push_back(removeNodeRec);
}
selectedNode = node;
}
示例2: SaveFile
void SceneSaver::SaveFile(const String &fileName, Set<String> &errorLog)
{
Logger::Info("[SceneSaver::SaveFile] %s", fileName.c_str());
FilePath filePath = sceneUtils.dataSourceFolder + fileName;
//Load scene with *.sc2
Scene *scene = new Scene();
Entity *rootNode = scene->GetRootNode(filePath);
if(rootNode)
{
int32 count = rootNode->GetChildrenCount();
Vector<Entity*> tempV;
tempV.reserve((count));
for(int32 i = 0; i < count; ++i)
{
tempV.push_back(rootNode->GetChild(i));
}
for(int32 i = 0; i < count; ++i)
{
scene->AddNode(tempV[i]);
}
SaveScene(scene, filePath, errorLog);
}
else
{
errorLog.insert(Format("[SceneSaver::SaveFile] Can't open file %s", fileName.c_str()));
}
SafeRelease(scene);
}
示例3: ReloadParticleSprites
void SpritePackerHelper::ReloadParticleSprites(SceneData* sceneData)
{
List<Entity*> particleEffects;
sceneData->GetAllParticleEffects(particleEffects);
for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it)
{
Entity* curNode = (*it);
ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT));
if (!effectComponent)
{
continue;
}
effectComponent->Stop();
// All the children of this Scene Node must have Emitter components.
int32 emittersCount = curNode->GetChildrenCount();
for (int32 i = 0; i < emittersCount; i ++)
{
Entity* childNode = curNode->GetChild(i);
ParticleEmitter * emitter = GetEmitter(childNode);
if (!emitter)
{
continue;
}
emitter->ReloadLayerSprites();
}
effectComponent->Start();
}
}
示例4: ResaveFile
void SceneSaver::ResaveFile(const String &fileName, Set<String> &errorLog)
{
DVASSERT(0); //TODO: check save
Logger::Info("[SceneSaver::ResaveFile] %s", fileName.c_str());
FilePath sc2Filename = sceneUtils.dataSourceFolder + fileName;
//Load scene with *.sc2
Scene *scene = new Scene();
Entity *rootNode = scene->GetRootNode(sc2Filename);
if(rootNode)
{
int32 count = rootNode->GetChildrenCount();
Vector<Entity*> tempV;
tempV.reserve((count));
for(int32 i = 0; i < count; ++i)
{
tempV.push_back(rootNode->GetChild(i));
}
for(int32 i = 0; i < count; ++i)
{
scene->AddNode(tempV[i]);
}
scene->Update(0.f);
SceneFileV2 * outFile = new SceneFileV2();
outFile->EnableDebugLog(false);
outFile->SaveScene(sc2Filename, scene);
SafeRelease(outFile);
}
else
{
errorLog.insert(Format("[SceneSaver::ResaveFile] Can't open file %s", fileName.c_str()));
}
SafeRelease(scene);
}
示例5: Scene
DAVA::Scene * DAEConvertWithSettingsAction::CreateSceneFromSc2(const DAVA::FilePath &scenePathname)
{
Scene * scene = new Scene();
Entity * rootNode = scene->GetRootNode(scenePathname);
if(rootNode)
{
rootNode = rootNode->Clone();
Vector<Entity*> tmpEntities;
uint32 entitiesCount = (uint32)rootNode->GetChildrenCount();
// optimize scene
SceneFileV2 *sceneFile = new SceneFileV2();
sceneFile->OptimizeScene(rootNode);
sceneFile->Release();
// remember all child pointers, but don't add them to scene in this cycle
// because when entity is adding it is automatically removing from its old hierarchy
tmpEntities.reserve(entitiesCount);
for (uint32 i = 0; i < entitiesCount; ++i)
{
tmpEntities.push_back(rootNode->GetChild(i));
}
// now we can safely add entities into our hierarchy
for (uint32 i = 0; i < (uint32) tmpEntities.size(); ++i)
{
scene->AddNode(tmpEntities[i]);
}
rootNode->Release();
Set<String> errorsLog;
SceneValidator::Instance()->ValidateScene(scene, scenePathname, errorsLog);
}
return scene;
}
示例6: MergeSwitch
bool SwitchToRenerObjectConverter::MergeSwitch(Entity * entity)
{
Vector<Entity*> entitiesToRemove;
SwitchComponent * sw = GetSwitchComponent(entity);
if(sw)
{
RenderComponent * rc = GetRenderComponent(entity);
RenderObject * ro = 0;
if(!rc)
{
ro = new Mesh();
rc = new RenderComponent(ro);
ro->Release();
ro->SetAABBox(AABBox3(Vector3(0, 0, 0), Vector3(0, 0, 0)));
entity->AddComponent(rc);
}
else
{
ro = rc->GetRenderObject();
}
DVASSERT(ro);
int32 size = entity->GetChildrenCount();
for(int32 i = 0; i < size; ++i)
{
Entity * sourceEntity = entity->GetChild(i);
RenderObject * sourceRenderObject = GetRenderObject(sourceEntity);
//workaround for custom properties for crashed model
if(1 == i) // crash model
{
KeyedArchive *childProps = GetCustomPropertiesArchieve(sourceEntity);
if(childProps && childProps->IsKeyExists("CollisionType"))
{
KeyedArchive *entityProps = GetOrCreateCustomProperties(entity)->GetArchive();
entityProps->SetInt32("CollisionTypeCrashed", childProps->GetInt32("CollisionType", 0));
}
}
//end of custom properties
Vector<std::pair<Entity*, RenderObject*> > renderPairs;
if(sourceRenderObject)
{
renderPairs.push_back(std::make_pair(sourceEntity, sourceRenderObject));
}
else
{
FindRenderObjectsRecursive(sourceEntity, renderPairs);
DVASSERT(renderPairs.size() == 1);
sourceRenderObject = renderPairs[0].second;
}
if(sourceRenderObject)
{
TransformComponent * sourceTransform = GetTransformComponent(sourceEntity);
if (sourceTransform->GetLocalTransform() != Matrix4::IDENTITY)
{
PolygonGroup * pg = sourceRenderObject->GetRenderBatchCount() > 0 ? sourceRenderObject->GetRenderBatch(0)->GetPolygonGroup() : 0;
if(pg && bakedPolygonGroups.end() == bakedPolygonGroups.find(pg))
{
sourceRenderObject->BakeGeometry(sourceTransform->GetLocalTransform());
bakedPolygonGroups.insert(pg);
}
}
uint32 sourceSize = sourceRenderObject->GetRenderBatchCount();
while(sourceSize)
{
int32 lodIndex, switchIndex;
RenderBatch * sourceRenderBatch = sourceRenderObject->GetRenderBatch(0, lodIndex, switchIndex);
sourceRenderBatch->Retain();
sourceRenderObject->RemoveRenderBatch(sourceRenderBatch);
ro->AddRenderBatch(sourceRenderBatch, lodIndex, i);
sourceRenderBatch->Release();
sourceSize--;
}
}
renderPairs[0].first->RemoveComponent(Component::RENDER_COMPONENT);
LodComponent * lc = GetLodComponent(sourceEntity);
if((0 != lc) && (0 == GetLodComponent(entity)))
{
LodComponent * newLod = (LodComponent*)lc->Clone(entity);
entity->AddComponent(newLod);
}
renderPairs[0].first->RemoveComponent(Component::LOD_COMPONENT);
if(sourceEntity->GetChildrenCount() == 0)
{
entitiesToRemove.push_back(sourceEntity);
}
}
}
uint32 entitiesToRemoveCount = entitiesToRemove.size();
//.........这里部分代码省略.........