Hi,
I have a fbx file with a model and material diffuse color animation.
If I load the file up in Maya, I can press the animation play button and see the material color animating. The model changes 5 colors.
The fbx is in binary and also in ascii format so I can look at the contents.
If I look at the ascii version, I can see that there is 1 AnimCuveNode for DiffuseColor
AnimationCurveNode: 930025792, "AnimCurveNode::DiffuseColor", "" {
Properties70: {
P: "d|X", "Number", "", "A",0.363935500383377
P: "d|Y", "Number", "", "A",0.0674999952316284
P: "d|Z", "Number", "", "A",0.5
}
}
This is the data for the first color, however I don't see any data anywhere that represents the remaining 4 colors.
How do you get animation data for the material diffuse color ?
Are there keyframes for it ?
Could somone provide a code sample ?
Solved! Go to Solution.
The following is an example that is performed in an fbx sdk extension plugin at export time, from Maya.
void MayaExt_ExportEnd(FbxScene* pFbxScene)
{
//First you have to get the Mesh Node. You can recursively loop through all the children of the FbxScene's root node.
<implement recursive node search function here>
//Look for a node with the attribute FbxNodeAttribute::eMesh.
FbxNode pMeshNode;
FbxNodeAttribute* pNodeAttribute = pNode->GetNodeAttribute();
if(pNodeAttribute != NULL)
{
FbxNodeAttribute::EType currentNodeAttributeType = pNodeAttribute->GetAttributeType();
if(currentNodeAttributeType == FbxNodeAttribute::eMesh){
pMeshNode = pNode;
}
}
//After you get that, you can get the material if it has one:
FbxSurfaceMaterial *pMaterial = pMeshNode->GetMaterial(materialIndex);
//Then you can access the Diffuse property:
FbxProperty diffuseProp = pMaterial->FindProperty(FbxSurfaceMaterial::sDiffuse);
if( diffuseProp.IsValid() )
{
//Then you can get the animation curve node:
FbxAnimCurveNode* animcurvenode = diffuseProp.GetCurveNode();
int redChannel = 0U;
int greenChannel = 1U;
int blueChannel = 2U;
int alphaChannel = 3U;
//Then you can get the animation curve for each color channel:
int numCurveRed = animcurvenode->GetCurveCount(redChannel);
for(i = 0; i < numCurveRed; i++){
FbxAnimCurve* animCurveRed animcurvenode->GetCurve(redChannel, i);
//...grab the animation key times and values from the curve
}
Can't find what you're looking for? Ask the community or share your knowledge.