本文整理汇总了C++中FbxSurfaceMaterial::GetClassId方法的典型用法代码示例。如果您正苦于以下问题:C++ FbxSurfaceMaterial::GetClassId方法的具体用法?C++ FbxSurfaceMaterial::GetClassId怎么用?C++ FbxSurfaceMaterial::GetClassId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FbxSurfaceMaterial
的用法示例。
在下文中一共展示了FbxSurfaceMaterial::GetClassId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: getMaterials
void Converter::getMaterials(FbxNode *n, std::vector<std::string> &textures, std::vector<PhongMaterial> &phongMats, std::vector<LambertMaterial> &lambertMats)
{
for (int i = 0; i < n->GetMaterialCount(); ++i) {
FbxSurfaceMaterial *material = n->GetMaterial(i);
getDiffuseTextures(material, textures);
if (material->GetClassId().Is(FbxSurfacePhong::ClassId)) {
phongMats.push_back(getPhongMaterial(material));
}
else if (material->GetClassId().Is(FbxSurfaceLambert::ClassId)) {
lambertMats.push_back(getLambertMaterial(material));
}
}
}
示例3: if
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
void UnFbx::FFbxImporter::FixupMaterial( FbxSurfaceMaterial& FbxMaterial, UMaterial* UnrealMaterial )
{
// add a basic diffuse color if no texture is linked to diffuse
if (UnrealMaterial->BaseColor.Expression == NULL)
{
FbxDouble3 DiffuseColor;
UMaterialExpressionVectorParameter* MyColorExpression = ConstructObject<UMaterialExpressionVectorParameter>( UMaterialExpressionVectorParameter::StaticClass(), UnrealMaterial );
UnrealMaterial->Expressions.Add( MyColorExpression );
UnrealMaterial->BaseColor.Expression = MyColorExpression;
bool bFoundDiffuseColor = true;
if( FbxMaterial.GetClassId().Is(FbxSurfacePhong::ClassId) )
{
DiffuseColor = ((FbxSurfacePhong&)(FbxMaterial)).Diffuse.Get();
}
else if( FbxMaterial.GetClassId().Is(FbxSurfaceLambert::ClassId) )
{
DiffuseColor = ((FbxSurfaceLambert&)(FbxMaterial)).Diffuse.Get();
}
else
{
bFoundDiffuseColor = false;
}
if( bFoundDiffuseColor )
{
MyColorExpression->DefaultValue.R = (float)(DiffuseColor[0]);
MyColorExpression->DefaultValue.G = (float)(DiffuseColor[1]);
MyColorExpression->DefaultValue.B = (float)(DiffuseColor[2]);
}
else
{
// use random color because there may be multiple materials, then they can be different
MyColorExpression->DefaultValue.R = 0.5f+(0.5f*FMath::Rand())/RAND_MAX;
MyColorExpression->DefaultValue.G = 0.5f+(0.5f*FMath::Rand())/RAND_MAX;
MyColorExpression->DefaultValue.B = 0.5f+(0.5f*FMath::Rand())/RAND_MAX;
}
TArray<FExpressionOutput> Outputs = UnrealMaterial->BaseColor.Expression->GetOutputs();
FExpressionOutput* Output = Outputs.GetTypedData();
UnrealMaterial->BaseColor.Mask = Output->Mask;
UnrealMaterial->BaseColor.MaskR = Output->MaskR;
UnrealMaterial->BaseColor.MaskG = Output->MaskG;
UnrealMaterial->BaseColor.MaskB = Output->MaskB;
UnrealMaterial->BaseColor.MaskA = Output->MaskA;
}
}
示例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: transferMaterials
//-------------------------------------------------------------------------------------------------------------------------------------------
void transferMaterials(FbxGeometry* fbxMesh, Mesh* mesh){
int numMaterials = 0;
if (fbxMesh == NULL){
throw new Exception("fbxMesh can not be NULL !");
}
FbxNode* fbxNode = NULL;
fbxNode = fbxMesh->GetNode();
if (fbxNode){
numMaterials = fbxNode->GetMaterialCount();
}
LOG_DEBUG << " Number of materials: " << numMaterials;
if (numMaterials > 0)
{
FbxPropertyT<FbxDouble3> lKFbxDouble3;
FbxPropertyT<FbxDouble> lKFbxDouble1;
FbxColor theColor;
for (int matId = 0; matId < numMaterials; matId++){
Material* material = new Material();
FbxSurfaceMaterial* fbxMaterial = fbxNode->GetMaterial(matId);
// Get the implementation to see f it's a hardware shader
const FbxImplementation* fbxImplementation = GetImplementation(fbxMaterial, FBXSDK_IMPLEMENTATION_HLSL);
string fbxImplementationType = "HLSL";
if (fbxImplementation != NULL){
fbxImplementation = GetImplementation(fbxMaterial, FBXSDK_IMPLEMENTATION_CGFX);
fbxImplementationType = "CFGX";
}
if (fbxImplementation)
{
// Handle hardware shader
// TODO: transfer material using hardware shader
}
else if (fbxMaterial->GetClassId().Is(FbxSurfacePhong::ClassId))
{
// Handle phong shader
// Transfer Ambient color
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->Ambient;
material->Ambient = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Transfer Diffuse color
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->Diffuse;
material->Diffuse = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Transfer Specular color
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->Specular;
material->Specular = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Transfer Emissive color
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->Emissive;
material->Emissive = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Transfer Transperency factor
lKFbxDouble1 = ((FbxSurfacePhong*)fbxMaterial)->TransparencyFactor;
material->Opacity = 1.0 - lKFbxDouble1.Get();
// Transfer Shininess
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->Shininess;
material->Shininess = lKFbxDouble1.Get();
// Transfer Reflectivity
lKFbxDouble3 = ((FbxSurfacePhong*)fbxMaterial)->ReflectionFactor;
material->Reflectivity = lKFbxDouble1.Get();
}
else if (fbxMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId))
{
// Handle Lambert shader
lKFbxDouble3 = ((FbxSurfaceLambert *)fbxMaterial)->Ambient;
material->Ambient = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Display the Diffuse Color
lKFbxDouble3 = ((FbxSurfaceLambert *)fbxMaterial)->Diffuse;
material->Diffuse = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Display the Emissive
lKFbxDouble3 = ((FbxSurfaceLambert *)fbxMaterial)->Emissive;
material->Emissive = Vector4s(lKFbxDouble3.Get()[0], lKFbxDouble3.Get()[1], lKFbxDouble3.Get()[2], 1);
// Display the Opacity
lKFbxDouble1 = ((FbxSurfaceLambert *)fbxMaterial)->TransparencyFactor;
material->Opacity = 1.0 - lKFbxDouble1.Get();
}
else
{
LOG_WARNING << "Unknown type of Material !";
}
FbxPropertyT<FbxString> fbxString;
fbxString = fbxMaterial->ShadingModel;
material->ShadingMode = fbxString.Get();
mesh->Materials.push_back(material);
}
//.........这里部分代码省略.........
示例7: if
//.........这里部分代码省略.........
vector[1] = double3[1];
vector[2] = double3[2];
DisplayCommon::Display3DVector( " 3D vector: ", vector );
}
else if( (FbxDouble4DT == fbxType) || (FbxColor4DT == fbxType) )
{
FbxDouble4 double4 = fbxProp.Get<FbxDouble4>();
FbxVector4 vector;
vector[0] = double4[0];
vector[1] = double4[1];
vector[2] = double4[2];
vector[3] = double4[3];
DisplayCommon::Display4DVector( " 4D vector: ", vector );
}
else if( FbxDouble4x4DT == fbxType )
{
FbxDouble4x4 double44 = fbxProp.Get<FbxDouble4x4>();
for( int j = 0; j < 4; j++ )
{
FbxVector4 vector;
vector[0] = double44[j][0];
vector[1] = double44[j][1];
vector[2] = double44[j][2];
vector[3] = double44[j][3];
DisplayCommon::Display4DVector( " 4x4D vector: ", vector );
}
}
}
}
}
}
else
#endif // #ifdef DISPLAY_HARDWARE_SHADER_INFORMATION
if( material->GetClassId().Is(FbxSurfacePhong::ClassId) )
{
// We found a Phong material. Display its properties.
// Display the Ambient Color
double3 = ((FbxSurfacePhong *) material)->Ambient;
theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] );
DisplayCommon::DisplayColor( " Ambient: ", theColor );
// Display the Diffuse Color
double3 = ((FbxSurfacePhong *) material)->Diffuse;
theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] );
DisplayCommon::DisplayColor( " Diffuse: ", theColor );
// Display the Specular Color (unique to Phong materials)
double3 = ((FbxSurfacePhong *) material)->Specular;
theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] );
DisplayCommon::DisplayColor( " Specular: ", theColor );
// Display the Emissive Color
double3 = ((FbxSurfacePhong *) material)->Emissive;
theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] );
DisplayCommon::DisplayColor( " Emissive: ", theColor );
//Opacity is Transparency factor now
double1 = ((FbxSurfacePhong *) material)->TransparencyFactor;
DisplayCommon::DisplayDouble( " Opacity: ", 1.0-double1.Get() );
// Display the Shininess
double1 = ((FbxSurfacePhong *) material)->Shininess;
DisplayCommon::DisplayDouble( " Shininess: ", double1.Get() );
// Display the Reflectivity
示例8: FromFbxMesh
//.........这里部分代码省略.........
perVertexNormals = -1;
perPolygonNormals = -1;
}
}
//per-triangle normals
NormsIndexesTableType* normsTable = 0;
if (perVertexNormals >= 0 || perPolygonNormals >= 0)
{
normsTable = new NormsIndexesTableType();
if (!normsTable->reserve(polyVertCount) || !mesh->reservePerTriangleNormalIndexes())
{
ccLog::Warning(QString("[FBX] Not enough memory to load mesh '%1' normals!").arg(fbxMesh->GetName()));
normsTable->release();
normsTable = 0;
}
else
{
mesh->setTriNormsTable(normsTable);
vertices->showNormals(true);
mesh->showNormals(true);
}
}
//materials
ccMaterialSet* materials = 0;
{
FbxNode* lNode = fbxMesh->GetNode();
int lMaterialCount = lNode ? lNode->GetMaterialCount() : 0;
for (int i=0; i<lMaterialCount; i++)
{
FbxSurfaceMaterial *lBaseMaterial = lNode->GetMaterial(i);
bool isLambert = lBaseMaterial->GetClassId().Is(FbxSurfaceLambert::ClassId);
bool isPhong = lBaseMaterial->GetClassId().Is(FbxSurfacePhong::ClassId);
if (isLambert || isPhong)
{
ccMaterial::Shared mat(new ccMaterial(lBaseMaterial->GetName()));
FbxSurfaceLambert* lLambertMat = static_cast<FbxSurfaceLambert*>(lBaseMaterial);
float ambient[4];
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);