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,char * pName,void *pData);
00082
00083
00084
00085
00090 #define FBBoxDeclare( ClassName, Parent ) \
00091 FBClassDeclare( ClassName,Parent ); \
00092 public: \
00093 ClassName(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(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 ,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 ,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 ,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(char *pName, HIObject pObject=NULL);
00227
00229
00239 virtual HFBAnimationNode AnimationNodeInCreate (kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00240 virtual HFBAnimationNode AnimationNodeOutCreate (kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=false,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00242
00248 virtual bool EvaluateAnimationNodes( HFBEvaluateInfo pEvaluateInfo );
00249
00256 virtual bool AnimationNodeNotify( HFBAnimationNode pAnimationNode, HFBEvaluateInfo pEvaluateInfo );
00257
00259
00264 virtual bool FbxStore( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat );
00265 virtual bool FbxRetrieve(HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat );
00267
00272 virtual bool AnimationNodeDestroy( HFBAnimationNode pAnimationNode );
00273
00278 virtual bool AnimationNodeIsUserData( HFBAnimationNode pAnimationNode );
00279
00281
00284 virtual HFBAnimationNode AnimationNodeInGet();
00285 virtual HFBAnimationNode AnimationNodeOutGet();
00287
00288 char* UniqueName;
00289 virtual char* FbxGetObjectSubType();
00290 virtual 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( 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 ( HFBModelTemplate 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< HFBAnimationNode > FBPropertyBaseListModelTemplateBinding;
00410
00412 class FBSDK_DLL FBPropertyListModelTemplateBinding : public FBPropertyListComponentBase
00413 {
00414 public:
00419 virtual int Add( HFBAnimationNode 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(char *pPrefix,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(HFBDevice pDevice);
00584 virtual bool InstrumentWriteData( HFBEvaluateInfo pEvaluateInfo );
00589 virtual void InstrumentRecordFrame( FBTime pRecordTime, FBDeviceNotifyInfo& pNotifyInfo );
00591
00596 virtual bool FbxStore( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat );
00597 virtual bool FbxRetrieve( HFBFbxObject 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
00654 enum FBDeviceSamplingMode {
00655 kFBHardwareTimestamp,
00656 kFBHardwareFrequency,
00657 kFBAutoFrequency,
00658 kFBSoftwareTimestamp
00659 };
00660 FB_DEFINE_ENUM( FBSDK_DLL, DeviceSamplingMode );
00661
00666 enum FBCommType {
00667 kFBCommTypeNone = 0,
00668 kFBCommTypeSerial = 1<<0,
00669 kFBCommTypeNetworkTCP = 1<<1,
00670 kFBCommTypeNetworkUDP = 1<<2,
00671 kFBCommTypeSharedMemory = 1<<3,
00672 kFBCommTypeSimulator = 1<<4,
00673 kFBCommTypeOther = 1<<5
00674 };
00675
00676 __FB_FORWARD( FBDevice );
00677
00679 class FBSDK_DLL FBDevice : public FBBox {
00680 __FBClassDeclare( FBDevice,FBBox );
00681 public:
00685 enum kDeviceOperations {
00686 kOpInit,
00687 kOpStart,
00688 kOpAutoDetect,
00689 kOpStop,
00690 kOpReset,
00691 kOpDone
00692 };
00693
00697 enum kDeviceIOs {
00698 kIOStopModeRead,
00699 kIOPlayModeRead,
00700 kIOStopModeWrite,
00701 kIOPlayModeWrite
00702 };
00703
00707 enum kTransportMode {
00708 kPreparePlay,
00709 kPlayReady,
00710 kPlayStop,
00711 kStop,
00712 kPlay,
00713 kJog
00714 };
00715
00720 FBDevice(char * pName,HIObject pObject=NULL);
00721
00722
00723 virtual bool FBCreate ();
00724 virtual void FBDestroy ();
00725
00726
00727 virtual HFBAnimationNode AnimationNodeInCreate (kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00728 virtual HFBAnimationNode AnimationNodeOutCreate(kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00729
00735 virtual bool DeviceOperation( kDeviceOperations pOperation );
00736
00743 virtual void DeviceTransportNotify( kTransportMode pMode, FBTime pTime, FBTime pSystem );
00744
00751 virtual void DeviceIONotify( kDeviceIOs pAction, FBDeviceNotifyInfo& pDeviceNotifyInfo );
00752
00758 virtual bool DeviceEvaluationNotify( kTransportMode pMode,HFBEvaluateInfo pEvaluateInfo );
00759
00766 virtual bool ModelTemplateBindNotify( HFBModel pModel,int pIndex, HFBModelTemplate pModelTemplate );
00767
00773 virtual bool ModelTemplateUnBindNotify( int pIndex, HFBModelTemplate pModelTemplate );
00774
00781 virtual bool AnimationNodeNotify( HFBAnimationNode pAnimationNode, HFBEvaluateInfo pEvaluateInfo ) override;
00782
00783 virtual char* FbxGetObjectType() override;
00784
00786
00791 virtual bool FbxStore ( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat ) override;
00792 virtual bool FbxRetrieve( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat ) override;
00794
00799 virtual void DeviceSendCommand( kDeviceOperations pOperation );
00800
00801 IObject_Declare( Implementation );
00802
00803 FBPropertyString IconFilename;
00804 FBPropertyString Status;
00805 FBPropertyString Information;
00806 FBPropertyString HardwareVersionInfo;
00807 FBPropertyTime SamplingPeriod;
00808 FBPropertyBool Online;
00809
00810 FBPropertyEvent OnStatusChange;
00811
00812 FBModelTemplate ModelTemplate;
00813
00814 FBPropertyDeviceSamplingMode SamplingMode;
00815 FBPropertyInt CommType;
00816
00817 FBPropertyListDeviceInstrument Instruments;
00818
00819 FBPropertyTime RecordingStartTime;
00820 FBPropertyTime RecordingStopTime;
00821
00823 void AckOneSampleReceived();
00824
00826 void AckOneBadSampleReceived();
00827
00829 void AckOneSampleSent();
00830
00834 virtual void RecordingInitAnimation(HFBAnimationNode pAnimationNode);
00835
00839 virtual void RecordingDoneAnimation(HFBAnimationNode pAnimationNode);
00840
00841 friend class __FBDevice;
00842 friend class DataFBDeviceOptical;
00843 };
00844
00845 #ifndef FBSDK_LEAN_AND_MEAN
00846
00847 __FB_FORWARD( FBDeviceGlove );
00848
00850 class FBSDK_DLL FBDeviceGlove : public FBDevice {
00851 __FBClassDeclare( FBDeviceGlove, FBDevice );
00852 public:
00855 enum kHandModelPart {
00856
00857 kPartRoot,
00858 kPartPalm,
00859
00860
00861 kPartThumbA,
00862 kPartThumbB,
00863 kPartThumbC,
00864 kPartThumbD,
00865
00866
00867 kPartIndexA,
00868 kPartIndexB,
00869 kPartIndexC,
00870 kPartIndexD,
00871
00872
00873 kPartMiddleA,
00874 kPartMiddleB,
00875 kPartMiddleC,
00876 kPartMiddleD,
00877
00878
00879 kPartRingA,
00880 kPartRingB,
00881 kPartRingC,
00882 kPartRingD,
00883
00884
00885 kPartLittleA,
00886 kPartLittleB,
00887 kPartLittleC,
00888 kPartLittleD,
00889
00890 kPartMax
00891 };
00892
00896 class FBSDK_DLL GloveChannel
00897 {
00898 public:
00902 GloveChannel( HFBAnimationNode pAnimNode );
00903
00906 virtual ~GloveChannel();
00907
00911 FBString GetName ();
00912
00916 void SetName ( FBString pName );
00917
00918 protected:
00919 FBString Name;
00920
00921 public:
00922 bool Enabled;
00923 HFBAnimationNode AnimNode;
00924 };
00925
00926
00931 FBDeviceGlove( char* pName, HIObject pObject=NULL );
00932
00936 virtual void RecordingInitAnimation( HFBAnimationNode pAnimationNode );
00937
00941 virtual void RecordingDoneAnimation( HFBAnimationNode pAnimationNode );
00942
00943 protected:
00948 void InitializeModelGeometry();
00949
00958 void VectorToModelPartAngle( kHandModelPart pPartIndex, FBVector3d& pVector );
00959
00964 HFBAnimationNode GetModelRotationNode( kHandModelPart pPartIndex );
00965
00966 public:
00967 FBArrayTemplate<GloveChannel*> Channels;
00968
00969 FBPropertyBool LeftHand;
00970 };
00971
00972 #endif
00973
00974 #ifdef FBSDKUseNamespace
00975 }
00976 #endif
00977 #endif