本文整理汇总了C++中MeshBuilder::SetMaterialName方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBuilder::SetMaterialName方法的具体用法?C++ MeshBuilder::SetMaterialName怎么用?C++ MeshBuilder::SetMaterialName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder::SetMaterialName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportMesh
//THIS MUST HAPPEN AFTER IMPORTING SKELETONS.
//-----------------------------------------------------------------------------------
static void ImportMesh(SceneImport* import, FbxMesh* mesh, MatrixStack4x4& matrixStack, std::map<int, FbxNode*>& nodeToJointIndex)
{
MeshBuilder builder = MeshBuilder();
ASSERT_OR_DIE(mesh->IsTriangleMesh(), "Was unable to load the mesh, it's not a triangle mesh!");
Matrix4x4 geoTransform = GetGeometricTransform(mesh);
matrixStack.Push(geoTransform);
int controlPointCount = mesh->GetControlPointsCount();
//Figure out our weighs for all verts before importing any of them
std::vector<SkinWeight> skinWeights;
if (HasSkinWeights(mesh))
{
skinWeights.resize(controlPointCount);
GetSkinWeights(import, skinWeights, mesh, nodeToJointIndex);
}
else
{
FbxNode* node = mesh->GetNode();
//Walk tree up till you reach the node associated with that joint.
//Find the first parent node that has a joint associated with it
//All vertices (fully weighted)
//All Skin Weights = indices{jointINdex, 0, 0, 0 } weights{1.0f, 0.0f, 0.0f, 0.0f};
int jointIndex = Skeleton::INVALID_JOINT_INDEX;
for (auto iter = nodeToJointIndex.begin(); iter != nodeToJointIndex.end(); ++iter)
{
if (iter->second == node)
{
jointIndex = iter->first;
break;
}
}
if (jointIndex == Skeleton::INVALID_JOINT_INDEX)
{
for (unsigned int i = 0; i < skinWeights.size(); ++i)
{
skinWeights[i].indices = Vector4Int::ZERO;
skinWeights[i].weights = Vector4::UNIT_X;
}
}
else
{
for (unsigned int i = 0; i < skinWeights.size(); ++i)
{
skinWeights[i].indices = Vector4Int(jointIndex, 0, 0, 0);
skinWeights[i].weights = Vector4::UNIT_X;
}
}
}
builder.Begin();
{
Matrix4x4 transform = matrixStack.GetTop();
int polyCount = mesh->GetPolygonCount();
for (int polyIndex = 0; polyIndex < polyCount; ++polyIndex)
{
int vertCount = mesh->GetPolygonSize(polyIndex);
ASSERT_OR_DIE(vertCount == 3, "Vertex count was not 3");
for (int vertIndex = 0; vertIndex < vertCount; ++vertIndex)
{
ImportVertex(builder, transform, mesh, polyIndex, vertIndex, skinWeights);
}
}
}
builder.End();
FbxSurfaceMaterial* material = mesh->GetNode()->GetMaterial(0);
builder.SetMaterialName(material->GetName());
matrixStack.Pop();
import->meshes.push_back(builder);
}