本文整理汇总了C++中CConversionMesh::AddBone方法的典型用法代码示例。如果您正苦于以下问题:C++ CConversionMesh::AddBone方法的具体用法?C++ CConversionMesh::AddBone怎么用?C++ CConversionMesh::AddBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConversionMesh
的用法示例。
在下文中一共展示了CConversionMesh::AddBone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadSIAShape
const tchar* CModelConverter::ReadSIAShape(const tchar* pszLine, const tchar* pszEnd, CConversionSceneNode* pScene, bool bCare)
{
size_t iCurrentMaterial = ~0;
CConversionMesh* pMesh = NULL;
CConversionSceneNode* pMeshNode = NULL;
size_t iAddV = 0;
size_t iAddE = 0;
size_t iAddUV = 0;
size_t iAddN = 0;
tstring sLastTask;
tstring sToken;
const tchar* pszNextLine = NULL;
while (pszLine < pszEnd)
{
if (pszNextLine)
pszLine = pszNextLine;
size_t iLineLength = tstrlen(pszLine);
pszNextLine = pszLine + iLineLength + 1;
// This code used to call StripWhitespace() but that's too slow for very large files w/ millions of lines.
// Instead we'll just cut the whitespace off the front and deal with whitespace on the end when we come to it.
while (*pszLine && IsWhitespace(*pszLine))
pszLine++;
if (tstrlen(pszLine) == 0)
continue;
const tchar* pszToken = pszLine;
while (*pszToken && *pszToken != _T(' '))
pszToken++;
sToken.reserve(iLineLength);
sToken.clear();
sToken.append(pszLine, pszToken-pszLine);
sToken[pszToken-pszLine] = _T('\0');
pszToken = sToken.c_str();
if (!bCare)
{
if (tstrncmp(pszToken, _T("-endShape"), 9) == 0)
return pszNextLine;
else
continue;
}
if (tstrncmp(pszToken, _T("-snam"), 5) == 0)
{
// We name our mesh.
tstring sName =pszLine+6;
eastl::vector<tstring> aName;
tstrtok(sName, aName, _T("\"")); // Strip out the quotation marks.
if (bCare)
{
size_t iMesh = m_pScene->FindMesh(aName[0].c_str());
if (iMesh == (size_t)~0)
{
iMesh = m_pScene->AddMesh(aName[0].c_str());
pMesh = m_pScene->GetMesh(iMesh);
pMesh->AddBone(aName[0].c_str());
}
else
{
pMesh = m_pScene->GetMesh(iMesh);
iAddV = pMesh->GetNumVertices();
iAddE = pMesh->GetNumEdges();
iAddUV = pMesh->GetNumUVs();
iAddN = pMesh->GetNumNormals();
}
// Make sure it exists.
pMeshNode = m_pScene->GetDefaultSceneMeshInstance(pScene, pMesh);
}
}
else if (tstrncmp(pszToken, _T("-vert"), 5) == 0)
{
if (m_pWorkListener)
{
if (sLastTask == pszToken)
m_pWorkListener->WorkProgress(0);
else
{
m_pWorkListener->SetAction(_T("Reading vertex data"), 0);
sLastTask = tstring(pszToken);
}
}
// A vertex.
float v[3];
// scanf is pretty slow even for such a short string due to lots of mallocs.
const tchar* pszToken = pszLine+5;
int iDimension = 0;
while (*pszToken)
{
while (pszToken[0] == _T(' '))
pszToken++;
//.........这里部分代码省略.........
示例2: ReadSIAShape
const tchar* CModelConverter::ReadSIAShape(const tchar* pszLine, const tchar* pszEnd, CConversionSceneNode* pScene, bool bCare)
{
size_t iCurrentMaterial = ~0;
CConversionMesh* pMesh = NULL;
CConversionSceneNode* pMeshNode = NULL;
size_t iAddV = 0;
size_t iAddE = 0;
size_t iAddUV = 0;
size_t iAddN = 0;
tstring sLastTask;
tstring sToken;
const tchar* pszNextLine = NULL;
while (pszLine < pszEnd)
{
if (pszNextLine)
pszLine = pszNextLine;
size_t iLineLength = tstrlen(pszLine);
pszNextLine = pszLine + iLineLength + 1;
// This code used to call StripWhitespace() but that's too slow for very large files w/ millions of lines.
// Instead we'll just cut the whitespace off the front and deal with whitespace on the end when we come to it.
while (*pszLine && IsWhitespace(*pszLine))
pszLine++;
if (tstrlen(pszLine) == 0)
continue;
const tchar* pszToken = pszLine;
while (*pszToken && *pszToken != ' ')
pszToken++;
sToken.reserve(iLineLength);
sToken.clear();
sToken.append(pszLine, pszToken-pszLine);
pszToken = sToken.c_str();
if (!bCare)
{
if (tstrncmp(pszToken, "-endShape", 9) == 0)
return pszNextLine;
else
continue;
}
if (tstrncmp(pszToken, "-snam", 5) == 0)
{
// We name our mesh.
tstring sName =pszLine+6;
tvector<tstring> aName;
tstrtok(sName, aName, "\""); // Strip out the quotation marks.
if (bCare)
{
size_t iMesh = m_pScene->FindMesh(aName[0].c_str());
if (iMesh == (size_t)~0)
{
iMesh = m_pScene->AddMesh(aName[0].c_str());
pMesh = m_pScene->GetMesh(iMesh);
pMesh->AddBone(aName[0].c_str());
}
else
{
pMesh = m_pScene->GetMesh(iMesh);
iAddV = pMesh->GetNumVertices();
iAddE = pMesh->GetNumEdges();
iAddUV = pMesh->GetNumUVs();
iAddN = pMesh->GetNumNormals();
}
// Make sure it exists.
pMeshNode = m_pScene->GetDefaultSceneMeshInstance(pScene, pMesh);
}
}
else if (tstrncmp(pszToken, "-vert", 5) == 0)
{
if (m_pWorkListener)
{
if (sLastTask == pszToken)
m_pWorkListener->WorkProgress(0);
else
{
m_pWorkListener->SetAction("Reading vertex data", 0);
sLastTask = tstring(pszToken);
}
}
// A vertex.
float v[3];
// scanf is pretty slow even for such a short string due to lots of mallocs.
const tchar* pszToken = pszLine+5;
int iDimension = 0;
while (*pszToken)
{
while (pszToken[0] == ' ')
pszToken++;
//.........这里部分代码省略.........
示例3: ReadOBJ
//.........这里部分代码省略.........
if (asTokens.size() == 4)
{
x = stof(asTokens[1]);
y = stof(asTokens[2]);
z = stof(asTokens[3]);
pMesh->AddNormal(x, y, z);
}
}
else if (tstrncmp(pszToken, _T("vt"), 3) == 0)
{
if (m_pWorkListener)
{
if (tstrncmp(sLastTask.c_str(), pszToken, sLastTask.length()) == 0)
m_pWorkListener->WorkProgress(0);
else
m_pWorkListener->SetAction(_T("Reading texture coordinate data"), 0);
}
sLastTask = tstring(pszToken);
// A UV coordinate for a vertex.
float u, v;
eastl::vector<tstring> asTokens;
tstrtok(pszLine, asTokens, _T(" "));
if (asTokens.size() == 3)
{
u = stof(asTokens[1]);
v = stof(asTokens[2]);
pMesh->AddUV(u, v);
}
}
else if (tstrncmp(pszToken, _T("g"), 1) == 0)
{
// A group of faces.
pMesh->AddBone(pszLine+2);
}
else if (tstrncmp(pszToken, _T("usemtl"), 6) == 0)
{
// All following faces should use this material.
tstring sMaterial = tstring(pszLine+7);
size_t iMaterial = pMesh->FindMaterialStub(sMaterial);
if (iMaterial == ((size_t)~0))
{
size_t iSceneMaterial = m_pScene->FindMaterial(sMaterial);
if (iSceneMaterial == ((size_t)~0))
iCurrentMaterial = m_pScene->AddDefaultSceneMaterial(pScene, pMesh, sMaterial);
else
{
size_t iMaterialStub = pMesh->AddMaterialStub(sMaterial);
m_pScene->GetDefaultSceneMeshInstance(pScene, pMesh)->GetMeshInstance(0)->AddMappedMaterial(iMaterialStub, iSceneMaterial);
iCurrentMaterial = iMaterialStub;
}
}
else
iCurrentMaterial = iMaterial;
}
else if (tstrncmp(pszToken, _T("s"), 1) == 0)
{
if (tstrncmp(pszLine, _T("s off"), 5) == 0)
{
iSmoothingGroup = ~0;
}
else
{
bSmoothingGroups = true;
eastl::vector<tstring> asTokens;
tstrtok(pszLine, asTokens, _T(" "));
示例4: ReadDAE
//.........这里部分代码省略.........
pMaterial->m_sDiffuseTexture = convert_from_fstring(pImage->GetFilename());
// Fix up a bug in the Max Collada exporter
if (pMaterial->m_sDiffuseTexture.startswith("\\\\C\\"))
pMaterial->m_sDiffuseTexture = "C:\\" + pMaterial->m_sDiffuseTexture.substr(4);
else if (pMaterial->m_sDiffuseTexture.startswith("\\\\D\\"))
pMaterial->m_sDiffuseTexture = "D:\\" + pMaterial->m_sDiffuseTexture.substr(4);
}
}
}
}
}
if (m_pWorkListener)
m_pWorkListener->WorkProgress(i+1);
}
FCDGeometryLibrary* pGeoLib = pDoc->GetGeometryLibrary();
iEntities = pGeoLib->GetEntityCount();
if (m_pWorkListener)
m_pWorkListener->SetAction("Loading entities", iEntities);
for (i = 0; i < iEntities; ++i)
{
FCDGeometry* pGeometry = pGeoLib->GetEntity(i);
if (pGeometry->IsMesh())
{
size_t j;
size_t iMesh = m_pScene->AddMesh(convert_from_fstring(pGeometry->GetName()));
CConversionMesh* pMesh = m_pScene->GetMesh(iMesh);
pMesh->AddBone(convert_from_fstring(pGeometry->GetName()));
FCDGeometryMesh* pGeoMesh = pGeometry->GetMesh();
FCDGeometrySource* pPositionSource = pGeoMesh->GetPositionSource();
size_t iVertexCount = pPositionSource->GetValueCount();
for (j = 0; j < iVertexCount; j++)
{
const float* pflValues = pPositionSource->GetValue(j);
pMesh->AddVertex(pflValues[0], pflValues[1], pflValues[2]);
}
FCDGeometrySource* pNormalSource = pGeoMesh->FindSourceByType(FUDaeGeometryInput::NORMAL);
if (pNormalSource)
{
iVertexCount = pNormalSource->GetValueCount();
for (j = 0; j < iVertexCount; j++)
{
const float* pflValues = pNormalSource->GetValue(j);
pMesh->AddNormal(pflValues[0], pflValues[1], pflValues[2]);
}
}
FCDGeometrySource* pUVSource = pGeoMesh->FindSourceByType(FUDaeGeometryInput::TEXCOORD);
if (pUVSource)
{
iVertexCount = pUVSource->GetValueCount();
for (j = 0; j < iVertexCount; j++)
{
const float* pflValues = pUVSource->GetValue(j);
pMesh->AddUV(pflValues[0], pflValues[1]);
}
}