|
Howdy,
Something seems strange with importing and exporting a vertex cache. It seems that I can only get it to work when there is another animated object in the file. If I try to export a vertex cache as the only element in the exported file, it won’t import.
For example, if I comment out everything except the Triangle object in the ExportScene03 example like this:
bool CreateScene(KFbxSdkManager* pSdkManager, KFbxScene* pScene, char* pSampleFileName) {
//KFbxNode* lCube = CreateCubeWithTexture(pSdkManager, "Cube");
//KFbxNode* lPyramid = CreatePyramidWithMaterials(pSdkManager, "Pyramid");
KFbxNode* lTriangle = CreateTriangle(pSdkManager, "Triangle");
//KFbxNode* lMyKFbxMeshCube = CreateCubeWithMaterialAndMyKFbxMesh(pSdkManager, "CubeMyKFbxMesh");
//MyFbxObject* lMyFbxObject = MyFbxObject::Create(pSdkManager, "MyFbxObject 1");
//MapShapeOnPyramid(pSdkManager, lPyramid);
MapVertexCacheOnTriangle(pSdkManager, lTriangle, pSampleFileName);
//SetCubeDefaultPosition(lCube);
//SetPyramidDefaultPosition(lPyramid);
SetTriangleDefaultPosition(lTriangle);
//SetMyKFbxMeshCubeDefaultPosition(lMyKFbxMeshCube);
//Animate(lCube);
//Animate(lPyramid);
//Animate(lMyKFbxMeshCube);
switch(gCacheType)
{
case 0:
default:
AnimateVertexCacheOnTriangleDoubleVertex(lTriangle, KTime::GetFrameRate(pScene->GetGlobalTimeSettings().GetTimeMode()));
break;
case 1:
AnimateVertexCacheOnTriangleInt32(lTriangle, KTime::GetFrameRate(pScene->GetGlobalTimeSettings().GetTimeMode()));
break;
}
// Build the node tree.
KFbxNode* lRootNode = pScene->GetRootNode();
//lRootNode->AddChild(lCube);
//lRootNode->AddChild(lPyramid);
//lRootNode->AddChild(lMyKFbxMeshCube);
lRootNode->AddChild(lTriangle);
//lRootNode->ConnectSrcObject(lMyFbxObject);
// Identify current take when file is loaded.
pScene->SetCurrentTake("Show all faces");
//Create a simple animated fcurve
/*KFbxProperty lMyProperty = lMyFbxObject->FindProperty("MyAnimatedPropertyName");
if( lMyProperty.IsValid() )
{
lMyProperty.Set(0.0); //Default value
lMyProperty.ModifyFlag(KFbxProperty::eANIMATABLE, true);
lMyProperty.CreateKFCurveNode();
KFCurve* lMyFCurve = lMyProperty.GetKFCurve();
if( lMyFCurve )
{
lMyFCurve->KeyAppendFast(KTIME_ZERO, -100);
lMyFCurve->KeyAppendFast(KTime(100), 0);
lMyFCurve->KeyAppendFast(KTime(200), 100);
}
}*/
return true; }
... then when I try to import it, the mesh is imported without the vertex cache, and the animation take length is 0.
Here is my code to get the take length:
int GetTakeLength(int ind) {
int numFrames = 0;
KTime::ETimeMode tMode = pScene->GetGlobalTimeSettings().GetTimeMode();
float frameRate = GetFrameRate(tMode);
KTime gPeriod, currentTime;
gPeriod.SetTime(0,0,0,1,0,tMode);
KFbxTakeInfo *lCurrentTakeInfo = pScene->GetTakeInfo(*gTakeNameArray[ind]);
if(lCurrentTakeInfo)
{
pScene->SetCurrentTake(gTakeNameArray[ind]->Buffer());
KTime gStart = lCurrentTakeInfo->mLocalTimeSpan.GetStart();
KTime gStop = lCurrentTakeInfo->mLocalTimeSpan.GetStop();
KTime timeDiff = gStop - gStart;
double diff = timeDiff.GetSecondDouble();
numFrames = (int)(diff * frameRate);
}
return numFrames; }
If I uncomment just one other object from the ExportScene03 example, for example, uncomment the cube, then the file imports correctly with the cube’s animation and the triangle’s vertex cache.
The ViewScene example also has trouble correctly importing the vertex cache alone, but with the cube added to the scene, then it will import the file correctly.
It’s odd though that Maya PLE will correctly import the triangle with its vertex cache alone.
What do I need to do to get this working correctly?
Adios,
Cactus Dan
|