#include "ormodel_template_tool.h"
#include "ormodel_template_model.h"
#include "ormodel_template_model_display.h"
#define ORTOOLCUSTOMMODEL__CLASS ORTOOLCUSTOMMODEL__CLASSNAME
#define ORTOOLCUSTOMMODEL__LABEL "Custom Model"
#define ORTOOLCUSTOMMODEL__DESC "OR - Custom Model Tool Description"
ORTOOLCUSTOMMODEL__LABEL,
ORTOOLCUSTOMMODEL__DESC,
bool ORToolCustomModel::FBCreate()
{
UICreate ();
UIConfigure ();
UIReset ();
OnShow.Add(
this, (
FBCallback)&ORToolCustomModel::EventToolShow);
OnIdle.Add(
this, (
FBCallback)&ORToolCustomModel::EventToolIdle);
mSystem.OnConnectionNotify.Add(
this, (
FBCallback)&ORToolCustomModel::ConnectionNotify);
mSystem.OnConnectionStateNotify.Add(
this, (
FBCallback)&ORToolCustomModel::ConnectionStateNotify);
return true;
}
void ORToolCustomModel::FBDestroy()
{
OnShow.Remove(
this, (
FBCallback) &ORToolCustomModel::EventToolShow);
OnIdle.Remove(
this, (
FBCallback) &ORToolCustomModel::EventToolIdle);
mSystem.OnConnectionNotify.Remove(
this, (
FBCallback)&ORToolCustomModel::ConnectionNotify);
mSystem.OnConnectionStateNotify.Remove(
this, (
FBCallback)&ORToolCustomModel::ConnectionStateNotify);
}
void ORToolCustomModel::UICreate()
{
int lS = 4;
int lW = 100;
int lH = 18;
AddRegion( "ButtonCreateModel", "ButtonCreateModel",
AddRegion( "ButtonCreateModelWithCustomDisplay", "ButtonCreateModel",
AddRegion( "ListModels", "ListModels",
AddRegion( "SliderScale", "SliderScale",
mScaleSlider.Max = 100.0;
mScaleSlider.Min = 0;
mScaleSlider.Value = 100.0;
SetControl( "ButtonCreateModel", mButtonCreateModel );
SetControl( "ButtonCreateModelWithCustomDisplay", mButtonCreateModelWithCustomDisplay );
SetControl( "ListModels", mListModels );
SetControl("SliderScale", mScaleSlider);
mScaleSlider.OnChange.Add(
this, (
FBCallback)&ORToolCustomModel::EventSliderChanged );
}
void ORToolCustomModel::UIConfigure()
{
mButtonCreateModel.Caption = "Create Model";
mButtonCreateModel.OnClick.Add(
this, (
FBCallback) &ORToolCustomModel::EventButtonCreateModelClick );
mButtonCreateModelWithCustomDisplay.Caption = "Create Model with custom display";
mButtonCreateModelWithCustomDisplay.OnClick.Add(
this, (
FBCallback) &ORToolCustomModel::EventButtonCreateModelWithCustomDisplayClick );
}
void ORToolCustomModel::UIReset()
{
mListModels.Items.Clear();
for( i=0; i<lList.GetCount(); i++)
{
if( lList[i]->Show )
{
mListModels.Items.Add( lList[i]->
Name, (kReference) lList[i] );
}
}
}
void ORToolCustomModel::UIRefresh()
{
}
void ORToolCustomModel::EventButtonCreateModelClick(
HISender pSender,
HKEvent pEvent )
{
ORModelCustom* lModel = new ORModelCustom( "Custom 1" );
lModel->FBCreate();
lModel->Show = true;
UIReset();
}
void ORToolCustomModel::EventButtonCreateModelWithCustomDisplayClick(
HISender pSender,
HKEvent pEvent )
{
ORModelCustomDisplay* lModel = new ORModelCustomDisplay( "Custom Display 1" );
lModel->FBCreate();
lModel->Show = true;
UIReset();
}
{
UIRefresh();
}
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
UIReset();
}
else
{
}
}
void ORToolCustomModel::ConnectionStateNotify(
HISender pSender,
HKEvent pEvent )
{
FBEventConnectionStateNotify lEvent(pEvent);
switch( lEvent.Action )
{
UIReset();
break;
}
}
void ORToolCustomModel::EventSliderChanged(
HISender pSender,
HKEvent pEvent )
{
for( int i=0; i<lList.GetCount(); i++)
{
if(ORModelCustomDisplay *lModel = (ORModelCustomDisplay*)lList[
i])
{
lModel->SetScale(mScaleSlider.Value);
}
}
}
void ORToolCustomModel::ConnectionNotify(
HISender pSender,
HKEvent pEvent )
{
FBEventConnectionNotify lEvent(pEvent);
switch( lEvent.Action )
{
UIReset();
break;
}
}
bool ORToolCustomModel::FbxStore ( FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldWriteBegin( "ORToolCustomModelSection" );
{
}
pFbxObject->FieldWriteEnd();
return true;
}
bool ORToolCustomModel::FbxRetrieve( FBFbxObject* pFbxObject,
kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldReadBegin( "ORToolCustomModelSection" );
{
}
pFbxObject->FieldReadEnd();
return true;
}