本文整理汇总了C++中CData::GetValueTRS方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::GetValueTRS方法的具体用法?C++ CData::GetValueTRS怎么用?C++ CData::GetValueTRS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CData
的用法示例。
在下文中一共展示了CData::GetValueTRS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........
示例2: BuildFromInputScript
//.........这里部分代码省略.........
t.AddMaterial(t.GetOutputDirectory() + "/" + pMesh->GetValueString(), GetPath(pMesh->GetValueString()));
t.AddVertex(0, -vecLeft + vecUp, Vector2D(0.0f, 1.0f));
t.AddVertex(0, -vecLeft - vecUp, Vector2D(0.0f, 0.0f));
t.AddVertex(0, vecLeft - vecUp, Vector2D(1.0f, 0.0f));
t.AddVertex(0, -vecLeft + vecUp, Vector2D(0.0f, 1.0f));
t.AddVertex(0, vecLeft - vecUp, Vector2D(1.0f, 0.0f));
t.AddVertex(0, vecLeft + vecUp, Vector2D(1.0f, 1.0f));
}
else if (sExtension == ".mat")
{
CMaterialHandle hMaterial(pMesh->GetValueString());
if (!hMaterial.IsValid())
{
TError("Input material '" + pMesh->GetValueString() + "' does not exist or is invalid.\n");
return false;
}
if (!hMaterial->m_ahTextures.size())
{
TError("Input material '" + pMesh->GetValueString() + "' has no textures.\n");
return false;
}
float w = (float)hMaterial->m_ahTextures[0]->m_iWidth;
float h = (float)hMaterial->m_ahTextures[0]->m_iHeight;
Vector vecUp = Vector(0, 0.5f, 0) * (h/hMaterial->m_iTexelsPerMeter);
Vector vecRight = Vector(0, 0, 0.5f) * (w/hMaterial->m_iTexelsPerMeter);
t.UseNormals(false);
t.AddMaterial(pMesh->GetValueString());
t.AddVertex(0, -vecRight + vecUp, Vector2D(0.0f, 1.0f));
t.AddVertex(0, -vecRight - vecUp, Vector2D(0.0f, 0.0f));
t.AddVertex(0, vecRight - vecUp, Vector2D(1.0f, 0.0f));
t.AddVertex(0, -vecRight + vecUp, Vector2D(0.0f, 1.0f));
t.AddVertex(0, vecRight - vecUp, Vector2D(1.0f, 0.0f));
t.AddVertex(0, vecRight + vecUp, Vector2D(1.0f, 1.0f));
}
else
{
TMsg("Reading model '" + GetPath(pMesh->GetValueString()) + "' ...");
std::shared_ptr<CConversionScene> pScene(new CConversionScene());
CModelConverter c(pScene.get());
if (!c.ReadModel(GetPath(pMesh->GetValueString())))
{
TError("Couldn't read '" + GetPath(pMesh->GetValueString()) + "'.\n");
return false;
}
TMsg(" Done.\n");
TMsg("Building toy mesh ...");
LoadSceneIntoToy(pScene.get(), &t);
TMsg(" Done.\n");
}
}
if (pPhysics)
{
TMsg("Reading physics model '" + GetPath(pPhysics->GetValueString()) + "' ...");
std::shared_ptr<CConversionScene> pScene(new CConversionScene());
CModelConverter c(pScene.get());
if (!c.ReadModel(GetPath(pPhysics->GetValueString())))
{
TError("Couldn't read '" + GetPath(pPhysics->GetValueString()) + "'.\n");
return false;
}
TMsg(" Done.\n");
TMsg("Building toy physics model ...");
LoadSceneIntoToyPhysics(pScene.get(), &t);
TMsg(" Done.\n");
}
if (pPhysicsShapes)
{
for (size_t i = 0; i < pPhysicsShapes->GetNumChildren(); i++)
{
CData* pShape = pPhysicsShapes->GetChild(i);
TAssert(pShape->GetKey() == "Box");
if (pShape->GetKey() != "Box")
continue;
TRS trs = pShape->GetValueTRS();
t.AddPhysBox(trs);
}
}
if (pSceneAreas)
LoadSceneAreas(pSceneAreas);
return Compile();
}
示例3: Open
void CToySource::Open(const tstring& sFile)
{
std::basic_ifstream<tchar> f((sFile).c_str());
if (!f.is_open())
{
TError("Could not read input script '" + sFile + "'\n");
return;
}
m_sFilename = sFile;
std::shared_ptr<CData> pData(new CData());
CDataSerializer::Read(f, 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");
TAssert(!pSceneAreas); // This is unimplemented.
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 = "";
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();
}
}
ToyEditor()->MarkSaved();
}