#include "ortooltimewarp_tool.h"
#define ORTOOLTIMEWARP__CLASS ORTOOLTIMEWARP__CLASSNAME
#define ORTOOLTIMEWARP__LABEL "TimeWarp"
#define ORTOOLTIMEWARP__DESC "OR - TimeWarp Tool Description"
ORTOOLTIMEWARP__LABEL,
ORTOOLTIMEWARP__DESC,
bool ORToolTimeWarp::FBCreate()
{
StartSize[0] = 275;
StartSize[1] = 100;
UICreate ();
UIConfigure ();
UIReset ();
OnShow.Add(
this, (
FBCallback) &ORToolTimeWarp::EventToolShow );
OnIdle.Add(
this, (
FBCallback) &ORToolTimeWarp::EventToolIdle );
mState=0;
return true;
}
void ORToolTimeWarp::FBDestroy()
{
}
void ORToolTimeWarp::UICreate()
{
int lS = 4;
AddRegion( "LabelDirections", "LabelDirections",
AddRegion( "TimeWarp", "TimeWarp",
SetControl( "LabelDirections", mLabelDirections );
SetControl( "TimeWarp", mButtonTimeWarp );
}
void ORToolTimeWarp::UIConfigure()
{
mLabelDirections.Caption = "Click to see a simple usage of FBTimeWarpManager ";
mButtonTimeWarp.Caption = "Create the Model and Animation";
mButtonTimeWarp.Enabled = true;
mButtonTimeWarp.OnClick.Add(
this, (
FBCallback) &ORToolTimeWarp::EventButtonSteps );
}
void ORToolTimeWarp::UIReset()
{
}
void ORToolTimeWarp::UIRefresh()
{
}
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
UIReset();
}
else
{
}
}
{
UIRefresh();
}
void ORToolTimeWarp::CreateAnimation( FBAnimationNode* pAnimationNode)
{
FBFCurve* lFCurve = (FBFCurve*)pAnimationNode->FCurve;
if (lFCurve)
{
FBTime lTimeZero = FBTime::Zero;
FBTime lTimeSixSeconds = FBTime::OneSecond;
lTimeSixSeconds *= 6;
lFCurve->KeyAdd(lTimeZero, 0);
lFCurve->KeyAdd(lTimeSixSeconds, 90);
}
for(
int i=0;
i<pAnimationNode->Nodes.GetCount();
i++)
{
CreateAnimation(pAnimationNode->Nodes[
i]);
}
}
{
switch( mState )
{
case 0:
{
mHdlModel = new FBModelCube("Cube TimeWarp");
mHdlModel->Show = true;
mHdlModel->Visibility = true;
v3d[0] = v3d[1] = v3d[2] = 10;
mHdlModel->Scaling = v3d;
mHdlModel->Rotation.SetAnimated(true);
FBAnimationNode* lAnimationNode = mHdlModel->Rotation.GetAnimationNode();
CreateAnimation(lAnimationNode);
mHdlModelCompared = new FBModelCube("Cube Compared");
mHdlModelCompared->Show = true;
mHdlModelCompared->Visibility = true;
mHdlModelCompared->Scaling = v3d;
mHdlModelCompared->Translation =
FBVector3d(100,10,10);
mHdlModelCompared->Rotation.SetAnimated(true);
lAnimationNode = mHdlModelCompared->Rotation.GetAnimationNode();
CreateAnimation(lAnimationNode);
mButtonTimeWarp.Caption = "Create, Apply and Merge a TimeWarp";
}
break;
case 1:
{
if (mHdlModel.Ok() && mHdlModelCompared.Ok()){
FBAnimationNode* lAnimationNode = mHdlModel->Rotation.GetAnimationNode();
FBTimeWarpManager::TheOne().TimeWarpInitTake( mSystem.CurrentTake );
FBAnimationNode* lTimeWarp = FBTimeWarpManager::TheOne().TimeWarpCreateNew( "lTimeWarpName" );
FBTimeWarpManager::TheOne().TimeWarpAddToTake( mSystem.CurrentTake, lTimeWarp );
FBFCurve* lFCurve = (FBFCurve*)lTimeWarp->FCurve;
if (lFCurve)
{
lFCurve->Keys[1].Value = lFCurve->Keys[1].Value + 5;
}
FBTimeWarpManager::TheOne().ApplyTimeWarp( mSystem.CurrentTake, &mHdlModel->Rotation, lTimeWarp );
FBTimeWarpManager::TheOne().TimeWarpMergeCurveNode( mSystem.CurrentTake, &mHdlModel->Rotation, lAnimationNode, lTimeWarp );
}
mButtonTimeWarp.Caption = "Clean TimeWarp and Models";
}
break;
case 2:
{
if (mHdlModel.Ok() && mHdlModelCompared.Ok()){
FBTimeWarpManager::TheOne().RemoveTimeWarp( mSystem.CurrentTake, &mHdlModel->Rotation );
FBTimeWarpManager::TheOne().TimeWarpClearTake( mSystem.CurrentTake );
mHdlModel->FBDelete();
mHdlModelCompared->FBDelete();
}
mButtonTimeWarp.Caption = "Create the Model and Animation";
}
break;
}
mState++;
mState %= 3;
}