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


C++ CData::FindChild方法代码示例

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


在下文中一共展示了CData::FindChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadData

void CCampaignData::ReadData(const tstring& sFile)
{
	FILE* fp = tfopen_asset(sFile, "r");
	CData* pData = new CData();
	CDataSerializer::Read(fp, pData);

	CData* pCampaign = pData->FindChild("Campaign");
	m_iHighestLevelReached = pCampaign->FindChild("HighestLevel")->GetValueInt();
	m_iCurrentLevel = pCampaign->FindChild("CurrentLevel")->GetValueInt();

	delete pData;
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:12,代码来源:campaigndata.cpp

示例2: AddShader

void CShaderLibrary::AddShader(const string& sFile)
{
	TAssert(!Get()->m_bCompiled);
	if (Get()->m_bCompiled)
		return;

	std::basic_ifstream<char> f(sFile.c_str());

	if (!f.is_open())
	{
		TAssert(false);
		// Couldn't open shader file
		return;
	}

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(f, pData.get());

	CData* pName = pData->FindChild("Name");
	CData* pVertex = pData->FindChild("Vertex");
	CData* pFragment = pData->FindChild("Fragment");

	TAssert(pName);
	if (!pName)
		return;

	TAssert(pVertex);
	if (!pVertex)
		return;

	TAssert(pFragment);
	if (!pFragment)
		return;

	Get()->m_aShaders.push_back(CShader(pName->GetValueString(), pVertex->GetValueString(), pFragment->GetValueString()));
	Get()->m_aShaderNames[pName->GetValueString()] = Get()->m_aShaders.size()-1;

	auto& oShader = Get()->m_aShaders.back();

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pChild = pData->GetChild(i);
		if (pChild->GetKey() == "Parameter")
		{
			auto& oParameter = oShader.m_aParameters[pChild->GetValueString()];
			oParameter.m_sName = pChild->GetValueString();

			for (size_t j = 0; j < pChild->GetNumChildren(); j++)
			{
				CData* pUniform = pChild->GetChild(j);
				if (pUniform->GetKey() == "Uniform")
				{
					oParameter.m_aActions.push_back(CShader::CParameter::CUniform());
					auto& oUniform = oParameter.m_aActions.back();
					oUniform.m_sName = pUniform->GetValueString();
					oUniform.m_bTexture = false;
					CData* pValue = pUniform->FindChild("Value");
					CData* pTexture = pUniform->FindChild("Texture");
					TAssert(!(pValue && pTexture));
					TAssert(pValue || pTexture);

					if (pValue)
						oUniform.m_sValue = pValue->GetValueString();
					else if (pTexture)
					{
						oUniform.m_sValue = pTexture->GetValueString();
						oShader.m_asTextures.push_back(pUniform->GetValueString());
						oUniform.m_bTexture = true;
					}
				}
				else if (pUniform->GetKey() == "Blend")
				{
					string& sBlend = oParameter.m_sBlend;
					sBlend = pUniform->GetValueString();
				}
			}
		}
		else if (pChild->GetKey() == "Defaults")
		{
			for (size_t j = 0; j < pChild->GetNumChildren(); j++)
			{
				CData* pUniform = pChild->GetChild(j);
				auto& oDefault = oShader.m_aDefaults[pUniform->GetKey()];
				oDefault.m_sName = pUniform->GetKey();
				oDefault.m_sValue = pUniform->GetValueString();
			}
		}
	}
}
开发者ID:Raki,项目名称:MathForGameDevelopers,代码行数:89,代码来源:shaders.cpp

示例3: Open

void CToySource::Open(const tstring& sFile)
{
	Clear();

	FILE* fp = tfopen_asset(sFile, "r");
	if (!fp)
	{
		TError("Could not read input script '" + sFile + "'\n");
		return;
	}

	m_sFilename = sFile;

	std::shared_ptr<CData> pData(new CData());
	CDataSerializer::Read(fp, pData.get());

	CData* pOutput = pData->FindChild("Output");
	CData* pSceneAreas = pData->FindChild("SceneAreas");
	CData* pMesh = pData->FindChild("Mesh");
	CData* pPhysics = pData->FindChild("Physics");
	CData* pPhysicsShapes = pData->FindChild("PhysicsShapes");

	if (pOutput)
		m_sToyFile = pOutput->GetValueString();
	else
		m_sToyFile = "";

	if (pMesh)
		m_sMesh = pMesh->GetValueString();
	else
		m_sMesh = "";

	if (pPhysics)
		m_sPhys = pPhysics->GetValueString();
	else
		m_sPhys = "";

	CData* pGlobalTransforms = pData->FindChild("UseGlobalTransforms");
	m_bUseLocalTransforms = !pGlobalTransforms;

	if (pPhysicsShapes)
	{
		for (size_t i = 0; i < pPhysicsShapes->GetNumChildren(); i++)
		{
			CData* pChild = pPhysicsShapes->GetChild(i);

			TAssert(pChild->GetKey() == "Box");
			if (pChild->GetKey() != "Box")
				continue;

			tvector<tstring> asTokens;
			strtok(pChild->GetValueString(), asTokens);
			TAssert(asTokens.size() == 9);
			if (asTokens.size() != 9)
				continue;

			CPhysicsShape& oShape = m_aShapes.push_back();

			oShape.m_trsTransform = pChild->GetValueTRS();
		}
	}

	if (pSceneAreas)
	{
		for (size_t i = 0; i < pSceneAreas->GetNumChildren(); i++)
		{
			CData* pChild = pSceneAreas->GetChild(i);

			if (pChild->GetKey() == "NeighborDistance")
			{
				m_flNeighborDistance = pChild->GetValueFloat();
				continue;
			}

			if (pChild->GetKey() == "UseGlobalTransforms")
			{
				m_bUseLocalTransforms = false;
				continue;
			}

			if (pChild->GetKey() == "UseLocalTransforms")
			{
				m_bUseLocalTransforms = true;
				continue;
			}

			TAssert(pChild->GetKey() == "Area");
			if (pChild->GetKey() != "Area")
				continue;

			auto& oArea = m_aAreas.push_back();

			oArea.m_sName = pChild->GetValueString();

			CData* pFile = pChild->FindChild("File");
			CData* pMesh = pChild->FindChild("Mesh");
			CData* pPhysics = pChild->FindChild("Physics");

			if (pFile)
				oArea.m_sFilename = pFile->GetValueString();
//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:toyeditor.cpp


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