void Model::SetAnimationStack( int index ) {
	KFbxAnimStack *current_stack = scene->FindMember( FBX_TYPE(KFbxAnimStack), AnimationStackNames[index]->Buffer() );
	CurrentAnimationLayer = current_stack->GetMember( FBX_TYPE(KFbxAnimLayer), 0 );

	// set the animation evaluator context (or something)
	scene->GetEvaluator()->SetContext( current_stack );

	// god knows what this does
	KFbxTakeInfo *current_take_info = scene->GetTakeInfo( *(AnimationStackNames[index]) );
	if( current_take_info ) {
		AnimationStartTime = current_take_info->mLocalTimeSpan.GetStart();
		AnimationStopTime = current_take_info->mLocalTimeSpan.GetStop();
	} else {
		KTimeSpan timespan;
		scene->GetGlobalSettings().GetTimelineDefaultTimeSpan( timespan );

		AnimationStartTime = timespan.GetStart();
		AnimationStopTime = timespan.GetStop();
	}

	/////////
    AnimationStartTime.SetTime(0, 0, 0, 10, 0, scene->GetGlobalSettings().GetTimeMode());
    AnimationStopTime.SetTime(0, 0, 0, 50, 0, scene->GetGlobalSettings().GetTimeMode());
	//////////////

	AnimationCurrentTime = AnimationStartTime;
}
Esempio n. 2
0
// -- Actions ----------------------------------------------------------------
void Scene::setAnimation(int index)
{
    LOG_INFO( "Scene::setAnimation("<< index <<")");

    int numAnimStacks = animationNames.GetCount();
    if (!numAnimStacks || index >= numAnimStacks) {
        return;
    }

    // select the base layer from the animation stack
    KFbxAnimStack* currentAnimationStack = fbxScene->FindMember(FBX_TYPE(KFbxAnimStack), animationNames[index]->Buffer());
    if (currentAnimationStack == NULL) {
        // this is a problem. The anim stack should be found in the scene!
        LOG_INFO( "The anim stack should be found in the scene!\n");
        return;
    }

    // we assume that the first animation layer connected to the animation stack is the base layer
    // (this is the assumption made in the FBXSDK)
    currentAnimationLayer = currentAnimationStack->GetMember(FBX_TYPE(KFbxAnimLayer), 0);
    fbxScene->GetEvaluator()->SetContext(currentAnimationStack);

    KFbxTakeInfo* lCurrentTakeInfo = fbxScene->GetTakeInfo(*(animationNames[index]));
    if (lCurrentTakeInfo) {
        start = lCurrentTakeInfo->mLocalTimeSpan.GetStart();
        stop = lCurrentTakeInfo->mLocalTimeSpan.GetStop();

        printf("Scene::initAnimStack $1 start %f stop %f \n", start.GetSecondDouble(), stop.GetSecondDouble());

    } else {
        // Take the time line value
        KTimeSpan lTimeLineTimeSpan;
        fbxScene->GetGlobalSettings().GetTimelineDefaultTimeSpan(lTimeLineTimeSpan);

        start = lTimeLineTimeSpan.GetStart();
        stop  = lTimeLineTimeSpan.GetStop();

        printf("Scene::initAnimStack $2 start %f stop %f \n", start.GetSecondDouble(), stop.GetSecondDouble());
    }

    currentTime = start;
}