#include <fbxsdk/scene/fbxscene.h>
#include "ortoolclipscene_tool.h"
#define ORTOOLCLIPSCENE__CLASS ORTOOLCLIPSCENE__CLASSNAME
#define ORTOOLCLIPSCENE__LABEL "Story Clip scene exposition"
#define ORTOOLCLIPSCENE__DESC "FBSDK - Tool Clip Scene Description"
ORTOOLCLIPSCENE__LABEL,
ORTOOLCLIPSCENE__DESC,
bool ORToolClipScene::FBCreate()
{
StartSize[0] = 400;
StartSize[1] = 700;
SetControl( "List", mListClips );
SetControl( "Tree", mClipScene );
OnShow.Add (
this, (
FBCallback) &ORToolClipScene::EventToolShow );
OnIdle.Add (
this, (
FBCallback) &ORToolClipScene::EventToolIdle );
OnResize.Add(
this, (
FBCallback) &ORToolClipScene::EventToolResize );
OnPaint.Add (
this, (
FBCallback) &ORToolClipScene::EventToolPaint );
OnInput.Add (
this, (
FBCallback) &ORToolClipScene::EventToolInput );
((FBScene*)FBSystem::TheOne().Scene)->OnChange.Add (
this, (
FBCallback) &ORToolClipScene::EventSceneChange );
mListClips.OnChange.Add(
this, (
FBCallback) &ORToolClipScene::EventListChange );
return true;
}
void ORToolClipScene::FBDestroy()
{
((FBScene*)FBSystem::TheOne().Scene)->OnChange.Remove (
this, (
FBCallback) &ORToolClipScene::EventSceneChange );
mListClips.OnChange.Remove(
this, (
FBCallback) &ORToolClipScene::EventListChange );
OnShow.Remove (
this, (
FBCallback) &ORToolClipScene::EventToolShow );
OnIdle.Remove (
this, (
FBCallback) &ORToolClipScene::EventToolIdle );
OnPaint.Remove (
this, (
FBCallback) &ORToolClipScene::EventToolPaint );
OnInput.Remove (
this, (
FBCallback) &ORToolClipScene::EventToolInput );
OnResize.Remove (
this, (
FBCallback) &ORToolClipScene::EventToolResize);
}
void ORToolClipScene::UIRefresh()
{
UpdateClipList();
UpdateClipScene();
}
void ORToolClipScene::UpdateClipList()
{
FBScene* lScene = (FBScene*)FBSystem::TheOne().Scene;
int lCount = lScene->Components.GetCount();
FBStoryClip* lCurrentClip = GetCurrentClip();
int lCurrentIndex = -1;
mListClips.Items.Clear();
for(
int i = 0;
i < lCount;
i++ )
{
FBComponent* lComp = lScene->Components[
i];
if(
FBIS(lComp,FBStoryClip))
{
mListClips.Items.Add(lComp->Name, (kReference)lComp);
if(lCurrentClip == lComp)
{
lCurrentIndex = mListClips.Items.GetCount()-1;
}
}
}
if(lCurrentIndex == -1 && mListClips.Items.GetCount())
{
lCurrentIndex = 0;
}
mListClips.ItemIndex = lCurrentIndex;
}
void ORToolClipScene::UpdateClipScene()
{
FBStoryClip* lClip = GetCurrentClip();
FBXSDK_NAMESPACE::FbxScene* lFbxScene = lClip ? lClip->GetFbxScene() :
NULL;
FBTreeNode* lRoot = mClipScene.GetRoot();
mClipScene.Clear();
if(lFbxScene)
{
int lNodeCount = lFbxScene->GetNodeCount();
for(
int i = 0;
i < lNodeCount;
i++)
{
FBString lNodeName = lFbxScene->GetNode(
i)->GetName();
mClipScene.InsertLast( lRoot, (char*)lNodeName );
}
}
}
FBStoryClip* ORToolClipScene::GetCurrentClip()
{
FBStoryClip* lClip =
NULL;
int lCurrentIndex = mListClips.ItemIndex;
if(lCurrentIndex != -1 && lCurrentIndex < mListClips.Items.GetCount())
{
lClip = (FBStoryClip*)mListClips.Items.GetReferenceAt(lCurrentIndex);
}
return lClip;
}
{
static bool TransactionStarted = false;
FBEventSceneChange lEvent( pEvent );
switch( lEvent.Type )
{
{
TransactionStarted = true;
}
break;
{
UIRefresh();
TransactionStarted = false;
}
break;
{
if (!TransactionStarted) UIRefresh();
}
break;
}
}
{
UpdateClipScene();
}
{
}
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
UpdateClipList();
UpdateClipScene();
}
else
{
}
}
{
}
{
}
{
}