00001 #ifndef __FBCORE_H__
00002 #define __FBCORE_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00043 #include <kaydaradef.h>
00044 #ifndef FBSDK_DLL
00045
00048 #define FBSDK_DLL K_DLLIMPORT
00049 #endif
00050
00051 #include <fbsdk/fbcomponent.h>
00052 #include <fbsdk/fbfbx.h>
00053 #include <fbsdk/fbtime.h>
00054 #include <fbsdk/fbdata.h>
00055 #include <fbsdk/fbevaluateinfo.h>
00056
00057
00058
00059
00060 #undef Status
00061
00062 #ifdef FBSDKUseNamespace
00063 namespace FBSDKNamespace {
00064 #endif
00065
00066 FB_DEFINE_COMPONENT( FBSDK_DLL, ModelTemplate );
00067 FB_DEFINE_COMPONENT( FBSDK_DLL, Device );
00068 FB_DEFINE_COMPONENT( FBSDK_DLL, Path3D );
00069 FB_DEFINE_COMPONENT( FBSDK_DLL, Scene );
00070 FB_DEFINE_COMPONENT( FBSDK_DLL, Model );
00071 FB_DEFINE_COMPONENT( FBSDK_DLL, Device );
00072
00073
00074
00075
00081 typedef HIObject (* kFBObjectCreatorFnc)(HIObject pOwner,const char* pName,void *pData);
00082
00083
00084
00085
00090 #define FBBoxDeclare( ClassName, Parent ) \
00091 FBClassDeclare( ClassName,Parent ); \
00092 public: \
00093 ClassName(const char* pName):Parent(pName) { FBClassInit; } \
00094 private:
00095
00099 #define FBBoxImplementation( ThisComponent ) \
00100 FBClassImplementation( ThisComponent )
00101
00106 #define FBDeviceDeclare( ClassName, Parent ) \
00107 FBClassDeclare( ClassName,Parent ); \
00108 public: \
00109 ClassName(const char* pName):Parent(pName) { FBClassInit; } \
00110 private:
00111
00115 #define FBDeviceImplementation( ThisComponent ) \
00116 FBClassImplementation( ThisComponent )
00117
00118
00119
00120
00129 #define FBRegisterBox( UniqueNameStr, ClassName, FolderName, Label, Description, IconFilename ) \
00130 HIObject RegisterBox##ClassName##Create( HIObject ,const char* pName,void * ) \
00131 { \
00132 ClassName *Class = new ClassName(pName); \
00133 Class->mAllocated = true; \
00134 Class->UniqueName = UniqueNameStr; \
00135 if (Class->FBCreate()) { \
00136 return Class->GetHIObject(); \
00137 } else { \
00138 delete Class; \
00139 return NULL; \
00140 } \
00141 } \
00142 \
00143 FBLibraryModule( ClassName ) \
00144 {\
00145 FBRegisterObject(ClassName##R1,"Boxes",UniqueNameStr,Description,RegisterBox##ClassName##Create,true, IconFilename );\
00146 FBRegisterObject(ClassName##R2,"Boxes/Functions/"FolderName,Label,Description,RegisterBox##ClassName##Create,true, IconFilename );\
00147 FBRegisterObject(ClassName##R3,"FbxStorable/Box",UniqueNameStr,Description,RegisterBox##ClassName##Create,true, IconFilename ); \
00148 }
00149
00157 #define FBRegisterDevice( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
00158 HIObject RegisterDevice##ClassName##Create( HIObject ,const char* pName,void * ) \
00159 { \
00160 ClassName *Class = new ClassName(pName); \
00161 Class->mAllocated = true; \
00162 Class->UniqueName = UniqueNameStr; \
00163 if (Class->FBCreate()) { \
00164 return Class->GetHIObject(); \
00165 } else { \
00166 delete Class; \
00167 return NULL; \
00168 } \
00169 } \
00170 \
00171 FBLibraryModule( ClassName ) \
00172 { \
00173 FBRegisterObject(ClassName##R1,"Boxes/Devices",Label,Description,RegisterDevice##ClassName##Create,true, IconFilename );\
00174 FBRegisterObject(ClassName##R2,"FbxStorable/Device",UniqueNameStr,Description,RegisterDevice##ClassName##Create,true, IconFilename ); \
00175 }
00176
00184 #define FBRegisterOnlineDevice( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
00185 HIObject RegisterDevice##ClassName##Create( HIObject ,const char* pName,void * ) \
00186 { \
00187 ClassName *Class = new ClassName(pName); \
00188 Class->mAllocated = true; \
00189 Class->UniqueName = UniqueNameStr; \
00190 if (Class->FBCreate()) { \
00191 return Class->GetHIObject(); \
00192 } else { \
00193 delete Class; \
00194 return NULL; \
00195 } \
00196 } \
00197 \
00198 FBLibraryModule( ClassName ) \
00199 { \
00200 if( FBGetLicense() >= kFBLicenseOnline ) \
00201 { \
00202 FBRegisterObject(ClassName##R1,"Boxes/Devices",Label,Description,RegisterDevice##ClassName##Create, true, IconFilename );\
00203 FBRegisterObject(ClassName##R2,"FbxStorable/Device",UniqueNameStr,Description,RegisterDevice##ClassName##Create, true, IconFilename ); \
00204 } \
00205 }
00206
00207
00209
00211 __FB_FORWARD( FBBox );
00212 FB_FORWARD( FBFbxObject );
00213
00218 class FBSDK_DLL FBBox : public FBComponent {
00219 __FBClassDeclare( FBBox,FBComponent );
00220 public:
00225 FBBox(const char* pName, HIObject pObject=NULL);
00226
00228
00238 virtual FBAnimationNode* AnimationNodeInCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00239 virtual FBAnimationNode* AnimationNodeOutCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00241
00247 virtual bool EvaluateAnimationNodes( FBEvaluateInfo* pEvaluateInfo );
00248
00255 virtual bool AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo );
00256
00258
00263 virtual bool FbxStore( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00264 virtual bool FbxRetrieve(FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00266
00271 virtual bool AnimationNodeDestroy( FBAnimationNode* pAnimationNode );
00272
00277 virtual bool AnimationNodeIsUserData( FBAnimationNode* pAnimationNode );
00278
00283 virtual void AnimationNodesOutDisableIfNotWritten( FBEvaluateInfo* pEvaluateInfo );
00284
00286
00289 virtual FBAnimationNode* AnimationNodeInGet();
00290 virtual FBAnimationNode* AnimationNodeOutGet();
00292
00293 const char* UniqueName;
00294 virtual const char* FbxGetObjectSubType();
00295 virtual const char* FbxGetObjectType();
00296
00297 IObject_Declare(K_IMPLEMENTATION);
00298
00299 FBPropertyBool Animatable;
00300 FBPropertyBool Live;
00301 FBPropertyBool RecordMode;
00302 };
00303
00304
00305 #ifndef FB_KERNEL
00306
00308
00310 __FB_FORWARD( FBHandle );
00311
00315 class FBSDK_DLL FBHandle : public FBBox {
00316 __FBClassDeclare( FBHandle, FBBox );
00317
00318 public:
00324 FBHandle( const char* pName, HIObject pObject=NULL );
00325
00330 void Select();
00331
00332 FBPropertyListObject Follow;
00333 FBPropertyListObject Manipulate;
00334 FBPropertyListObject ManipulateTranslation;
00335 FBPropertyListObject ManipulateRotation;
00336 FBPropertyListObject ManipulateScaling;
00337 FBPropertyListObject Image;
00338
00339 private:
00341
00345 FBHandle( const FBHandle& );
00346 FBHandle& operator=( const FBHandle& );
00348 };
00349
00350
00352
00354 FB_DEFINE_LIST( FBSDK_DLL, Handle );
00355 FB_FORWARD( FBPropertyListHandle );
00356
00358 class FBSDK_DLL FBPropertyListHandle : public FBPropertyListComponent
00359 {
00360 public:
00361 FBPropertyListHandle();
00366 FBHandle* operator[](int pIndex);
00367 };
00368
00369 #endif
00370
00372
00374 __FB_FORWARD ( FBModelTemplate );
00375 __FB_FORWARD ( FBPropertyListModelTemplate );
00376 FB_DEFINE_LIST ( FBSDK_DLL, ModelTemplate );
00377
00379 class FBSDK_DLL FBPropertyListModelTemplate : public FBPropertyListComponentBase
00380 {
00381 public:
00386 int Add ( FBModelTemplate* pItem );
00390 virtual void RemoveAt( int pIndex );
00395 FBModelTemplate* operator[](int pIndex);
00399 virtual int GetCount();
00400 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00401 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00402 private:
00403 inline virtual int Add ( FBComponent* pItem ) { return Add((FBModelTemplate*)pItem); }
00404 #endif
00405 };
00406
00408
00410 __FB_FORWARD( FBModelTemplateBinding );
00411 __FB_FORWARD( FBPropertyListModelTemplateBinding );
00413 typedef class FBSDK_DLL FBPropertyBaseList< FBAnimationNode* > FBPropertyBaseListModelTemplateBinding;
00414
00416 class FBSDK_DLL FBPropertyListModelTemplateBinding : public FBPropertyListComponentBase
00417 {
00418 public:
00423 virtual int Add( FBAnimationNode* pItem );
00424
00428 virtual void RemoveAt( int pIndex );
00433 FBAnimationNode* operator[](int pIndex);
00434
00438 virtual int GetCount();
00439 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00440 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00441 private:
00442 inline virtual int Add ( FBComponent* pItem ) { return Add((FBAnimationNode*)pItem); }
00443 #endif
00444 };
00445
00447
00449 __FB_FORWARD( FBModelTemplate);
00450
00456 enum FBModelTemplateStyle {
00457 kFBModelTemplateNone,
00458 kFBModelTemplateNull,
00459 kFBModelTemplateMarker,
00460 kFBModelTemplateRoot,
00461 kFBModelTemplateSensor,
00462 kFBModelTemplateSkeleton,
00463 kFBModelTemplateCamera,
00464 kFBModelTemplateGeometry,
00465 kFBModelTemplateCameraInterest,
00466 kFBModelTemplateLight,
00467 kFBModelTemplateOptical
00468 };
00469
00476 class FBSDK_DLL FBModelTemplate : public FBComponent {
00477 __FBClassDeclare( FBModelTemplate,FBComponent );
00478
00481 void Init();
00482 public:
00487 FBModelTemplate(HIObject pObject=NULL);
00488
00494 FBModelTemplate(const char *pPrefix,const char *pName, FBModelTemplateStyle pStyle);
00495
00496 FBPropertyListModelTemplate Children;
00497 FBPropertyListModelTemplateBinding Bindings;
00498
00499 FBPropertyString Prefix;
00500 FBPropertyModel Model;
00501 FBPropertyVector3d DefaultTranslation;
00502 FBPropertyVector3d DefaultRotation;
00503 FBPropertyVector3d DefaultScaling;
00504
00505 friend class FBDevice;
00506 };
00507
00509
00511 __FB_FORWARD ( FBDevice );
00512 __FB_FORWARD ( FBPropertyListDevice );
00513
00515 class FBSDK_DLL FBPropertyListDevice : public FBPropertyListComponent
00516 {
00517 public:
00518 FBPropertyListDevice();
00523 FBDevice* operator[](int pIndex);
00524 };
00525
00527
00529 FB_FORWARD( FBDeviceNotifyInfo );
00530
00537 class FBSDK_DLL FBDeviceNotifyInfo
00538 {
00539 public:
00543 FBTime &GetSystemTime();
00544
00548 FBTime &GetLocalTime();
00549
00555 void SetLocalTime( const FBTime & );
00556
00560 int GetSyncCount();
00561
00565 FBEvaluateInfo& GetEvaluateInfo();
00566 };
00567
00569
00571 __FB_FORWARD( FBDeviceInstrument );
00574 class FBSDK_DLL FBDeviceInstrument : public FBComponent
00575 {
00576 __FBClassDeclare( FBDeviceInstrument, FBComponent );
00577 public:
00581 FBDeviceInstrument(FBDevice* pDevice);
00588 virtual bool InstrumentWriteData( FBEvaluateInfo* pEvaluateInfo );
00593 virtual void InstrumentRecordFrame( FBTime pRecordTime, FBDeviceNotifyInfo& pNotifyInfo );
00595
00600 virtual bool FbxStore( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00601 virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00603
00604 FBPropertyDevice Device;
00605 FBPropertyBool Active;
00606 FBPropertyModelTemplate ModelTemplate;
00607 };
00608 FB_DEFINE_COMPONENT( FBSDK_DLL, DeviceInstrument );
00609
00611
00613 __FB_FORWARD( FBPropertyListDeviceInstrument );
00614 FB_DEFINE_LIST( FBSDK_DLL, DeviceInstrument );
00617 class FBSDK_DLL FBPropertyListDeviceInstrument : public FBPropertyListComponentBase
00618 {
00619 public:
00624 virtual int Add ( FBDeviceInstrument* pItem );
00628 virtual void RemoveAt( int pIndex );
00633 FBDeviceInstrument* operator[](int pIndex);
00637 virtual int GetCount();
00638 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00639 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00640 private:
00641 inline virtual int Add ( FBComponent* pItem ) { return Add((FBDeviceInstrument*)pItem); }
00642 #endif
00643 };
00644
00646
00648 __FB_FORWARD( FBSyncReference );
00651 class FBSDK_DLL FBSyncReference : public FBComponent
00652 {
00653 __FBClassDeclare( FBSyncReference, FBComponent );
00654 public:
00659 FBSyncReference(const char* pName, HIObject pObject=NULL);
00660
00664 void Sync(int pSyncId);
00665
00669 int GetSyncCount();
00670
00674 FBTime GetTimeOfLastSync();
00675
00679 FBTime GetTimeOfNextSync();
00680
00681 FBPropertyBool Active;
00682 FBPropertyTime SamplingPeriod;
00683 };
00684 FB_DEFINE_COMPONENT( FBSDK_DLL, SyncReference );
00685
00686
00688
00690
00700 enum FBDeviceSamplingMode {
00701 kFBHardwareTimestamp,
00702 kFBHardwareFrequency,
00703 kFBAutoFrequency,
00704 kFBSoftwareTimestamp
00705 };
00706 FB_DEFINE_ENUM( FBSDK_DLL, DeviceSamplingMode );
00707
00712 enum FBCommType {
00713 kFBCommTypeNone = 0,
00714 kFBCommTypeSerial = 1<<0,
00715 kFBCommTypeNetworkTCP = 1<<1,
00716 kFBCommTypeNetworkUDP = 1<<2,
00717 kFBCommTypeSharedMemory = 1<<3,
00718 kFBCommTypeSimulator = 1<<4,
00719 kFBCommTypeOther = 1<<5
00720 };
00721
00722 typedef class FBSDK_DLL FBArrayTemplate<FBModel*> FBModelList;
00723 __FB_FORWARD( FBDevice );
00724
00726 class FBSDK_DLL FBDevice : public FBBox {
00727 __FBClassDeclare( FBDevice,FBBox );
00728 public:
00732 enum kDeviceOperations {
00733 kOpInit,
00734 kOpStart,
00735 kOpAutoDetect,
00736 kOpStop,
00737 kOpReset,
00738 kOpDone
00739 };
00740
00744 enum kDeviceIOs {
00745 kIOStopModeRead,
00746 kIOPlayModeRead,
00747 kIOStopModeWrite,
00748 kIOPlayModeWrite
00749 };
00750
00754 enum kTransportMode {
00755 kPreparePlay,
00756 kPlayReady,
00757 kPlayStop,
00758 kStop,
00759 kPlay,
00760 kJog,
00761 kPlayReverse
00762 };
00763
00768 FBDevice(const char * pName,HIObject pObject=NULL);
00769
00770
00771 virtual bool FBCreate ();
00772 virtual void FBDestroy ();
00773
00774
00775 virtual FBAnimationNode* AnimationNodeInCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00776 virtual FBAnimationNode* AnimationNodeOutCreate(kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00777
00783 virtual bool DeviceOperation( kDeviceOperations pOperation );
00784
00791 virtual void DeviceTransportNotify( kTransportMode pMode, FBTime pTime, FBTime pSystem );
00792
00799 virtual void DeviceIONotify( kDeviceIOs pAction, FBDeviceNotifyInfo& pDeviceNotifyInfo );
00800
00806 virtual bool DeviceEvaluationNotify( kTransportMode pMode,FBEvaluateInfo* pEvaluateInfo );
00807
00814 virtual bool ModelTemplateBindNotify( FBModel* pModel,int pIndex, FBModelTemplate* pModelTemplate );
00815
00821 virtual bool ModelTemplateUnBindNotify( int pIndex, FBModelTemplate* pModelTemplate );
00822
00826 FBModel* ModelBindingCreate();
00827
00831 void ModelBindingRootsList(FBModelList& pList);
00832
00839 virtual bool AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo ) override;
00840
00841 virtual const char* FbxGetObjectType() override;
00842
00844
00849 virtual bool FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
00850 virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
00852
00857 virtual void DeviceSendCommand( kDeviceOperations pOperation );
00858
00859 IObject_Declare( K_IMPLEMENTATION );
00860
00861 FBPropertyString IconFilename;
00862 FBPropertyString Status;
00863 FBPropertyString Information;
00864 FBPropertyString HardwareVersionInfo;
00865 FBPropertyTime SamplingPeriod;
00866 FBPropertyBool Online;
00867
00868 FBPropertyEvent OnStatusChange;
00869
00870 FBModelTemplate ModelTemplate;
00871 FBPropertyModel ModelBindingRoot;
00872
00873 FBPropertyDeviceSamplingMode SamplingMode;
00874 FBPropertyInt CommType;
00875
00876 FBPropertyListDeviceInstrument Instruments;
00877
00878 FBPropertyTime RecordingStartTime;
00879 FBPropertyTime RecordingStopTime;
00880
00882 void AckOneSampleReceived();
00883
00885 void AckOneBadSampleReceived();
00886
00888 void AckOneSampleSent();
00889
00893 virtual void RecordingInitAnimation(FBAnimationNode* pAnimationNode);
00894
00898 virtual void RecordingDoneAnimation(FBAnimationNode* pAnimationNode);
00899
00900 friend class __FBDevice;
00901 friend class DataFBDeviceOptical;
00902 };
00903
00904 #ifndef FBSDK_LEAN_AND_MEAN
00905
00906 __FB_FORWARD( FBDeviceGlove );
00907
00909 class FBSDK_DLL FBDeviceGlove : public FBDevice {
00910 __FBClassDeclare( FBDeviceGlove, FBDevice );
00911 public:
00914 enum kHandModelPart {
00915
00916 kPartRoot,
00917 kPartPalm,
00918
00919
00920 kPartThumbA,
00921 kPartThumbB,
00922 kPartThumbC,
00923 kPartThumbD,
00924
00925
00926 kPartIndexA,
00927 kPartIndexB,
00928 kPartIndexC,
00929 kPartIndexD,
00930
00931
00932 kPartMiddleA,
00933 kPartMiddleB,
00934 kPartMiddleC,
00935 kPartMiddleD,
00936
00937
00938 kPartRingA,
00939 kPartRingB,
00940 kPartRingC,
00941 kPartRingD,
00942
00943
00944 kPartLittleA,
00945 kPartLittleB,
00946 kPartLittleC,
00947 kPartLittleD,
00948
00949 kPartMax
00950 };
00951
00955 class FBSDK_DLL GloveChannel
00956 {
00957 public:
00961 GloveChannel( FBAnimationNode* pAnimNode );
00962
00965 virtual ~GloveChannel();
00966
00970 FBString GetName ();
00971
00975 void SetName ( FBString pName );
00976
00977 protected:
00978 FBString Name;
00979
00980 public:
00981 bool Enabled;
00982 FBAnimationNode* AnimNode;
00983 };
00984
00985
00990 FBDeviceGlove( const char* pName, HIObject pObject=NULL );
00991
00995 virtual void RecordingInitAnimation( FBAnimationNode* pAnimationNode );
00996
01000 virtual void RecordingDoneAnimation( FBAnimationNode* pAnimationNode );
01001
01002 protected:
01007 void InitializeModelGeometry();
01008
01017 void VectorToModelPartAngle( kHandModelPart pPartIndex, FBVector3d& pVector );
01018
01023 FBAnimationNode* GetModelRotationNode( kHandModelPart pPartIndex );
01024
01025 public:
01026 FBArrayTemplate<GloveChannel*> Channels;
01027
01028 FBPropertyBool LeftHand;
01029 };
01030
01031 #endif
01032
01033 #ifdef FBSDKUseNamespace
01034 }
01035 #endif
01036 #endif