本文整理汇总了C++中FbxSurfaceMaterial::FindProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ FbxSurfaceMaterial::FindProperty方法的具体用法?C++ FbxSurfaceMaterial::FindProperty怎么用?C++ FbxSurfaceMaterial::FindProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FbxSurfaceMaterial
的用法示例。
在下文中一共展示了FbxSurfaceMaterial::FindProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMaterialAndTextureFileNames
void getMaterialAndTextureFileNames(FbxGeometry* fbxGeometry, std::vector<std::string>* out_textureFileNames,
Material* out_material) {
if (fbxGeometry->GetNode() == nullptr) {
return;
}
int numMaterials = fbxGeometry->GetNode()->GetSrcObjectCount(FbxSurfaceMaterial::ClassId);
for (int midx = 0; midx < numMaterials; ++midx){
FbxSurfaceMaterial *fbxMaterial = (FbxSurfaceMaterial *)fbxGeometry->GetNode()->GetSrcObject(FbxSurfaceMaterial::ClassId, midx);
if (fbxMaterial) {
getMaterialData(fbxMaterial, out_material);
// Go through all the possible textures
int tidx;
FBXSDK_FOR_EACH_TEXTURE(tidx) {
FbxProperty fbxTextureProperty = fbxMaterial->FindProperty(FbxLayerElement::sTextureChannelNames[tidx]);
std::vector<std::string>* tempTextureFileNames = findAndGetTextureInfoByProperty(fbxTextureProperty, midx);
for (int t = 0; t < tempTextureFileNames->size(); ++t) {
out_textureFileNames->push_back(tempTextureFileNames->at(t));
}
}
}//end if(fbxMaterial)
}// end for materialIndex
return;
}
示例2: getMaterial
reMaterial* reFBXAsset::getMaterial( FbxMesh* fmesh, int i, reMaterialSet& set)
{
reMaterial* mat = NULL;
for (int l = 0; l < fmesh->GetElementMaterialCount(); l++)
{
FbxGeometryElementMaterial* lMaterialElement = fmesh->GetElementMaterial(l);
int lMatId = lMaterialElement->GetIndexArray().GetAt(i);
if(lMatId >= 0)
{
if (mat = set.materialById(lMatId))
return mat;
mat = new reMaterial;
mat->id = lMatId;
set.addMetarial(mat);
FbxSurfaceMaterial* lMaterial = fmesh->GetNode()->GetMaterial(lMaterialElement->GetIndexArray().GetAt(i));
if (!lMaterial)
{
continue;
}
//////////////////////////////////////////////////////////////////////////
FbxProperty lProperty = lMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
if (lMaterial->GetClassId().Is(FbxSurfacePhong::ClassId))
{
FbxDouble3 lFbxDouble3;
lFbxDouble3 =((FbxSurfacePhong *)lMaterial)->Diffuse;
mat->diffuseColor = reColor4(lFbxDouble3[0], lFbxDouble3[1], lFbxDouble3[2], 1);
}
if (lMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId))
{
FbxDouble3 lFbxDouble3;
lFbxDouble3 =((FbxSurfaceLambert *)lMaterial)->Diffuse;
mat->diffuseColor = reColor4(lFbxDouble3[0], lFbxDouble3[1], lFbxDouble3[2], 1);
}
////////////////////////////////////////////////////////////////////////// read texture
int lNbTextures = lProperty.GetSrcObjectCount(FbxTexture::ClassId);
if (lNbTextures)
{
mat->diffuseTexture = new reTexture;
FbxTexture* lTexture = FbxCast <FbxTexture> (lProperty.GetSrcObject(FbxTexture::ClassId,0));
qDebug() << "map: " << lTexture->GetName();
FbxFileTexture *lFileTexture = FbxCast<FbxFileTexture>(lTexture);
if (lFileTexture)
{
mat->diffuseTexture->fileName(lFileTexture->GetFileName());
}
}
//////////////////////////////////////////////////////////////////////////
}
}
return mat;
}
示例3: transferTextures
//-------------------------------------------------------------------------------------------------------------------------------------------
void transferTextures(FbxGeometry* fbxMesh, Mesh* mesh)
{
FbxNode* fbxNode = fbxMesh->GetNode();
FbxProperty fbxProperty;
int numMaterials = fbxNode->GetSrcObjectCount<FbxSurfaceMaterial>();
for (int matId = 0; matId < numMaterials; matId++){
FbxSurfaceMaterial* fbxMaterial = fbxNode->GetSrcObject<FbxSurfaceMaterial>(matId);
Material* modelMaterial = mesh->Materials[matId];
if (fbxMaterial){
// Go through all the possible textures
for (int layerId = 0; layerId < FbxLayerElement::sTypeTextureCount; layerId++){
fbxProperty = fbxMaterial->FindProperty(FbxLayerElement::sTextureChannelNames[layerId]);
transferTextureByProperty(fbxProperty, matId, modelMaterial);
}
}
}
LOG_DEBUG << "Transfer materials successfully! ";
}
示例4: 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;
}
示例5: if
void UnFbx::FFbxImporter::ImportTexturesFromNode(FbxNode* Node)
{
FbxProperty Property;
int32 NbMat = Node->GetMaterialCount();
// visit all materials
int32 MaterialIndex;
for (MaterialIndex = 0; MaterialIndex < NbMat; MaterialIndex++)
{
FbxSurfaceMaterial *Material = Node->GetMaterial(MaterialIndex);
//go through all the possible textures
if(Material)
{
int32 TextureIndex;
FBXSDK_FOR_EACH_TEXTURE(TextureIndex)
{
Property = Material->FindProperty(FbxLayerElement::sTextureChannelNames[TextureIndex]);
if( Property.IsValid() )
{
FbxTexture * lTexture= NULL;
//Here we have to check if it's layered textures, or just textures:
int32 LayeredTextureCount = Property.GetSrcObjectCount(FbxLayeredTexture::ClassId);
FbxString PropertyName = Property.GetName();
if(LayeredTextureCount > 0)
{
for(int32 LayerIndex=0; LayerIndex<LayeredTextureCount; ++LayerIndex)
{
FbxLayeredTexture *lLayeredTexture = FbxCast <FbxLayeredTexture>(Property.GetSrcObject(FbxLayeredTexture::ClassId, LayerIndex));
int32 NbTextures = lLayeredTexture->GetSrcObjectCount(FbxTexture::ClassId);
for(int32 TexIndex =0; TexIndex<NbTextures; ++TexIndex)
{
FbxFileTexture* Texture = FbxCast <FbxFileTexture> (lLayeredTexture->GetSrcObject(FbxFileTexture::ClassId,TexIndex));
if(Texture)
{
ImportTexture(Texture, PropertyName == FbxSurfaceMaterial::sNormalMap || PropertyName == FbxSurfaceMaterial::sBump);
}
}
}
}
else
{
//no layered texture simply get on the property
int32 NbTextures = Property.GetSrcObjectCount(FbxTexture::ClassId);
for(int32 TexIndex =0; TexIndex<NbTextures; ++TexIndex)
{
FbxFileTexture* Texture = FbxCast <FbxFileTexture> (Property.GetSrcObject(FbxFileTexture::ClassId,TexIndex));
if(Texture)
{
ImportTexture(Texture, PropertyName == FbxSurfaceMaterial::sNormalMap || PropertyName == FbxSurfaceMaterial::sBump);
}
}
}
}
}
}//end if(Material)
}// end for MaterialIndex
}
示例6: ProcessMaterials
//--------------------------------------------------------------------------------------
void FBXScene::ProcessMaterials(FbxScene* pScene)
{
for( int i = 0; i < pScene->GetMaterialCount(); ++i )
{
Material* pMaterial = new Material(i);
FbxSurfaceMaterial* pFBXMaterial = pScene->GetMaterial(i);
FbxProperty diffuseTextureProperty = pFBXMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
if( diffuseTextureProperty.IsValid() )
{
FbxFileTexture* pDiffuseTexture = diffuseTextureProperty.GetSrcObject<FbxFileTexture>(0);
if( pDiffuseTexture )
{
std::string strFileName = pDiffuseTexture->GetFileName();
if( strFileName.length() == 0 )
strFileName = pDiffuseTexture->GetRelativeFileName();
strFileName = GetFileFromPath(strFileName);
pMaterial->SetDiffuseTextureName(strFileName);
}
}
FbxProperty normalTextureProperty = pFBXMaterial->FindProperty(FbxSurfaceMaterial::sNormalMap);
if( normalTextureProperty.IsValid() )
{
FbxFileTexture* pNormalTexture = normalTextureProperty.GetSrcObject<FbxFileTexture>(0);
if( pNormalTexture )
{
std::string strFileName = pNormalTexture->GetFileName();
if( strFileName.length() == 0 )
strFileName = pNormalTexture->GetRelativeFileName();
strFileName = GetFileFromPath(strFileName);
pMaterial->SetNormalTextureName(strFileName);
}
}
FbxSurfaceLambert* pLambert = FbxCast<FbxSurfaceLambert>(pFBXMaterial);
FbxSurfacePhong* pPhong = FbxCast<FbxSurfacePhong>(pFBXMaterial);
BTHFBX_VEC3 AmbientColor2;
BTHFBX_VEC3 EmissiveColor2;
BTHFBX_VEC3 DiffuseColor2;
BTHFBX_VEC3 SpecularColor2;
float fSpecularPower = 1.0f;
float fTransparency = 1.0f;
if( pLambert )
{
AmbientColor2 = GetMaterialColor2(pLambert->Ambient, pLambert->AmbientFactor);
EmissiveColor2 = GetMaterialColor2(pLambert->Emissive, pLambert->EmissiveFactor);
DiffuseColor2 = GetMaterialColor2(pLambert->Diffuse, pLambert->DiffuseFactor);
FbxPropertyT<FbxDouble> FBXTransparencyProperty = pLambert->TransparencyFactor;
if( FBXTransparencyProperty.IsValid() )
fTransparency = (float)FBXTransparencyProperty.Get();
}
if( pPhong )
{
SpecularColor2 = GetMaterialColor2(pPhong->Specular, pPhong->SpecularFactor);
FbxPropertyT<FbxDouble> FBXSpecularPowerProperty = pPhong->Shininess;
if( FBXSpecularPowerProperty.IsValid() )
fSpecularPower = (float)FBXSpecularPowerProperty.Get();
}
pMaterial->SetAmbientColor2(AmbientColor2);
pMaterial->SetEmissiveColor2(EmissiveColor2);
pMaterial->SetDiffuseColor2(DiffuseColor2);
pMaterial->SetSpecularColor2(SpecularColor2);
pMaterial->SetSpecularPower(fSpecularPower);
pMaterial->SetTransparency(fTransparency);
pMaterial->AddTexturePath( GetFilePath(this->mFilename) + "/" );
m_Materials.push_back(pMaterial);
m_FBXMaterials.push_back(pFBXMaterial);
}
}
示例7: LoadMaterials
void MeshImporter::LoadMaterials(FbxNode* node, MeshEntry* mesh, ID3D11Device3* device,
ID3D11DeviceContext3* context)
{
int mcount = node->GetSrcObjectCount<FbxSurfaceMaterial>();
for (int index = 0; index < mcount; index++)
{
FbxSurfaceMaterial *material =
(FbxSurfaceMaterial*)node->GetSrcObject<FbxSurfaceMaterial>(index);
if (material)
{
// This only gets the material of type sDiffuse, you
// probably need to traverse all Standard Material Property
// by its name to get all possible textures.
FbxProperty prop = material->FindProperty(FbxSurfaceMaterial::sDiffuse);
// Check if it's layeredtextures
int layered_texture_count = prop.GetSrcObjectCount<FbxLayeredTexture>();
if (layered_texture_count > 0)
{
for (int j = 0; j < layered_texture_count; j++)
{
FbxLayeredTexture* layered_texture = FbxCast<FbxLayeredTexture>(prop.GetSrcObject<FbxLayeredTexture>(j));
int lcount = layered_texture->GetSrcObjectCount<FbxTexture>();
for (int k = 0; k < lcount; k++)
{
FbxTexture* texture =
FbxCast<FbxTexture>(layered_texture->GetSrcObject<FbxTexture>(k));
// Then, you can get all the properties of the texture, include its name
const char* texture_name = texture->GetName();
// Load files
LoadTexture(texture_name, mesh, device, context);
PrintTab(to_string(layered_texture_count) + " Layered textures loaded!" +
"Number of layers: " + to_string(lcount));
}
}
}
else
{
// Directly get textures
int texture_count = prop.GetSrcObjectCount<FbxTexture>();
for (int j = 0; j < texture_count; j++)
{
const FbxTexture* texture =
FbxCast<FbxTexture>(prop.GetSrcObject<FbxTexture>(j));
// Then, you can get all the properties of the texture, include its name
const char* texture_name = texture->GetName();
// Load file
LoadTexture(texture_name, mesh, device, context);
PrintTab(to_string(texture_count) + " Single texture loaded!");
}
}
}
}
}
示例8: FromFbxMesh
//.........这里部分代码省略.........
float diffuse[4];
float emission[4];
float specular[4];
FbxSurfacePhong* lPhongMat = isPhong ? static_cast<FbxSurfacePhong*>(lBaseMaterial) : 0;
for (int k=0; k<3; ++k)
{
ambient[k] = static_cast<float>(lLambertMat->Ambient.Get()[k]);
diffuse[k] = static_cast<float>(lLambertMat->Diffuse.Get()[k]);
emission[k] = static_cast<float>(lLambertMat->Emissive.Get()[k]);
if (lPhongMat)
{
specular[k] = static_cast<float>(lPhongMat->Specular.Get()[k]);
}
}
mat->setAmbient(ambient);
mat->setDiffuse(diffuse);
mat->setEmission(emission);
if (isPhong)
{
mat->setSpecular(specular);
assert(lPhongMat);
mat->setShininess(static_cast<float>(lPhongMat->Shininess));
}
//import associated texture (if any)
{
int lTextureIndex;
FBXSDK_FOR_EACH_TEXTURE(lTextureIndex)
{
FbxProperty lProperty = lBaseMaterial->FindProperty(FbxLayerElement::sTextureChannelNames[lTextureIndex]);
if( lProperty.IsValid() )
{
int lTextureCount = lProperty.GetSrcObjectCount<FbxTexture>();
FbxTexture* texture = 0; //we can handle only one texture per material! We'll take the non layered one by default (if any)
for (int j = 0; j < lTextureCount; ++j)
{
//Here we have to check if it's layeredtextures, or just textures:
FbxLayeredTexture *lLayeredTexture = lProperty.GetSrcObject<FbxLayeredTexture>(j);
if (lLayeredTexture)
{
//we don't handle layered textures!
/*int lNbTextures = lLayeredTexture->GetSrcObjectCount<FbxTexture>();
for (int k=0; k<lNbTextures; ++k)
{
FbxTexture* lTexture = lLayeredTexture->GetSrcObject<FbxTexture>(k);
if(lTexture)
{
}
}
//*/
}
else
{
//non-layered texture
FbxTexture* lTexture = lProperty.GetSrcObject<FbxTexture>(j);
if(lTexture)
{
//we take the first non layered texture by default
texture = lTexture;
break;
}
}
示例9: if
//.........这里部分代码省略.........
sceneNode->type = FbxString("drawable");
// Name
sceneNode->attributes.push_back(std::make_pair(FbxString("name"), node->GetName()));
// Transformation
FbxAMatrix m = node->EvaluateLocalTransform();
//FbxAMatrix m1 = node->EvaluateGlobalTransform();
const FbxVector4 translation = m.GetT();
const FbxVector4 rotation = m.GetR();
const FbxVector4 scaling = m.GetS();
float s[3], r[3], t[3];
t[0] = (float)translation.mData[0];
t[1] = (float)translation.mData[1];
t[2] = (float)translation.mData[2];
r[0] = (float)(rotation[0] * FBXSDK_DEG_TO_RAD);
r[1] = (float)(rotation[1] * FBXSDK_DEG_TO_RAD);
r[2] = (float)(rotation[2] * FBXSDK_DEG_TO_RAD);
s[0] = (float)scaling[0];
s[1] = (float)scaling[1];
s[2] = (float)scaling[2];
//const FbxVector4 translation1 = m1.GetT();
//const FbxVector4 rotation1 = m1.GetR();
//const FbxVector4 scaling1 = m1.GetS();
char buffer[1024];
FBXSDK_sprintf(buffer, 1024, "s:%8.5f,%8.5f,%8.5f,r:%8.5f,%8.5f,%8.5f,t:%8.5f,%8.5f,%8.5f",
s[0], s[1], s[2], r[0], r[1], r[2], t[0], t[1], t[2]);
sceneNode->attributes.push_back(std::make_pair(FbxString("transform"), FbxString(buffer)));
// Mesh
//if (node->GetNodeAttribute()->GetAttributeType() == FbxNodeAttribute::eCamera)
//{
// FBXSDK_printf("fuck");
//}
static FbxUInt32 i = 0;
if (node->GetMesh() == NULL)
{
sceneNode->type = FbxString("node");
}
else
{
const char *meshName = node->GetMesh()->GetName();
if (meshName == NULL || meshName[0] == 0)
{
meshName = node->GetName();
}
FbxString prefix;
if (meshName == NULL || meshName[0] == 0)
{
prefix = FbxString("mesh_") + FbxString(int(i++));
}
else
{
prefix = FbxString(meshName);
}
sceneNode->geometry = prefix + FbxString(".") + m_arguments->meshFormat;
// Material
FbxSurfaceMaterial *material = node->GetMaterial(0);
if (material != NULL)
{
// This only gets the material of type sDiffuse, you probably need to
// traverse all Standard Material Property by its name to get all
// possible textures.
FbxProperty prop = material->FindProperty(FbxSurfaceMaterial::sDiffuse);
// Check if it's layeredtextures
int layeredTextureCount = prop.GetSrcObjectCount<FbxLayeredTexture>();
if (prop.GetSrcObjectCount<FbxTexture>() > 0)
{
FbxFileTexture *lTex = prop.GetSrcObject<FbxFileTexture>(0);
FbxString filename = FbxPathUtils::GetFileName(lTex->GetFileName());
sceneNode->texture = filename.Lower();
m_textures.push_back(FbxString(lTex->GetFileName()));
}
// root node is not counted as a drawable.
m_numDrawables++;
}
}
}
}
}
return sceneNode;
}