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


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

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


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

示例1: LoadSourceFile

bool CModel::LoadSourceFile()
{
#ifdef TINKER_NO_TOOLS
	return false;
#else
	CConversionScene* pScene = new CConversionScene();
	CModelConverter c(pScene);

	if (!c.ReadModel(m_sFilename))
	{
		delete pScene;
		return false;
	}

	g_asTextures.clear();
	g_aaflData.clear();
	g_aabbVisBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999));
	g_aabbPhysBounds = AABB(Vector(999, 999, 999), Vector(-999, -999, -999));

	LoadSceneIntoToy(pScene);

	size_t iTextures = g_asTextures.size();

	m_ahMaterials.resize(iTextures);
	m_aiVertexBuffers.resize(iTextures);
	m_aiVertexBufferSizes.resize(iTextures);

	for (size_t i = 0; i < iTextures; i++)
	{
		if (g_aaflData[i].size() == 0)
			continue;

		m_aiVertexBuffers[i] = CRenderer::LoadVertexDataIntoGL(g_aaflData[i].size()*4, &g_aaflData[i][0]);
		m_aiVertexBufferSizes[i] = g_aaflData[i].size()/FIXED_FLOATS_PER_VERTEX;

		CData oMaterialData;
		CData* pShader = oMaterialData.AddChild("Shader", "model");
		pShader->AddChild("DiffuseTexture", g_asTextures[i]);
		m_ahMaterials[i] = CMaterialLibrary::AddMaterial(&oMaterialData);

		//TAssert(m_aiMaterials[i]);
		if (!m_ahMaterials[i].IsValid())
			TError(tstring("Couldn't create fake material for texture \"") + g_asTextures[i] + "\"\n");
	}

	m_aabbVisBoundingBox = g_aabbVisBounds;
	m_aabbPhysBoundingBox = g_aabbPhysBounds;

	delete pScene;

	return true;
#endif
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:53,代码来源:loadsource.cpp

示例2: SaveData

void CCampaignData::SaveData(const tstring& sFile)
{
	FILE* fp = tfopen_asset(sFile, "w");
	CData* pData = new CData();

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

	CDataSerializer::Save(fp, pData);

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

示例3: Read

void CDataSerializer::Read(std::basic_istream<char>& sStream, CData* pData)
{
	if (!sStream.good())
		return;

	if (!pData)
		return;

	char szLine[1024];
	string sLine;

	CData* pCurrentData = pData;
	CData* pLastData = NULL;

	while (sStream.getline(szLine, 1024))
	{
		sLine = string(szLine);

		size_t iComment = sLine.find("//");
		if (iComment != string::npos)
			sLine = sLine.substr(0, iComment);

		sLine = trim(sLine);

		if (sLine.length() == 0)
			continue;

		if (sLine[0] == '{')
		{
			pCurrentData = pLastData;
			continue;
		}

		if (sLine[0] == '}')
		{
			pCurrentData = pCurrentData->GetParent();
			continue;
		}

		vector<string> asTokens;
		explode(sLine, asTokens, ":");

		if (asTokens.size() == 1)
			pLastData = pCurrentData->AddChild(trim(sLine));
		else if (asTokens.size() >= 2)
			pLastData = pCurrentData->AddChild(trim(asTokens[0]), trim(sLine.substr(sLine.find(':')+1)));
	}
}
开发者ID:BSVino,项目名称:MathForGameDevelopers,代码行数:48,代码来源:dataserializer.cpp


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