本文整理汇总了C++中FbxSurfaceMaterial::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ FbxSurfaceMaterial::GetName方法的具体用法?C++ FbxSurfaceMaterial::GetName怎么用?C++ FbxSurfaceMaterial::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FbxSurfaceMaterial
的用法示例。
在下文中一共展示了FbxSurfaceMaterial::GetName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MapMaterials
void MaterialHandler::MapMaterials(FbxNode * pNode, SceneMap * sceneMap)
{
//Recursively extract the children
for (int j = 0; j < pNode->GetChildCount(); j++)
MapMaterials(pNode->GetChild(j), sceneMap);
FbxGeometry* pGeometry = pNode->GetGeometry();
int materialCount = 0;
FbxNode* node = NULL;
if (pGeometry) {
node = pGeometry->GetNode();
if (node)
materialCount = pNode->GetMaterialCount();
if (materialCount > 0)
{
for (int i = 0; i < materialCount; i++)
{
if (pNode->GetMaterial(i))
{
FbxSurfaceMaterial *pMaterial = node->GetMaterial(i);
std::cout << pMaterial->GetName() << "\n";
if (sceneMap->materialHash.find(pMaterial->GetName()) == sceneMap->materialHash.end()) {
// not found
std::cout << "New material found! mapping..\n";
sceneMap->materialHash[pMaterial->GetName()] = sceneMap->materialID;
sceneMap->materialID += 1;
}
else {
// found
std::cout << "Material " << pMaterial->GetName() << " already exist .. skipping mapping of material" << std::endl;
}
//ProcessData(pMaterial, materialCount, outputMat);
}
}
}
}
}
示例2: loadMaterial
void FBXSceneEncoder::loadMaterial(FbxNode* fbxNode)
{
Node* node = findNode(fbxNode);
Model* model = (node) ? node->getModel() : NULL;
const int materialCount = fbxNode->GetMaterialCount();
for (int index = 0; index < materialCount; ++index)
{
FbxSurfaceMaterial* fbxMaterial = fbxNode->GetMaterial(index);
string materialName(fbxMaterial->GetName());
fixMaterialName(materialName);
Material* material = NULL;
map<string, Material*>::iterator it = _materials.find(materialName);
if (it != _materials.end())
{
// This material was already loaded so don't load it again
material = it->second;
}
else
{
if (EncoderArguments::getInstance()->outputMaterialEnabled())
{
material = createMaterial(materialName, fbxMaterial, node);
}
else
{
// If outputMaterialEnabled() is not enabled then only create the materials for the purpose of writing
// the material name in the GPB file. There is no need to load uniforms and samplers for the material.
material = new Material(materialName);
}
_materials[materialName] = material;
}
if (materialCount == 1 && material && model)
{
model->setMaterial(material); // TODO: add support for materials per mesh part
}
else if (materialCount > 1 && material && model)
{
model->setMaterial(material, index);
}
}
const int childCount = fbxNode->GetChildCount();
for (int i = 0; i < childCount; ++i)
{
FbxNode* childNode = fbxNode->GetChild(i);
if (childNode)
{
loadMaterial(childNode);
}
}
}
示例3: BindMaterial
void FbxLoader::BindMaterial(FbxNode* node, Node& meshNode)
{
const int materialCount = node->GetMaterialCount();
meshNode.materialNames.resize(materialCount);
for(int i = 0; i < materialCount; i++) {
FbxSurfaceMaterial* surfaceMaterial = node->GetMaterial(i);
auto name = surfaceMaterial->GetName();
meshNode.materialNames[i] = name;
if(materials[name].normalMapName != "")
meshNode.useNormalMap = true;
}
}
示例4: LoadMaterialAttributes
void FBXImporter::LoadMaterialAttributes(FBXMeshData* fbxMeshData)
{
// Get the name of material.
FbxSurfaceMaterial* surfaceMaterial = fbxMeshData->mSurfaceMaterial;
const char* materialName = surfaceMaterial->GetName();
// Phong material
if (surfaceMaterial->GetClassId().Is(FbxSurfacePhong::ClassId))
{
// Ambient color.
FbxDouble3 ambient = ((FbxSurfacePhong*)surfaceMaterial)->Ambient;
// Diffuse color.
FbxDouble3 diffuse = ((FbxSurfacePhong*)surfaceMaterial)->Diffuse;
// Specular color.
FbxDouble3 specular = ((FbxSurfacePhong*)surfaceMaterial)->Specular;
// Emissive color.
FbxDouble3 emissive = ((FbxSurfacePhong*)surfaceMaterial)->Emissive;
// Opacity.
FbxDouble opacity = ((FbxSurfacePhong*)surfaceMaterial)->TransparencyFactor;
// Shininess.
FbxDouble shininess = ((FbxSurfacePhong*)surfaceMaterial)->Shininess;
// Reflectivety.
FbxDouble reflectiveity = ((FbxSurfacePhong*)surfaceMaterial)->ReflectionFactor;
}
// Lambert material.
if (surfaceMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId))
{
// Ambient color.
FbxDouble3 ambient = ((FbxSurfaceLambert*)surfaceMaterial)->Ambient;
// Diffuse color.
FbxDouble3 diffuse = ((FbxSurfaceLambert*)surfaceMaterial)->Diffuse;
// Emissive color.
FbxDouble3 emissive = ((FbxSurfaceLambert*)surfaceMaterial)->Emissive;
// Opacity.
FbxDouble opacity = ((FbxSurfaceLambert*)surfaceMaterial)->TransparencyFactor;
}
}
示例5: LoadMaterial
void FbxUtil::LoadMaterial(const SceneNode::Ptr &ntNode, FbxNode *fbxNode)
{
if (fbxNode->GetMaterialCount() > 0)
{
FbxSurfaceMaterial *fbxMaterial = fbxNode->GetMaterial(0);
// only supports phong material
if (fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId))
{
Material::Ptr material = EntityUtil::Instance()->FindEntity<Material>(fbxMaterial->GetName());
if (material == nullptr)
{
material = CreateMaterial(fbxMaterial);
EntityUtil::Instance()->AddEntity(material);
}
if (auto ptr = ntNode->GetComponent<MeshRender>())
ptr->SetMaterial(material);
}
}
}
示例6: supported
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
bool UnFbx::FFbxImporter::CreateAndLinkExpressionForMaterialProperty(
FbxSurfaceMaterial& FbxMaterial,
UMaterial* UnrealMaterial,
const char* MaterialProperty ,
FExpressionInput& MaterialInput,
bool bSetupAsNormalMap,
TArray<FString>& UVSet )
{
bool bCreated = false;
FbxProperty FbxProperty = FbxMaterial.FindProperty( MaterialProperty );
if( FbxProperty.IsValid() )
{
int32 LayeredTextureCount = FbxProperty.GetSrcObjectCount(FbxLayeredTexture::ClassId);
if (LayeredTextureCount>0)
{
UE_LOG(LogFbxMaterialImport, Warning,TEXT("Layered TEXTures are not supported (material %s)"),ANSI_TO_TCHAR(FbxMaterial.GetName()));
}
else
{
int32 TextureCount = FbxProperty.GetSrcObjectCount(FbxTexture::ClassId);
if (TextureCount>0)
{
for(int32 TextureIndex =0; TextureIndex<TextureCount; ++TextureIndex)
{
FbxFileTexture* FbxTexture = FbxProperty.GetSrcObject(FBX_TYPE(FbxFileTexture), TextureIndex);
// create an unreal texture asset
UTexture* UnrealTexture = ImportTexture(FbxTexture, bSetupAsNormalMap);
if (UnrealTexture)
{
// and link it to the material
UMaterialExpressionTextureSample* UnrealTextureExpression = ConstructObject<UMaterialExpressionTextureSample>( UMaterialExpressionTextureSample::StaticClass(), UnrealMaterial );
UnrealMaterial->Expressions.Add( UnrealTextureExpression );
MaterialInput.Expression = UnrealTextureExpression;
UnrealTextureExpression->Texture = UnrealTexture;
UnrealTextureExpression->SamplerType = bSetupAsNormalMap ? SAMPLERTYPE_Normal : SAMPLERTYPE_Color;
// add/find UVSet and set it to the texture
FbxString UVSetName = FbxTexture->UVSet.Get();
FString LocalUVSetName = ANSI_TO_TCHAR(UVSetName.Buffer());
int32 SetIndex = UVSet.Find(LocalUVSetName);
UMaterialExpressionTextureCoordinate* MyCoordExpression = ConstructObject<UMaterialExpressionTextureCoordinate>( UMaterialExpressionTextureCoordinate::StaticClass(), UnrealMaterial );
UnrealMaterial->Expressions.Add( MyCoordExpression );
MyCoordExpression->CoordinateIndex = (SetIndex >= 0)? SetIndex: 0;
UnrealTextureExpression->Coordinates.Expression = MyCoordExpression;
if ( !bSetupAsNormalMap )
{
UnrealMaterial->BaseColor.Expression = UnrealTextureExpression;
}
else
{
UnrealMaterial->Normal.Expression = UnrealTextureExpression;
}
bCreated = true;
}
}
}
if (MaterialInput.Expression)
{
TArray<FExpressionOutput> Outputs = MaterialInput.Expression->GetOutputs();
FExpressionOutput* Output = Outputs.GetTypedData();
MaterialInput.Mask = Output->Mask;
MaterialInput.MaskR = Output->MaskR;
MaterialInput.MaskG = Output->MaskG;
MaterialInput.MaskB = Output->MaskB;
MaterialInput.MaskA = Output->MaskA;
}
}
}
return bCreated;
}
示例7: if
void Tools::DisplayMaterial::DisplayMaterial( FbxGeometry *i_geometry )
{
DisplayCommon::DisplayString( "\n\n--------------------\nMaterial\n--------------------" );
int materialCount = 0;
FbxNode *node = NULL;
if( i_geometry )
{
node = i_geometry->GetNode();
if( node )
materialCount = node->GetMaterialCount();
}
if( materialCount > 0 )
{
FbxPropertyT<FbxDouble3> double3;
FbxPropertyT<FbxDouble> double1;
FbxColor theColor;
for( int ctr = 0; ctr < materialCount; ctr++ )
{
DisplayCommon::DisplayInt( " Material ", ctr );
FbxSurfaceMaterial *material = node->GetMaterial( ctr );
DisplayCommon::DisplayString( " Name: \"", (char *) material->GetName(), "\"" );
#ifdef DISPLAY_HARDWARE_SHADER_INFORMATION
//Get the implementation to see if it's a hardware shader.
// Note:: this cause memory leak
const FbxImplementation* implementation = GetImplementation( material, FBXSDK_IMPLEMENTATION_HLSL );
FbxString implementationType = "HLSL";
if( !implementation )
{
implementation = GetImplementation( material, FBXSDK_IMPLEMENTATION_CGFX );
implementationType = "CGFX";
}
if( implementation )
{
//Now we have a hardware shader, let's read it
FBXSDK_printf( " Hardware Shader Type: %s\n", implemenationType.Buffer() );
DisplayCommon::DisplayString( " Hardware Shader Type: ", implemenationType );
const FbxBindingTable* rootTable = implementation->GetRootTable();
FbxString fileName = rootTable->DescAbsoluteURL.Get();
FbxString techniqueName = rootTable->DescTAG.Get();
const FbxBindingTable* table = implementation->GetRootTable();
size_t entryNum = table->GetEntryCount();
for( int i = 0; i < (int)entryNum; i++ )
{
const FbxBindingTableEntry& entry = table->GetEntry( i );
const char *entrySrcType = entry.GetEntryType( true );
FbxProperty fbxProp;
FbxString test = entry.GetSource();
FBXSDK_printf( " Entry: %s\n", test.Buffer() );
DisplayCommon::DisplayString( " Entry: %s\n", test );
if ( strcmp( FbxPropertyEntryView::sEntryType, entrySrcType ) == 0 )
{
fbxProp = material->FindPropertyHierarchical(entry.GetSource());
if( !fbxProp.IsValid() )
{
fbxProp = material->RootProperty.FindHierarchical( entry.GetSource() );
}
}
else if( strcmp( FbxConstantEntryView::sEntryType, entrySrcType ) == 0 )
{
fbxProp = implementation->GetConstants().FindHierarchical( entry.GetSource() );
}
if( fbxProp.IsValid() )
{
if( fbxProp.GetSrcObjectCount<FbxTexture>() > 0 )
{
//do what you want with the textures
for( int j = 0; j < fbxProp.GetSrcObjectCount<FbxFileTexture>(); j++ )
{
FbxFileTexture *tex = fbxProp.GetSrcObject<FbxFileTexture>( j );
FBXSDK_printf( " File Texture: %s\n", tex->GetFileName() );
DisplayCommon::DisplayString( " File Texture: %s\n", tex->GetFileName() );
}
for( int j = 0; j < fbxProp.GetSrcObjectCount<FbxLayeredTexture>(); j++ )
{
FbxLayeredTexture *tex = fbxProp.GetSrcObject<FbxLayeredTexture>( j );
FBXSDK_printf( " Layered Texture: %s\n", tex->GetName() );
DisplayCommon::DisplayString( " Layered Texture: %s\n", tex->GetName() );
}
for( int j = 0; j < fbxProp.GetSrcObjectCount<FbxProceduralTexture>(); j++ )
{
FbxProceduralTexture *tex = fbxProp.GetSrcObject<FbxProceduralTexture>( j );
FBXSDK_printf( " Procedural Texture: %s\n", tex->GetName() );
DisplayCommon::DisplayString( " Procedural Texture: %s\n", tex->GetName() );
}
}
else
{
FbxDataType fbxType = fbxProp.GetPropertyDataType();
//.........这里部分代码省略.........
示例8: FromFbxMesh
//converts a FBX mesh to a CC mesh
static ccMesh* FromFbxMesh(FbxMesh* fbxMesh, FileIOFilter::LoadParameters& parameters)
{
if (!fbxMesh)
return 0;
int polyCount = fbxMesh->GetPolygonCount();
//fbxMesh->GetLayer(
unsigned triCount = 0;
unsigned polyVertCount = 0; //different from vertCount (vertices can be counted multiple times here!)
//as we can't load all polygons (yet ;) we already look if we can load any!
{
unsigned skipped = 0;
for (int i=0; i<polyCount; ++i)
{
int pSize = fbxMesh->GetPolygonSize(i);
if (pSize == 3)
{
++triCount;
polyVertCount += 3;
}
else if (pSize == 4)
{
triCount += 2;
polyVertCount += 4;
}
else
{
++skipped;
}
}
if (triCount == 0)
{
ccLog::Warning(QString("[FBX] No triangle or quad found in mesh '%1'! (polygons with more than 4 vertices are not supported for the moment)").arg(fbxMesh->GetName()));
return 0;
}
else if (skipped != 0)
{
ccLog::Warning(QString("[FBX] Some polygons in mesh '%1' were ignored (%2): polygons with more than 4 vertices are not supported for the moment)").arg(fbxMesh->GetName()).arg(skipped));
return 0;
}
}
int vertCount = fbxMesh->GetControlPointsCount();
if (vertCount <= 0)
{
ccLog::Warning(QString("[FBX] Mesh '%1' has no vetex or no polygon?!").arg(fbxMesh->GetName()));
return 0;
}
ccPointCloud* vertices = new ccPointCloud("vertices");
ccMesh* mesh = new ccMesh(vertices);
mesh->setName(fbxMesh->GetName());
mesh->addChild(vertices);
vertices->setEnabled(false);
if (!mesh->reserve(static_cast<unsigned>(triCount)) || !vertices->reserve(vertCount))
{
ccLog::Warning(QString("[FBX] Not enough memory to load mesh '%1'!").arg(fbxMesh->GetName()));
delete mesh;
return 0;
}
//colors
{
for (int l=0; l<fbxMesh->GetElementVertexColorCount(); l++)
{
FbxGeometryElementVertexColor* vertColor = fbxMesh->GetElementVertexColor(l);
//CC can only handle per-vertex colors
if (vertColor->GetMappingMode() == FbxGeometryElement::eByControlPoint)
{
if (vertColor->GetReferenceMode() == FbxGeometryElement::eDirect
|| vertColor->GetReferenceMode() == FbxGeometryElement::eIndexToDirect)
{
if (vertices->reserveTheRGBTable())
{
switch (vertColor->GetReferenceMode())
{
case FbxGeometryElement::eDirect:
{
for (int i=0; i<vertCount; ++i)
{
FbxColor c = vertColor->GetDirectArray().GetAt(i);
vertices->addRGBColor( static_cast<colorType>(c.mRed * ccColor::MAX),
static_cast<colorType>(c.mGreen * ccColor::MAX),
static_cast<colorType>(c.mBlue * ccColor::MAX) );
}
}
break;
case FbxGeometryElement::eIndexToDirect:
{
for (int i=0; i<vertCount; ++i)
{
int id = vertColor->GetIndexArray().GetAt(i);
FbxColor c = vertColor->GetDirectArray().GetAt(id);
vertices->addRGBColor( static_cast<colorType>(c.mRed * ccColor::MAX),
static_cast<colorType>(c.mGreen * ccColor::MAX),
static_cast<colorType>(c.mBlue * ccColor::MAX) );
//.........这里部分代码省略.........
示例9: 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);
}