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


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

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


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

示例1: LoadSceneAreas

bool CGeppetto::LoadSceneAreas(CData* pData)
{
	tmap<tstring, std::shared_ptr<CConversionScene> > asScenes;
	tmap<tstring, size_t> aiSceneIDs;

	size_t iSceneArea = 0;

	for (size_t i = 0; i < pData->GetNumChildren(); i++)
	{
		CData* pArea = pData->GetChild(i);

		if (pArea->GetKey() == "NeighborDistance")
		{
			t.SetNeighborDistance(pArea->GetValueFloat());
			continue;
		}

		if (pArea->GetKey() == "UseGlobalTransforms")
		{
			t.UseGlobalTransformations();
			continue;
		}

		if (pArea->GetKey() == "UseLocalTransforms")
		{
			t.UseLocalTransformations();
			continue;
		}

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

		tstring sFile = pArea->FindChildValueString("File");
		TAssert(sFile.length());
		if (!sFile.length())
			continue;

		tstring sMesh = pArea->FindChildValueString("Mesh");
		TAssert(sMesh.length());
		if (!sMesh.length())
			continue;

		tstring sPhysics = pArea->FindChildValueString("Physics");

		auto it = asScenes.find(sFile);
		if (it == asScenes.end())
		{
			TMsg("Reading model '" + GetPath(sFile) + "' ...");
			std::shared_ptr<CConversionScene> pScene(new CConversionScene());
			CModelConverter c(pScene.get());

			if (!c.ReadModel(GetPath(sFile)))
			{
				TError("Couldn't read '" + GetPath(sFile) + "'.\n");
				return false;
			}
			TMsg(" Done.\n");

			asScenes[sFile] = pScene;
		}

		iSceneArea++;

		CToyUtil ts;

		if (t.IsUsingUV())
			ts.UseUV();
		if (t.IsUsingNormals())
			ts.UseNormals();

		ts.SetGameDirectory(t.GetGameDirectory());
		ts.SetOutputDirectory(t.GetOutputDirectory());
		ts.SetOutputFile(tsprintf(t.GetOutputFile() + "_sa%d_" + pArea->GetValueString().tolower(), iSceneArea));
		ts.UseLocalTransformations(t.IsUsingLocalTransformations());

		CConversionSceneNode* pMeshNode = asScenes[sFile]->FindSceneNode(sMesh);
		CConversionSceneNode* pPhysicsNode = nullptr;
		if (sPhysics.length())
		{
			pPhysicsNode = asScenes[sFile]->FindSceneNode(sPhysics);
		
			if (!pPhysicsNode)
				TError("Couldn't find a scene node in '" + sFile + "' named '" + sMesh + "'\n");
		}

		TAssert(pMeshNode);

		TMsg("Building scene area toy ...");

		Matrix4x4 mUpLeftSwap(Vector(1, 0, 0), Vector(0, 0, 1), Vector(0, -1, 0));

		if (pMeshNode)
			LoadSceneNodeIntoToy(asScenes[sFile].get(), pMeshNode, mUpLeftSwap, &ts);
		else
			TError("Couldn't find a scene node in '" + sFile + "' named '" + sMesh + "'\n");

		if (pPhysicsNode)
			LoadSceneNodeIntoToyPhysics(asScenes[sFile].get(), pPhysicsNode, mUpLeftSwap, &ts);

//.........这里部分代码省略.........
开发者ID:BSVino,项目名称:Digitanks,代码行数:101,代码来源:inputscript.cpp

示例2: ReadLesson

void CInstructor::ReadLesson(const class CData* pData)
{
    tstring sLessonName = pData->GetValueString();
    if (!sLessonName.length())
    {
        TError("Found a lesson with no name.\n");
        return;
    }

    CLesson* pLesson = new CLesson(this, sLessonName);
    m_apLessons[sLessonName] = pLesson;

    for (size_t i = 0; i < pData->GetNumChildren(); i++)
    {
        CData* pChildData = pData->GetChild(i);

        if (pChildData->GetKey() == "Position")
        {
            tstring sPosition = pChildData->GetValueString();
            if (sPosition == "top-center")
                pLesson->m_iPosition = POSITION_TOPCENTER;
            else if (sPosition == "top-left")
                pLesson->m_iPosition = POSITION_TOPLEFT;
            else if (sPosition == "left")
                pLesson->m_iPosition = POSITION_LEFT;
        }
        else if (pChildData->GetKey() == "Width")
            pLesson->m_iWidth = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "Next")
            pLesson->m_sNextLesson = pChildData->GetValueString();
        else if (pChildData->GetKey() == "Text")
            pLesson->m_sText = pChildData->GetValueString();
        else if (pChildData->GetKey() == "SlideAmount")
            pLesson->m_flSlideAmount = pChildData->GetValueFloat();
        else if (pChildData->GetKey() == "SlideX")
            pLesson->m_bSlideX = pChildData->GetValueBool();
        else if (pChildData->GetKey() == "Rotation")
            pLesson->m_bRotation = pChildData->GetValueBool();
        else if (pChildData->GetKey() == "Output")
            ReadLessonOutput(pChildData, pLesson);
        else if (pChildData->GetKey() == "Priority")
            pLesson->m_iPriority = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "LessonType")
        {
            tstring sLessonType = pChildData->GetValueString();
            if (sLessonType == "button")
                pLesson->m_iLessonType = CLesson::LESSON_BUTTON;
            else if (sLessonType == "info")
                pLesson->m_iLessonType = CLesson::LESSON_INFO;
            else if (sLessonType == "environment")
                pLesson->m_iLessonType = CLesson::LESSON_ENVIRONMENT;
        }
        else if (pChildData->GetKey() == "LearningMethod")
        {
            tstring sLearningMethod = pChildData->GetValueString();
            if (sLearningMethod == "displaying")
                pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
            else if (sLearningMethod == "display")
                pLesson->m_iLearningMethod = CLesson::LEARN_DISPLAYING;
            else if (sLearningMethod == "performing")
                pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
            else if (sLearningMethod == "perform")
                pLesson->m_iLearningMethod = CLesson::LEARN_PERFORMING;
        }
        else if (pChildData->GetKey() == "TimesToLearn")
            pLesson->m_iTimesToLearn = pChildData->GetValueInt();
        else if (pChildData->GetKey() == "Conditions")
            pLesson->m_pfnConditions = Game_GetInstructorConditions(pChildData->GetValueString()); // A dirty hack, but not a scary one.
    }
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:70,代码来源:instructor.cpp

示例3: Compile


//.........这里部分代码省略.........
		{
		case GL_FLOAT: oUniform.m_sUniformType = "float"; break;
		case GL_FLOAT_VEC2: oUniform.m_sUniformType = "vec2"; break;
		case GL_FLOAT_VEC3: oUniform.m_sUniformType = "vec3"; break;
		case GL_FLOAT_VEC4: oUniform.m_sUniformType = "vec4"; break;
		case GL_INT: oUniform.m_sUniformType = "int"; break;
		case GL_BOOL: oUniform.m_sUniformType = "bool"; break;
		case GL_FLOAT_MAT4: oUniform.m_sUniformType = "mat4"; break;
		case GL_SAMPLER_2D: oUniform.m_sUniformType = "sampler2D"; break;
		default: TUnimplemented();
		}
	}

	for (auto it = m_aParameters.begin(); it != m_aParameters.end(); it++)
	{
		for (size_t j = 0; j < it->second.m_aActions.size(); j++)
		{
			auto it2 = m_asUniforms.find(it->second.m_aActions[j].m_sName);
			TAssert(it2 != m_asUniforms.end());
			if (it2 == m_asUniforms.end())
			{
				TAssert(false);
				// A shader specifies a uniform that is not in the linked program.
				continue;
			}

			CShader::CUniform& oUniform = it2->second;

			// This is almost cheating
			CData d;
			d.SetValue(it->second.m_aActions[j].m_sValue);

			if (oUniform.m_sUniformType == "float")
				it->second.m_aActions[j].m_flValue = d.GetValueFloat();
			else if (oUniform.m_sUniformType == "vec2")
				it->second.m_aActions[j].m_vec2Value = d.GetValueVector2D();
			else if (oUniform.m_sUniformType == "vec3")
				it->second.m_aActions[j].m_vecValue = d.GetValueVector();
			else if (oUniform.m_sUniformType == "vec4")
				it->second.m_aActions[j].m_vec4Value = d.GetValueVector4D();
			else if (oUniform.m_sUniformType == "int")
				it->second.m_aActions[j].m_iValue = d.GetValueInt();
			else if (oUniform.m_sUniformType == "bool")
				it->second.m_aActions[j].m_bValue = d.GetValueBool();
			else if (oUniform.m_sUniformType == "mat4")
			{
				TUnimplemented();
			}
			else if (oUniform.m_sUniformType == "sampler2D")
			{
				// No op.
			}
			else
				TUnimplemented();
		}
	}

	for (auto it = m_aDefaults.begin(); it != m_aDefaults.end(); it++)
	{
		auto it2 = m_asUniforms.find(it->first);
		TAssert(it2 != m_asUniforms.end());
		if (it2 == m_asUniforms.end())
		{
			TAssert(false);
			// A shader specifies a default for a uniform that is not in the linked program.
			continue;
开发者ID:Raki,项目名称:MathForGameDevelopers,代码行数:67,代码来源:shaders.cpp

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