当前位置: 首页>>代码示例>>C++>>正文


C++ Entity::GetChild方法代码示例

本文整理汇总了C++中Entity::GetChild方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetChild方法的具体用法?C++ Entity::GetChild怎么用?C++ Entity::GetChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::GetChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:60,代码来源:SceneGraphCommands.cpp

示例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);
}
开发者ID:boyjimeking,项目名称:dava.framework,代码行数:32,代码来源:SceneSaver.cpp

示例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();
	}
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:35,代码来源:SpritePackerHelper.cpp

示例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);
}
开发者ID:boyjimeking,项目名称:dava.framework,代码行数:40,代码来源:SceneSaver.cpp

示例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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:40,代码来源:DAEConvertAction.cpp


注:本文中的Entity::GetChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。