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
00219 class FBSDK_DLL FBBox : public FBComponent {
00220 __FBClassDeclare( FBBox,FBComponent );
00221 public:
00226 FBBox(const char* pName, HIObject pObject=NULL);
00227
00229
00239 virtual FBAnimationNode* AnimationNodeInCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00240 virtual FBAnimationNode* AnimationNodeOutCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00242
00248 virtual bool EvaluateAnimationNodes( FBEvaluateInfo* pEvaluateInfo );
00249
00256 virtual bool AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo );
00257
00259
00264 virtual bool FbxStore( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00265 virtual bool FbxRetrieve(FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00267
00272 virtual bool AnimationNodeDestroy( FBAnimationNode* pAnimationNode );
00273
00278 virtual bool AnimationNodeIsUserData( FBAnimationNode* pAnimationNode );
00279
00281
00284 virtual FBAnimationNode* AnimationNodeInGet();
00285 virtual FBAnimationNode* AnimationNodeOutGet();
00287
00288 const char* UniqueName;
00289 virtual const char* FbxGetObjectSubType();
00290 virtual const char* FbxGetObjectType();
00291
00292 IObject_Declare(Implementation);
00293
00294 FBPropertyBool Animatable;
00295 FBPropertyBool Live;
00296 FBPropertyBool RecordMode;
00297 };
00298
00299
00300 #ifndef FB_KERNEL
00301
00303
00305 __FB_FORWARD( FBHandle );
00306
00311 class FBSDK_DLL FBHandle : public FBBox {
00312 __FBClassDeclare( FBHandle, FBBox );
00313
00314 public:
00320 FBHandle( const char* pName, HIObject pObject=NULL );
00321
00326 void Select();
00327
00328 FBPropertyListObject Follow;
00329 FBPropertyListObject Manipulate;
00330 FBPropertyListObject ManipulateTranslation;
00331 FBPropertyListObject ManipulateRotation;
00332 FBPropertyListObject ManipulateScaling;
00333 FBPropertyListObject Image;
00334
00335 private:
00337
00341 FBHandle( const FBHandle& );
00342 FBHandle& operator=( const FBHandle& );
00344 };
00345
00346
00348
00350 FB_DEFINE_LIST( FBSDK_DLL, Handle );
00351 FB_FORWARD( FBPropertyListHandle );
00352
00354 class FBSDK_DLL FBPropertyListHandle : public FBPropertyListComponent
00355 {
00356 public:
00357 FBPropertyListHandle();
00362 FBHandle* operator[](int pIndex);
00363 };
00364
00365 #endif
00366
00368
00370 __FB_FORWARD ( FBModelTemplate );
00371 __FB_FORWARD ( FBPropertyListModelTemplate );
00372 FB_DEFINE_LIST ( FBSDK_DLL, ModelTemplate );
00373
00375 class FBSDK_DLL FBPropertyListModelTemplate : public FBPropertyListComponentBase
00376 {
00377 public:
00382 int Add ( FBModelTemplate* pItem );
00386 virtual void RemoveAt( int pIndex );
00391 FBModelTemplate* operator[](int pIndex);
00395 virtual int GetCount();
00396 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00397 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00398 private:
00399 inline virtual int Add ( FBComponent* pItem ) { return Add((FBModelTemplate*)pItem); }
00400 #endif
00401 };
00402
00404
00406 __FB_FORWARD( FBModelTemplateBinding );
00407 __FB_FORWARD( FBPropertyListModelTemplateBinding );
00409 typedef class FBSDK_DLL FBPropertyBaseList< FBAnimationNode* > FBPropertyBaseListModelTemplateBinding;
00410
00412 class FBSDK_DLL FBPropertyListModelTemplateBinding : public FBPropertyListComponentBase
00413 {
00414 public:
00419 virtual int Add( FBAnimationNode* pItem );
00420
00424 virtual void RemoveAt( int pIndex );
00429 FBAnimationNode* operator[](int pIndex);
00430
00434 virtual int GetCount();
00435 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00436 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00437 private:
00438 inline virtual int Add ( FBComponent* pItem ) { return Add((FBAnimationNode*)pItem); }
00439 #endif
00440 };
00441
00443
00445 __FB_FORWARD( FBModelTemplate);
00446
00452 enum FBModelTemplateStyle {
00453 kFBModelTemplateNone,
00454 kFBModelTemplateNull,
00455 kFBModelTemplateMarker,
00456 kFBModelTemplateRoot,
00457 kFBModelTemplateSensor,
00458 kFBModelTemplateSkeleton,
00459 kFBModelTemplateCamera,
00460 kFBModelTemplateGeometry,
00461 kFBModelTemplateCameraInterest,
00462 kFBModelTemplateLight,
00463 kFBModelTemplateOptical
00464 };
00465
00472 class FBSDK_DLL FBModelTemplate : public FBComponent {
00473 __FBClassDeclare( FBModelTemplate,FBComponent );
00474
00477 void Init();
00478 public:
00483 FBModelTemplate(HIObject pObject=NULL);
00484
00490 FBModelTemplate(const char *pPrefix,const char *pName, FBModelTemplateStyle pStyle);
00491
00492 FBPropertyListModelTemplate Children;
00493 FBPropertyListModelTemplateBinding Bindings;
00494
00495 FBPropertyString Prefix;
00496 FBPropertyModel Model;
00497 FBPropertyVector3d DefaultTranslation;
00498 FBPropertyVector3d DefaultRotation;
00499 FBPropertyVector3d DefaultScaling;
00500
00501 friend class FBDevice;
00502 };
00503
00505
00507 __FB_FORWARD ( FBDevice );
00508 __FB_FORWARD ( FBPropertyListDevice );
00509
00511 class FBSDK_DLL FBPropertyListDevice : public FBPropertyListComponent
00512 {
00513 public:
00514 FBPropertyListDevice();
00519 FBDevice* operator[](int pIndex);
00520 };
00521
00523
00525 FB_FORWARD( FBDeviceNotifyInfo );
00526
00533 class FBSDK_DLL FBDeviceNotifyInfo
00534 {
00535 public:
00539 FBTime &GetSystemTime();
00540
00544 FBTime &GetLocalTime();
00545
00551 void SetLocalTime( const FBTime & );
00552
00556 int GetSyncCount();
00557
00561 FBEvaluateInfo& GetEvaluateInfo();
00562 };
00563
00565
00567 __FB_FORWARD( FBDeviceInstrument );
00570 class FBSDK_DLL FBDeviceInstrument : public FBComponent
00571 {
00572 __FBClassDeclare( FBDeviceInstrument, FBComponent );
00573 public:
00577 FBDeviceInstrument(FBDevice* pDevice);
00584 virtual bool InstrumentWriteData( FBEvaluateInfo* pEvaluateInfo );
00589 virtual void InstrumentRecordFrame( FBTime pRecordTime, FBDeviceNotifyInfo& pNotifyInfo );
00591
00596 virtual bool FbxStore( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00597 virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat );
00599
00600 FBPropertyDevice Device;
00601 FBPropertyBool Active;
00602 FBPropertyModelTemplate ModelTemplate;
00603 };
00604 FB_DEFINE_COMPONENT( FBSDK_DLL, DeviceInstrument );
00605
00607
00609 __FB_FORWARD( FBPropertyListDeviceInstrument );
00610 FB_DEFINE_LIST( FBSDK_DLL, DeviceInstrument );
00613 class FBSDK_DLL FBPropertyListDeviceInstrument : public FBPropertyListComponentBase
00614 {
00615 public:
00620 virtual int Add ( HFBDeviceInstrument pItem );
00624 virtual void RemoveAt( int pIndex );
00629 FBDeviceInstrument* operator[](int pIndex);
00633 virtual int GetCount();
00634 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00635 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00636 private:
00637 inline virtual int Add ( FBComponent* pItem ) { return Add((FBDeviceInstrument*)pItem); }
00638 #endif
00639 };
00640
00642
00644 __FB_FORWARD( FBSyncReference );
00647 class FBSDK_DLL FBSyncReference : public FBComponent
00648 {
00649 __FBClassDeclare( FBSyncReference, FBComponent );
00650 public:
00655 FBSyncReference(const char* pName, HIObject pObject=NULL);
00656
00660 void Sync(int pSyncId);
00661
00665 int GetSyncCount();
00666
00670 FBTime GetTimeOfLastSync();
00671
00675 FBTime GetTimeOfNextSync();
00676
00677 FBPropertyBool Active;
00678 FBPropertyTime SamplingPeriod;
00679 };
00680 FB_DEFINE_COMPONENT( FBSDK_DLL, SyncReference );
00681
00682
00684
00686
00696 enum FBDeviceSamplingMode {
00697 kFBHardwareTimestamp,
00698 kFBHardwareFrequency,
00699 kFBAutoFrequency,
00700 kFBSoftwareTimestamp
00701 };
00702 FB_DEFINE_ENUM( FBSDK_DLL, DeviceSamplingMode );
00703
00708 enum FBCommType {
00709 kFBCommTypeNone = 0,
00710 kFBCommTypeSerial = 1<<0,
00711 kFBCommTypeNetworkTCP = 1<<1,
00712 kFBCommTypeNetworkUDP = 1<<2,
00713 kFBCommTypeSharedMemory = 1<<3,
00714 kFBCommTypeSimulator = 1<<4,
00715 kFBCommTypeOther = 1<<5
00716 };
00717
00718 typedef class FBSDK_DLL FBArrayTemplate<FBModel*> FBModelList;
00719 __FB_FORWARD( FBDevice );
00720
00722 class FBSDK_DLL FBDevice : public FBBox {
00723 __FBClassDeclare( FBDevice,FBBox );
00724 public:
00728 enum kDeviceOperations {
00729 kOpInit,
00730 kOpStart,
00731 kOpAutoDetect,
00732 kOpStop,
00733 kOpReset,
00734 kOpDone
00735 };
00736
00740 enum kDeviceIOs {
00741 kIOStopModeRead,
00742 kIOPlayModeRead,
00743 kIOStopModeWrite,
00744 kIOPlayModeWrite
00745 };
00746
00750 enum kTransportMode {
00751 kPreparePlay,
00752 kPlayReady,
00753 kPlayStop,
00754 kStop,
00755 kPlay,
00756 kJog,
00757 kPlayReverse
00758 };
00759
00764 FBDevice(const char * pName,HIObject pObject=NULL);
00765
00766
00767 virtual bool FBCreate ();
00768 virtual void FBDestroy ();
00769
00770
00771 virtual FBAnimationNode* AnimationNodeInCreate (kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00772 virtual FBAnimationNode* AnimationNodeOutCreate(kReference pUserId,const char * pName ,const char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00773
00779 virtual bool DeviceOperation( kDeviceOperations pOperation );
00780
00787 virtual void DeviceTransportNotify( kTransportMode pMode, FBTime pTime, FBTime pSystem );
00788
00795 virtual void DeviceIONotify( kDeviceIOs pAction, FBDeviceNotifyInfo& pDeviceNotifyInfo );
00796
00802 virtual bool DeviceEvaluationNotify( kTransportMode pMode,FBEvaluateInfo* pEvaluateInfo );
00803
00810 virtual bool ModelTemplateBindNotify( FBModel* pModel,int pIndex, FBModelTemplate* pModelTemplate );
00811
00817 virtual bool ModelTemplateUnBindNotify( int pIndex, FBModelTemplate* pModelTemplate );
00818
00822 FBModel* ModelBindingCreate();
00823
00827 void ModelBindingRootsList(FBModelList& pList);
00828
00835 virtual bool AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo ) override;
00836
00837 virtual const char* FbxGetObjectType() override;
00838
00840
00845 virtual bool FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
00846 virtual bool FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat ) override;
00848
00853 virtual void DeviceSendCommand( kDeviceOperations pOperation );
00854
00855 IObject_Declare( Implementation );
00856
00857 FBPropertyString IconFilename;
00858 FBPropertyString Status;
00859 FBPropertyString Information;
00860 FBPropertyString HardwareVersionInfo;
00861 FBPropertyTime SamplingPeriod;
00862 FBPropertyBool Online;
00863
00864 FBPropertyEvent OnStatusChange;
00865
00866 FBModelTemplate ModelTemplate;
00867 FBPropertyModel ModelBindingRoot;
00868
00869 FBPropertyDeviceSamplingMode SamplingMode;
00870 FBPropertyInt CommType;
00871
00872 FBPropertyListDeviceInstrument Instruments;
00873
00874 FBPropertyTime RecordingStartTime;
00875 FBPropertyTime RecordingStopTime;
00876
00878 void AckOneSampleReceived();
00879
00881 void AckOneBadSampleReceived();
00882
00884 void AckOneSampleSent();
00885
00889 virtual void RecordingInitAnimation(FBAnimationNode* pAnimationNode);
00890
00894 virtual void RecordingDoneAnimation(FBAnimationNode* pAnimationNode);
00895
00896 friend class __FBDevice;
00897 friend class DataFBDeviceOptical;
00898 };
00899
00900 #ifndef FBSDK_LEAN_AND_MEAN
00901
00902 __FB_FORWARD( FBDeviceGlove );
00903
00905 class FBSDK_DLL FBDeviceGlove : public FBDevice {
00906 __FBClassDeclare( FBDeviceGlove, FBDevice );
00907 public:
00910 enum kHandModelPart {
00911
00912 kPartRoot,
00913 kPartPalm,
00914
00915
00916 kPartThumbA,
00917 kPartThumbB,
00918 kPartThumbC,
00919 kPartThumbD,
00920
00921
00922 kPartIndexA,
00923 kPartIndexB,
00924 kPartIndexC,
00925 kPartIndexD,
00926
00927
00928 kPartMiddleA,
00929 kPartMiddleB,
00930 kPartMiddleC,
00931 kPartMiddleD,
00932
00933
00934 kPartRingA,
00935 kPartRingB,
00936 kPartRingC,
00937 kPartRingD,
00938
00939
00940 kPartLittleA,
00941 kPartLittleB,
00942 kPartLittleC,
00943 kPartLittleD,
00944
00945 kPartMax
00946 };
00947
00951 class FBSDK_DLL GloveChannel
00952 {
00953 public:
00957 GloveChannel( FBAnimationNode* pAnimNode );
00958
00961 virtual ~GloveChannel();
00962
00966 FBString GetName ();
00967
00971 void SetName ( FBString pName );
00972
00973 protected:
00974 FBString Name;
00975
00976 public:
00977 bool Enabled;
00978 FBAnimationNode* AnimNode;
00979 };
00980
00981
00986 FBDeviceGlove( const char* pName, HIObject pObject=NULL );
00987
00991 virtual void RecordingInitAnimation( FBAnimationNode* pAnimationNode );
00992
00996 virtual void RecordingDoneAnimation( FBAnimationNode* pAnimationNode );
00997
00998 protected:
01003 void InitializeModelGeometry();
01004
01013 void VectorToModelPartAngle( kHandModelPart pPartIndex, FBVector3d& pVector );
01014
01019 FBAnimationNode* GetModelRotationNode( kHandModelPart pPartIndex );
01020
01021 public:
01022 FBArrayTemplate<GloveChannel*> Channels;
01023
01024 FBPropertyBool LeftHand;
01025 };
01026
01027 #endif
01028
01029 #ifdef FBSDKUseNamespace
01030 }
01031 #endif
01032 #endif