// Bake light properties. bool LightCache::Initialize(const FbxLight * pLight, FbxAnimLayer * pAnimLayer) { mType = pLight->LightType.Get(); FbxPropertyT<FbxDouble3> lColorProperty = pLight->Color; FbxDouble3 lLightColor = lColorProperty.Get(); mColorRed.mValue = static_cast<float>(lLightColor[0]); mColorGreen.mValue = static_cast<float>(lLightColor[1]); mColorBlue.mValue = static_cast<float>(lLightColor[2]); if (pAnimLayer) { mColorRed.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_RED); mColorGreen.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_GREEN); mColorBlue.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_BLUE); } if (mType == FbxLight::eSpot) { FbxPropertyT<FbxDouble> lConeAngleProperty = pLight->InnerAngle; mConeAngle.mValue = static_cast<GLfloat>(lConeAngleProperty.Get()); if (pAnimLayer) mConeAngle.mAnimCurve = lConeAngleProperty.GetCurve(pAnimLayer); } return true; }
void readRotationElement(FbxPropertyT<FbxDouble3>& prop, EFbxRotationOrder fbxRotOrder, bool quatInterpolate, osgAnimation::UpdateMatrixTransform* pUpdate, osg::Matrix& staticTransform, FbxScene& fbxScene) { if (isAnimated(prop, fbxScene)) { if (quatInterpolate) { if (!staticTransform.isIdentity()) { pUpdate->getStackedTransforms().push_back( new osgAnimation::StackedMatrixElement(staticTransform)); staticTransform.makeIdentity(); } pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedQuaternionElement( "quaternion", makeQuat(prop.Get(), fbxRotOrder))); } else { const char* curveNames[3] = {FBXSDK_CURVENODE_COMPONENT_X, FBXSDK_CURVENODE_COMPONENT_Y, FBXSDK_CURVENODE_COMPONENT_Z}; osg::Vec3 axes[3] = {osg::Vec3(1,0,0), osg::Vec3(0,1,0), osg::Vec3(0,0,1)}; FbxDouble3 fbxPropValue = prop.Get(); fbxPropValue[0] = osg::DegreesToRadians(fbxPropValue[0]); fbxPropValue[1] = osg::DegreesToRadians(fbxPropValue[1]); fbxPropValue[2] = osg::DegreesToRadians(fbxPropValue[2]); int order[3] = {0, 1, 2}; getRotationOrder(fbxRotOrder, order); for (int i = 0; i < 3; ++i) { int j = order[2-i]; if (isAnimated(prop, curveNames[j], fbxScene)) { if (!staticTransform.isIdentity()) { pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedMatrixElement(staticTransform)); staticTransform.makeIdentity(); } pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement( std::string("rotate") + curveNames[j], axes[j], fbxPropValue[j])); } else { staticTransform.preMultRotate(osg::Quat(fbxPropValue[j], axes[j])); } } } } else { staticTransform.preMultRotate(makeQuat(prop.Get(), fbxRotOrder)); } }
babylon_vector3 extractColorAndTexture(const FbxPropertyT<FbxDouble3>& colorRGB, const FbxPropertyT<FbxDouble>& factorProp, std::shared_ptr<babylon_texture>& oTexture, TextureFormat desiredTextureFormat, const std::wstring& srcDir, const std::wstring& outdir){ babylon_vector3 color(0,0,0); if (colorRGB.IsValid()){ auto ambient = colorRGB.Get(); float factor = 1; if (factorProp.IsValid()){ factor = (float) factorProp.Get(); } color.x = (float) (ambient[0] * factor); color.y = (float) (ambient[1] * factor); color.z = (float) (ambient[2] * factor); auto texture = colorRGB.GetSrcObject<FbxFileTexture>(); if (texture){ std::string relativeFileName(texture->GetRelativeFileName()); std::wstring wsourceFile(srcDir); if (*wsourceFile.rbegin() != L'\\'){ wsourceFile.push_back(L'\\'); } wsourceFile.append(std::begin(relativeFileName), std::end(relativeFileName)); // check if file exists DWORD attrib = GetFileAttributes(wsourceFile.c_str()); if (attrib != 0xFFFFFFFF) { oTexture.reset(new babylon_texture()); std::transform(relativeFileName.begin(), relativeFileName.end(), relativeFileName.begin(), [](char c){return (char) tolower(c); }); oTexture->name = relativeFileName; oTexture->hasAlpha = texture->GetAlphaSource() != FbxTexture::eNone; TextureFormat sourceTextureFormat = getTextureFormatFromFileName(relativeFileName); if (sourceTextureFormat == desiredTextureFormat){ std::wstring wdestFile(outdir); if (*wdestFile.rbegin() != L'\\'){ wdestFile.push_back(L'\\'); } wdestFile.append(std::wstring(relativeFileName.begin(), relativeFileName.end())); CopyFile(wsourceFile.c_str(), wdestFile.c_str(), true); } else{ changeFileNameForFormat(relativeFileName, desiredTextureFormat); oTexture->name = relativeFileName; std::wstring wdestFile(outdir); if (*wdestFile.rbegin() != L'\\'){ wdestFile.push_back(L'\\'); } wdestFile.append(std::wstring(relativeFileName.begin(), relativeFileName.end())); convertTexture(wsourceFile, wdestFile, sourceTextureFormat, desiredTextureFormat, oTexture->hasAlpha); } } } } return color; }
void readScaleElement(FbxPropertyT<FbxDouble3>& prop, osgAnimation::UpdateMatrixTransform* pUpdate, osg::Matrix& staticTransform, FbxScene& fbxScene) { FbxDouble3 fbxPropValue = prop.Get(); osg::Vec3d val( fbxPropValue[0], fbxPropValue[1], fbxPropValue[2]); if (isAnimated(prop, fbxScene)) { if (!staticTransform.isIdentity()) { pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedMatrixElement(staticTransform)); staticTransform.makeIdentity(); } pUpdate->getStackedTransforms().push_back(new osgAnimation::StackedScaleElement("scale", val)); } else { staticTransform.preMultScale(val); } }
BTHFBX_VEC3 FBXScene::GetMaterialColor2(FbxPropertyT<FbxDouble3> FBXColorProperty, FbxPropertyT<FbxDouble> FBXFactorProperty) { BTHFBX_VEC3 Color; if( FBXColorProperty.IsValid() ) { FbxDouble3 FBXColor = FBXColorProperty.Get(); Color = BTHFBX_VEC3( (float)FBXColor[0], (float)FBXColor[1], (float)FBXColor[2] ); if( FBXFactorProperty.IsValid() ) { float FBXFactor = (float)FBXFactorProperty.Get(); Color.x *= FBXFactor; Color.y *= FBXFactor; Color.z *= FBXFactor; } } return Color; }
void ofxFBXScene::parseRotationCurve(ofxFBXNode & node, FbxAnimLayer * pAnimLayer, FbxNode* fbxNode, FbxPropertyT<FbxDouble3> &rotation){ node.originalRotation = ofQuaternion(rotation.Get().mData[0], ofVec3f(1, 0, 0), rotation.Get().mData[1], ofVec3f(0, 1, 0), rotation.Get().mData[2], ofVec3f(0, 0, 1)); node.getNode().setOrientation(node.originalRotation); ofLogVerbose("ofxFBXScene") << "original rotation " << endl << node.originalRotation << endl; if(!rotation.GetCurve(pAnimLayer)) return; FbxAnimCurve* lAnimCurveX = rotation.GetCurve(pAnimLayer,"X"); FbxAnimCurve* lAnimCurveY = rotation.GetCurve(pAnimLayer,"Y"); FbxAnimCurve* lAnimCurveZ = rotation.GetCurve(pAnimLayer,"Z"); int xKeyCount = lAnimCurveX ? lAnimCurveX->KeyGetCount() : 0; int yKeyCount = lAnimCurveY ? lAnimCurveY->KeyGetCount() : 0; int zKeyCount = lAnimCurveZ ? lAnimCurveZ->KeyGetCount() : 0; FbxTime lKeyTime; int lCount; FbxTime lXKeyTime,lYKeyTime,lZKeyTime; for(lCount = 0; lCount < max(max(xKeyCount,yKeyCount),zKeyCount); lCount++) { if(lCount<xKeyCount){ lXKeyTime = lAnimCurveX->KeyGetTime(lCount); } if(lCount<yKeyCount){ lYKeyTime = lAnimCurveY->KeyGetTime(lCount); } if(lCount<zKeyCount){ lZKeyTime = lAnimCurveZ->KeyGetTime(lCount); } lKeyTime = min(min(lXKeyTime,lYKeyTime),lZKeyTime); lKeyTime = lXKeyTime; FbxAMatrix & matrix = fbxNode->EvaluateLocalTransform(lKeyTime); ofxFBXKey<ofQuaternion> key; ofVec3f t,s; ofQuaternion so; ofMatrix4x4 m = toOf(matrix); m.decompose(t,key.value,s,so); key.timeMillis = lKeyTime.GetMilliSeconds(); node.rotationKeys.push_back(key); } }
void ofxFBXScene::parsePositionCurve(ofxFBXNode & node, FbxAnimLayer * pAnimLayer, FbxPropertyT<FbxDouble3> &position){ node.originalPosition = toOf(position.Get()); node.getNode().setPosition(node.originalPosition); ofLogVerbose("ofxFBXScene") << "original position " << node.originalPosition << endl; if(!position.GetCurve(pAnimLayer)) return; FbxAnimCurve* lAnimCurveX = position.GetCurve(pAnimLayer,"X"); FbxAnimCurve* lAnimCurveY = position.GetCurve(pAnimLayer,"Y"); FbxAnimCurve* lAnimCurveZ = position.GetCurve(pAnimLayer,"Z"); FbxTime lKeyTime; int lCount; int xKeyCount = lAnimCurveX? lAnimCurveX->KeyGetCount() : 0; int yKeyCount = lAnimCurveY? lAnimCurveY->KeyGetCount() : 0; int zKeyCount = lAnimCurveZ? lAnimCurveZ->KeyGetCount() : 0; ofxFBXKey<float> key; for(lCount = 0; lCount < xKeyCount; lCount++) { key.value = lAnimCurveX->KeyGetValue(lCount); lKeyTime = lAnimCurveX->KeyGetTime(lCount); key.timeMillis = lKeyTime.GetMilliSeconds(); node.xKeys.push_back(key); } for(lCount = 0; lCount < yKeyCount; lCount++) { key.value = lAnimCurveY->KeyGetValue(lCount); lKeyTime = lAnimCurveY->KeyGetTime(lCount); key.timeMillis = lKeyTime.GetMilliSeconds(); node.yKeys.push_back(key); } for(lCount = 0; lCount < zKeyCount; lCount++) { key.value = lAnimCurveZ->KeyGetValue(lCount); lKeyTime = lAnimCurveZ->KeyGetTime(lCount); key.timeMillis = lKeyTime.GetMilliSeconds(); node.zKeys.push_back(key); } }
//-------------------------------------------------------------------------------------- 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); } }
//------------------------------------------------------------------------------------------------------------------------------------------- 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); } } LOG_DEBUG << "Transfer materials successfully! "; }
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(); FbxString fbxName = fbxType.GetName(); if( FbxBoolDT == fbxType ) { DisplayCommon::DisplayBool( " Bool: ", fbxProp.Get<FbxBool>() ); } else if( FbxIntDT == fbxType || FbxEnumDT == fbxType ) { DisplayCommon::DisplayInt( " Int: ", fbxProp.Get<FbxInt>() ); } else if( FbxFloatDT == fbxType ) { DisplayCommon::DisplayDouble( " Float: ", fbxProp.Get<FbxFloat>() ); } else if( FbxDoubleDT == fbxType ) { DisplayCommon::DisplayDouble( " Double: ", fbxProp.Get<FbxDouble>() ); } else if( FbxStringDT == fbxType || FbxUrlDT == fbxType || FbxXRefUrlDT == fbxType ) { DisplayCommon::DisplayString( " String: ", fbxProp.Get<FbxString>().Buffer() ); } else if( FbxDouble2DT == fbxType ) { FbxDouble2 double2 = fbxProp.Get<FbxDouble2>(); FbxVector2 vector; vector[0] = double2[0]; vector[1] = double2[1]; DisplayCommon::Display2DVector( " 2D vector: ", vector ); } else if( (FbxDouble3DT == fbxType) || (FbxColor3DT == fbxType) ) { FbxDouble3 double3 = fbxProp.Get<FbxDouble3>(); FbxVector4 vector; vector[0] = double3[0]; 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 double1 = ((FbxSurfacePhong *) material)->ReflectionFactor; DisplayCommon::DisplayDouble( " Reflectivity: ", double1.Get() ); } else if( material->GetClassId().Is(FbxSurfaceLambert::ClassId) ) { // We found a Lambert material. Display its properties. // Display the Ambient Color double3 = ((FbxSurfaceLambert *)material)->Ambient; theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] ); DisplayCommon::DisplayColor( " Ambient: ", theColor ); // Display the Diffuse Color double3 = ((FbxSurfaceLambert *)material)->Diffuse; theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] ); DisplayCommon::DisplayColor( " Diffuse: ", theColor ); // Display the Emissive double3 = ((FbxSurfaceLambert *)material)->Emissive; theColor.Set( double3.Get()[0], double3.Get()[1], double3.Get()[2] ); DisplayCommon::DisplayColor( " Emissive: ", theColor ); // Display the Opacity double1 = ((FbxSurfaceLambert *)material)->TransparencyFactor; DisplayCommon::DisplayDouble( " Opacity: ", 1.0-double1.Get() ); } else DisplayCommon::DisplayString( "Unknown type of Material" ); FbxPropertyT<FbxString> string; string = material->ShadingModel; DisplayCommon::DisplayString( " Shading Model: ", string.Get() ); } } }