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
00549 int GetSyncCount();
00550
00551 };
00552
00554
00556 __FB_FORWARD( FBDeviceInstrument );
00559 class FBSDK_DLL FBDeviceInstrument : public FBComponent
00560 {
00561 __FBClassDeclare( FBDeviceInstrument, FBComponent );
00562 public:
00566 FBDeviceInstrument(HFBDevice pDevice);
00573 virtual bool InstrumentWriteData( HFBEvaluateInfo pEvaluateInfo );
00578 virtual void InstrumentRecordFrame( FBTime pRecordTime, FBDeviceNotifyInfo& pNotifyInfo );
00580
00585 virtual bool FbxStore( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat );
00586 virtual bool FbxRetrieve( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat );
00588
00589 FBPropertyDevice Device;
00590 FBPropertyBool Active;
00591 FBPropertyModelTemplate ModelTemplate;
00592 };
00593 FB_DEFINE_COMPONENT( FBSDK_DLL, DeviceInstrument );
00594
00596
00598 __FB_FORWARD( FBPropertyListDeviceInstrument );
00599 FB_DEFINE_LIST( FBSDK_DLL, DeviceInstrument );
00602 class FBSDK_DLL FBPropertyListDeviceInstrument : public FBPropertyListComponentBase
00603 {
00604 public:
00609 virtual int Add ( HFBDeviceInstrument pItem );
00613 virtual void RemoveAt( int pIndex );
00618 FBDeviceInstrument* operator[](int pIndex);
00622 virtual int GetCount();
00623 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00624 inline virtual FBComponent* GetAt(int pIndex) { return (FBComponent*)operator[](pIndex); }
00625 private:
00626 inline virtual int Add ( FBComponent* pItem ) { return Add((FBDeviceInstrument*)pItem); }
00627 #endif
00628 };
00629
00631
00633
00643 enum FBDeviceSamplingMode {
00644 kFBHardwareTimestamp,
00645 kFBHardwareFrequency,
00646 kFBAutoFrequency,
00647 kFBSoftwareTimestamp
00648 };
00649 FB_DEFINE_ENUM( FBSDK_DLL, DeviceSamplingMode );
00650
00655 enum FBCommType {
00656 kFBCommTypeNone = 0,
00657 kFBCommTypeSerial = 1<<0,
00658 kFBCommTypeNetworkTCP = 1<<1,
00659 kFBCommTypeNetworkUDP = 1<<2,
00660 kFBCommTypeSharedMemory = 1<<3,
00661 kFBCommTypeSimulator = 1<<4,
00662 kFBCommTypeOther = 1<<5
00663 };
00664
00665 __FB_FORWARD( FBDevice );
00666
00668 class FBSDK_DLL FBDevice : public FBBox {
00669 __FBClassDeclare( FBDevice,FBBox );
00670 public:
00674 enum kDeviceOperations {
00675 kOpInit,
00676 kOpStart,
00677 kOpAutoDetect,
00678 kOpStop,
00679 kOpReset,
00680 kOpDone
00681 };
00682
00686 enum kDeviceIOs {
00687 kIOStopModeRead,
00688 kIOPlayModeRead,
00689 kIOStopModeWrite,
00690 kIOPlayModeWrite
00691 };
00692
00696 enum kTransportMode {
00697 kPreparePlay,
00698 kPlayReady,
00699 kPlayStop,
00700 kStop,
00701 kPlay,
00702 kJog
00703 };
00704
00709 FBDevice(char * pName,HIObject pObject=NULL);
00710
00711
00712 virtual bool FBCreate ();
00713 virtual void FBDestroy ();
00714
00715
00716 virtual HFBAnimationNode AnimationNodeInCreate (kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00717 virtual HFBAnimationNode AnimationNodeOutCreate(kReference pUserId,char * pName ,char * pDataType,bool pIsPublic=true,double *pMin=NULL,double *pMax=NULL,bool pUserData=false);
00718
00724 virtual bool DeviceOperation( kDeviceOperations pOperation );
00725
00732 virtual void DeviceTransportNotify( kTransportMode pMode, FBTime pTime, FBTime pSystem );
00733
00740 virtual void DeviceIONotify( kDeviceIOs pAction, FBDeviceNotifyInfo& pDeviceNotifyInfo );
00741
00747 virtual bool DeviceEvaluationNotify( kTransportMode pMode,HFBEvaluateInfo pEvaluateInfo );
00748
00755 virtual bool ModelTemplateBindNotify( HFBModel pModel,int pIndex, HFBModelTemplate pModelTemplate );
00756
00762 virtual bool ModelTemplateUnBindNotify( int pIndex, HFBModelTemplate pModelTemplate );
00763
00770 virtual bool AnimationNodeNotify( HFBAnimationNode pAnimationNode, HFBEvaluateInfo pEvaluateInfo ) override;
00771
00772 virtual char* FbxGetObjectType() override;
00773
00775
00780 virtual bool FbxStore ( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat ) override;
00781 virtual bool FbxRetrieve( HFBFbxObject pFbxObject, kFbxObjectStore pStoreWhat ) override;
00783
00788 virtual void DeviceSendCommand( kDeviceOperations pOperation );
00789
00790 IObject_Declare( Implementation );
00791
00792 FBPropertyString IconFilename;
00793 FBPropertyString Status;
00794 FBPropertyString Information;
00795 FBPropertyString HardwareVersionInfo;
00796 FBPropertyTime SamplingPeriod;
00797 FBPropertyBool Online;
00798
00799 FBPropertyEvent OnStatusChange;
00800
00801 FBModelTemplate ModelTemplate;
00802
00803 FBPropertyDeviceSamplingMode SamplingMode;
00804 FBPropertyInt CommType;
00805
00806 FBPropertyListDeviceInstrument Instruments;
00807
00808 FBPropertyTime RecordingStartTime;
00809 FBPropertyTime RecordingStopTime;
00810
00812 void AckOneSampleReceived();
00813
00815 void AckOneBadSampleReceived();
00816
00818 void AckOneSampleSent();
00819
00823 virtual void RecordingInitAnimation(HFBAnimationNode pAnimationNode);
00824
00828 virtual void RecordingDoneAnimation(HFBAnimationNode pAnimationNode);
00829
00830 friend class __FBDevice;
00831 friend class DataFBDeviceOptical;
00832 };
00833
00834 #ifndef FBSDK_LEAN_AND_MEAN
00835
00836 __FB_FORWARD( FBDeviceGlove );
00837
00839 class FBSDK_DLL FBDeviceGlove : public FBDevice {
00840 __FBClassDeclare( FBDeviceGlove, FBDevice );
00841 public:
00844 enum kHandModelPart {
00845
00846 kPartRoot,
00847 kPartPalm,
00848
00849
00850 kPartThumbA,
00851 kPartThumbB,
00852 kPartThumbC,
00853 kPartThumbD,
00854
00855
00856 kPartIndexA,
00857 kPartIndexB,
00858 kPartIndexC,
00859 kPartIndexD,
00860
00861
00862 kPartMiddleA,
00863 kPartMiddleB,
00864 kPartMiddleC,
00865 kPartMiddleD,
00866
00867
00868 kPartRingA,
00869 kPartRingB,
00870 kPartRingC,
00871 kPartRingD,
00872
00873
00874 kPartLittleA,
00875 kPartLittleB,
00876 kPartLittleC,
00877 kPartLittleD,
00878
00879 kPartMax
00880 };
00881
00885 class FBSDK_DLL GloveChannel
00886 {
00887 public:
00891 GloveChannel( HFBAnimationNode pAnimNode );
00892
00895 virtual ~GloveChannel();
00896
00900 FBString GetName ();
00901
00905 void SetName ( FBString pName );
00906
00907 protected:
00908 FBString Name;
00909
00910 public:
00911 bool Enabled;
00912 HFBAnimationNode AnimNode;
00913 };
00914
00915
00920 FBDeviceGlove( char* pName, HIObject pObject=NULL );
00921
00925 virtual void RecordingInitAnimation( HFBAnimationNode pAnimationNode );
00926
00930 virtual void RecordingDoneAnimation( HFBAnimationNode pAnimationNode );
00931
00932 protected:
00937 void InitializeModelGeometry();
00938
00947 void VectorToModelPartAngle( kHandModelPart pPartIndex, FBVector3d& pVector );
00948
00953 HFBAnimationNode GetModelRotationNode( kHandModelPart pPartIndex );
00954
00955 public:
00956 FBArrayTemplate<GloveChannel*> Channels;
00957
00958 FBPropertyBool LeftHand;
00959 };
00960
00961 #endif
00962
00963 #ifdef FBSDKUseNamespace
00964 }
00965 #endif
00966 #endif