forked from gaojunxin/TSPlug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3dx9anim.h
1114 lines (961 loc) · 41.3 KB
/
d3dx9anim.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
// File: d3dx9anim.h
// Content: D3DX mesh types and functions
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3DX9ANIM_H__
#define __D3DX9ANIM_H__
// {698CFB3F-9289-4d95-9A57-33A94B5A65F9}
DEFINE_GUID(IID_ID3DXAnimationSet,
0x698cfb3f, 0x9289, 0x4d95, 0x9a, 0x57, 0x33, 0xa9, 0x4b, 0x5a, 0x65, 0xf9);
// {FA4E8E3A-9786-407d-8B4C-5995893764AF}
DEFINE_GUID(IID_ID3DXKeyframedAnimationSet,
0xfa4e8e3a, 0x9786, 0x407d, 0x8b, 0x4c, 0x59, 0x95, 0x89, 0x37, 0x64, 0xaf);
// {6CC2480D-3808-4739-9F88-DE49FACD8D4C}
DEFINE_GUID(IID_ID3DXCompressedAnimationSet,
0x6cc2480d, 0x3808, 0x4739, 0x9f, 0x88, 0xde, 0x49, 0xfa, 0xcd, 0x8d, 0x4c);
// {AC8948EC-F86D-43e2-96DE-31FC35F96D9E}
DEFINE_GUID(IID_ID3DXAnimationController,
0xac8948ec, 0xf86d, 0x43e2, 0x96, 0xde, 0x31, 0xfc, 0x35, 0xf9, 0x6d, 0x9e);
//----------------------------------------------------------------------------
// D3DXMESHDATATYPE:
// -----------------
// This enum defines the type of mesh data present in a MeshData structure.
//----------------------------------------------------------------------------
typedef enum _D3DXMESHDATATYPE {
D3DXMESHTYPE_MESH = 0x001, // Normal ID3DXMesh data
D3DXMESHTYPE_PMESH = 0x002, // Progressive Mesh - ID3DXPMesh
D3DXMESHTYPE_PATCHMESH = 0x003, // Patch Mesh - ID3DXPatchMesh
D3DXMESHTYPE_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DXMESHDATATYPE;
//----------------------------------------------------------------------------
// D3DXMESHDATA:
// -------------
// This struct encapsulates a the mesh data that can be present in a mesh
// container. The supported mesh types are pMesh, pPMesh, pPatchMesh.
// The valid way to access this is determined by the Type enum.
//----------------------------------------------------------------------------
typedef struct _D3DXMESHDATA
{
D3DXMESHDATATYPE Type;
// current mesh data interface
union
{
LPD3DXMESH pMesh;
LPD3DXPMESH pPMesh;
LPD3DXPATCHMESH pPatchMesh;
};
} D3DXMESHDATA, *LPD3DXMESHDATA;
//----------------------------------------------------------------------------
// D3DXMESHCONTAINER:
// ------------------
// This struct encapsulates a mesh object in a transformation frame
// hierarchy. The app can derive from this structure to add other app specific
// data to this.
//----------------------------------------------------------------------------
typedef struct _D3DXMESHCONTAINER
{
LPSTR Name;
D3DXMESHDATA MeshData;
LPD3DXMATERIAL pMaterials;
LPD3DXEFFECTINSTANCE pEffects;
DWORD NumMaterials;
DWORD *pAdjacency;
LPD3DXSKININFO pSkinInfo;
struct _D3DXMESHCONTAINER *pNextMeshContainer;
} D3DXMESHCONTAINER, *LPD3DXMESHCONTAINER;
//----------------------------------------------------------------------------
// D3DXFRAME:
// ----------
// This struct is the encapsulates a transform frame in a transformation frame
// hierarchy. The app can derive from this structure to add other app specific
// data to this
//----------------------------------------------------------------------------
typedef struct _D3DXFRAME
{
LPSTR Name;
D3DXMATRIX TransformationMatrix;
LPD3DXMESHCONTAINER pMeshContainer;
struct _D3DXFRAME *pFrameSibling;
struct _D3DXFRAME *pFrameFirstChild;
} D3DXFRAME, *LPD3DXFRAME;
//----------------------------------------------------------------------------
// ID3DXAllocateHierarchy:
// -----------------------
// This interface is implemented by the application to allocate/free frame and
// mesh container objects. Methods on this are called during loading and
// destroying frame hierarchies
//----------------------------------------------------------------------------
typedef interface ID3DXAllocateHierarchy ID3DXAllocateHierarchy;
typedef interface ID3DXAllocateHierarchy *LPD3DXALLOCATEHIERARCHY;
#undef INTERFACE
#define INTERFACE ID3DXAllocateHierarchy
DECLARE_INTERFACE(ID3DXAllocateHierarchy)
{
// ID3DXAllocateHierarchy
//------------------------------------------------------------------------
// CreateFrame:
// ------------
// Requests allocation of a frame object.
//
// Parameters:
// Name
// Name of the frame to be created
// ppNewFrame
// Returns the created frame object
//
//------------------------------------------------------------------------
STDMETHOD(CreateFrame)(THIS_ LPCSTR Name,
LPD3DXFRAME *ppNewFrame) PURE;
//------------------------------------------------------------------------
// CreateMeshContainer:
// --------------------
// Requests allocation of a mesh container object.
//
// Parameters:
// Name
// Name of the mesh
// pMesh
// Pointer to the mesh object if basic polygon data found
// pPMesh
// Pointer to the progressive mesh object if progressive mesh data found
// pPatchMesh
// Pointer to the patch mesh object if patch data found
// pMaterials
// Array of materials used in the mesh
// pEffectInstances
// Array of effect instances used in the mesh
// NumMaterials
// Num elements in the pMaterials array
// pAdjacency
// Adjacency array for the mesh
// pSkinInfo
// Pointer to the skininfo object if the mesh is skinned
// pBoneNames
// Array of names, one for each bone in the skinned mesh.
// The numberof bones can be found from the pSkinMesh object
// pBoneOffsetMatrices
// Array of matrices, one for each bone in the skinned mesh.
//
//------------------------------------------------------------------------
STDMETHOD(CreateMeshContainer)(THIS_
LPCSTR Name,
CONST D3DXMESHDATA *pMeshData,
CONST D3DXMATERIAL *pMaterials,
CONST D3DXEFFECTINSTANCE *pEffectInstances,
DWORD NumMaterials,
CONST DWORD *pAdjacency,
LPD3DXSKININFO pSkinInfo,
LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE;
//------------------------------------------------------------------------
// DestroyFrame:
// -------------
// Requests de-allocation of a frame object.
//
// Parameters:
// pFrameToFree
// Pointer to the frame to be de-allocated
//
//------------------------------------------------------------------------
STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE;
//------------------------------------------------------------------------
// DestroyMeshContainer:
// ---------------------
// Requests de-allocation of a mesh container object.
//
// Parameters:
// pMeshContainerToFree
// Pointer to the mesh container object to be de-allocated
//
//------------------------------------------------------------------------
STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE;
};
//----------------------------------------------------------------------------
// ID3DXLoadUserData:
// ------------------
// This interface is implemented by the application to load user data in a .X file
// When user data is found, these callbacks will be used to allow the application
// to load the data.
//----------------------------------------------------------------------------
typedef interface ID3DXLoadUserData ID3DXLoadUserData;
typedef interface ID3DXLoadUserData *LPD3DXLOADUSERDATA;
#undef INTERFACE
#define INTERFACE ID3DXLoadUserData
DECLARE_INTERFACE(ID3DXLoadUserData)
{
STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE;
STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame,
LPD3DXFILEDATA pXofChildData) PURE;
STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer,
LPD3DXFILEDATA pXofChildData) PURE;
};
//----------------------------------------------------------------------------
// ID3DXSaveUserData:
// ------------------
// This interface is implemented by the application to save user data in a .X file
// The callbacks are called for all data saved. The user can then add any
// child data objects to the object provided to the callback.
//----------------------------------------------------------------------------
typedef interface ID3DXSaveUserData ID3DXSaveUserData;
typedef interface ID3DXSaveUserData *LPD3DXSAVEUSERDATA;
#undef INTERFACE
#define INTERFACE ID3DXSaveUserData
DECLARE_INTERFACE(ID3DXSaveUserData)
{
STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame,
LPD3DXFILESAVEOBJECT pXofSave,
LPD3DXFILESAVEDATA pXofFrameData) PURE;
STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer,
LPD3DXFILESAVEOBJECT pXofSave,
LPD3DXFILESAVEDATA pXofMeshData) PURE;
// NOTE: this is called once per Save. All top level objects should be added using the
// provided interface. One call adds objects before the frame hierarchy, the other after
STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE;
STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE;
// callbacks for the user to register and then save templates to the XFile
STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE;
STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE;
};
//----------------------------------------------------------------------------
// D3DXCALLBACK_SEARCH_FLAGS:
// --------------------------
// Flags that can be passed into ID3DXAnimationSet::GetCallback.
//----------------------------------------------------------------------------
typedef enum _D3DXCALLBACK_SEARCH_FLAGS
{
D3DXCALLBACK_SEARCH_EXCLUDING_INITIAL_POSITION = 0x01, // exclude callbacks at the initial position from the search
D3DXCALLBACK_SEARCH_BEHIND_INITIAL_POSITION = 0x02, // reverse the callback search direction
D3DXCALLBACK_SEARCH_FORCE_DWORD = 0x7fffffff,
} D3DXCALLBACK_SEARCH_FLAGS;
//----------------------------------------------------------------------------
// ID3DXAnimationSet:
// ------------------
// This interface implements an animation set.
//----------------------------------------------------------------------------
typedef interface ID3DXAnimationSet ID3DXAnimationSet;
typedef interface ID3DXAnimationSet *LPD3DXANIMATIONSET;
#undef INTERFACE
#define INTERFACE ID3DXAnimationSet
DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown)
{
// IUnknown
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Name
STDMETHOD_(LPCSTR, GetName)(THIS) PURE;
// Period
STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE;
STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period
// Animation names
STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE;
STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE;
STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE;
// SRT
STDMETHOD(GetSRT)(THIS_
DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition)
UINT Animation, // Animation index
D3DXVECTOR3 *pScale, // Returns the scale
D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion
D3DXVECTOR3 *pTranslation) PURE; // Returns the translation
// Callbacks
STDMETHOD(GetCallback)(THIS_
DOUBLE Position, // Position from which to find callbacks
DWORD Flags, // Callback search flags
DOUBLE *pCallbackPosition, // Returns the position of the callback
LPVOID *ppCallbackData) PURE; // Returns the callback data pointer
};
//----------------------------------------------------------------------------
// D3DXPLAYBACK_TYPE:
// ------------------
// This enum defines the type of animation set loop modes.
//----------------------------------------------------------------------------
typedef enum _D3DXPLAYBACK_TYPE
{
D3DXPLAY_LOOP = 0,
D3DXPLAY_ONCE = 1,
D3DXPLAY_PINGPONG = 2,
D3DXPLAY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DXPLAYBACK_TYPE;
//----------------------------------------------------------------------------
// D3DXKEY_VECTOR3:
// ----------------
// This structure describes a vector key for use in keyframe animation.
// It specifies a vector Value at a given Time. This is used for scale and
// translation keys.
//----------------------------------------------------------------------------
typedef struct _D3DXKEY_VECTOR3
{
FLOAT Time;
D3DXVECTOR3 Value;
} D3DXKEY_VECTOR3, *LPD3DXKEY_VECTOR3;
//----------------------------------------------------------------------------
// D3DXKEY_QUATERNION:
// -------------------
// This structure describes a quaternion key for use in keyframe animation.
// It specifies a quaternion Value at a given Time. This is used for rotation
// keys.
//----------------------------------------------------------------------------
typedef struct _D3DXKEY_QUATERNION
{
FLOAT Time;
D3DXQUATERNION Value;
} D3DXKEY_QUATERNION, *LPD3DXKEY_QUATERNION;
//----------------------------------------------------------------------------
// D3DXKEY_CALLBACK:
// -----------------
// This structure describes an callback key for use in keyframe animation.
// It specifies a pointer to user data at a given Time.
//----------------------------------------------------------------------------
typedef struct _D3DXKEY_CALLBACK
{
FLOAT Time;
LPVOID pCallbackData;
} D3DXKEY_CALLBACK, *LPD3DXKEY_CALLBACK;
//----------------------------------------------------------------------------
// D3DXCOMPRESSION_FLAGS:
// ----------------------
// Flags that can be passed into ID3DXKeyframedAnimationSet::Compress.
//----------------------------------------------------------------------------
typedef enum _D3DXCOMPRESSION_FLAGS
{
D3DXCOMPRESS_DEFAULT = 0x00,
D3DXCOMPRESS_FORCE_DWORD = 0x7fffffff,
} D3DXCOMPRESSION_FLAGS;
//----------------------------------------------------------------------------
// ID3DXKeyframedAnimationSet:
// ---------------------------
// This interface implements a compressable keyframed animation set.
//----------------------------------------------------------------------------
typedef interface ID3DXKeyframedAnimationSet ID3DXKeyframedAnimationSet;
typedef interface ID3DXKeyframedAnimationSet *LPD3DXKEYFRAMEDANIMATIONSET;
#undef INTERFACE
#define INTERFACE ID3DXKeyframedAnimationSet
DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet)
{
// ID3DXAnimationSet
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Name
STDMETHOD_(LPCSTR, GetName)(THIS) PURE;
// Period
STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE;
STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period
// Animation names
STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE;
STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE;
STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE;
// SRT
STDMETHOD(GetSRT)(THIS_
DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition)
UINT Animation, // Animation index
D3DXVECTOR3 *pScale, // Returns the scale
D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion
D3DXVECTOR3 *pTranslation) PURE; // Returns the translation
// Callbacks
STDMETHOD(GetCallback)(THIS_
DOUBLE Position, // Position from which to find callbacks
DWORD Flags, // Callback search flags
DOUBLE *pCallbackPosition, // Returns the position of the callback
LPVOID *ppCallbackData) PURE; // Returns the callback data pointer
// Playback
STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE;
STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE;
// Scale keys
STDMETHOD_(UINT, GetNumScaleKeys)(THIS_ UINT Animation) PURE;
STDMETHOD(GetScaleKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pScaleKeys) PURE;
STDMETHOD(GetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE;
STDMETHOD(SetScaleKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pScaleKey) PURE;
// Rotation keys
STDMETHOD_(UINT, GetNumRotationKeys)(THIS_ UINT Animation) PURE;
STDMETHOD(GetRotationKeys)(THIS_ UINT Animation, LPD3DXKEY_QUATERNION pRotationKeys) PURE;
STDMETHOD(GetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE;
STDMETHOD(SetRotationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_QUATERNION pRotationKey) PURE;
// Translation keys
STDMETHOD_(UINT, GetNumTranslationKeys)(THIS_ UINT Animation) PURE;
STDMETHOD(GetTranslationKeys)(THIS_ UINT Animation, LPD3DXKEY_VECTOR3 pTranslationKeys) PURE;
STDMETHOD(GetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE;
STDMETHOD(SetTranslationKey)(THIS_ UINT Animation, UINT Key, LPD3DXKEY_VECTOR3 pTranslationKey) PURE;
// Callback keys
STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE;
STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE;
STDMETHOD(GetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE;
STDMETHOD(SetCallbackKey)(THIS_ UINT Key, LPD3DXKEY_CALLBACK pCallbackKey) PURE;
// Key removal methods. These are slow, and should not be used once the animation starts playing
STDMETHOD(UnregisterScaleKey)(THIS_ UINT Animation, UINT Key) PURE;
STDMETHOD(UnregisterRotationKey)(THIS_ UINT Animation, UINT Key) PURE;
STDMETHOD(UnregisterTranslationKey)(THIS_ UINT Animation, UINT Key) PURE;
// One-time animaton SRT keyframe registration
STDMETHOD(RegisterAnimationSRTKeys)(THIS_
LPCSTR pName, // Animation name
UINT NumScaleKeys, // Number of scale keys
UINT NumRotationKeys, // Number of rotation keys
UINT NumTranslationKeys, // Number of translation keys
CONST D3DXKEY_VECTOR3 *pScaleKeys, // Array of scale keys
CONST D3DXKEY_QUATERNION *pRotationKeys, // Array of rotation keys
CONST D3DXKEY_VECTOR3 *pTranslationKeys, // Array of translation keys
DWORD *pAnimationIndex) PURE; // Returns the animation index
// Compression
STDMETHOD(Compress)(THIS_
DWORD Flags, // Compression flags (use D3DXCOMPRESS_STRONG for better results)
FLOAT Lossiness, // Compression loss ratio in the [0, 1] range
LPD3DXFRAME pHierarchy, // Frame hierarchy (optional)
LPD3DXBUFFER *ppCompressedData) PURE; // Returns the compressed animation set
STDMETHOD(UnregisterAnimation)(THIS_ UINT Index) PURE;
};
//----------------------------------------------------------------------------
// ID3DXCompressedAnimationSet:
// ----------------------------
// This interface implements a compressed keyframed animation set.
//----------------------------------------------------------------------------
typedef interface ID3DXCompressedAnimationSet ID3DXCompressedAnimationSet;
typedef interface ID3DXCompressedAnimationSet *LPD3DXCOMPRESSEDANIMATIONSET;
#undef INTERFACE
#define INTERFACE ID3DXCompressedAnimationSet
DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet)
{
// ID3DXAnimationSet
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Name
STDMETHOD_(LPCSTR, GetName)(THIS) PURE;
// Period
STDMETHOD_(DOUBLE, GetPeriod)(THIS) PURE;
STDMETHOD_(DOUBLE, GetPeriodicPosition)(THIS_ DOUBLE Position) PURE; // Maps position into animation period
// Animation names
STDMETHOD_(UINT, GetNumAnimations)(THIS) PURE;
STDMETHOD(GetAnimationNameByIndex)(THIS_ UINT Index, LPCSTR *ppName) PURE;
STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE;
// SRT
STDMETHOD(GetSRT)(THIS_
DOUBLE PeriodicPosition, // Position mapped to period (use GetPeriodicPosition)
UINT Animation, // Animation index
D3DXVECTOR3 *pScale, // Returns the scale
D3DXQUATERNION *pRotation, // Returns the rotation as a quaternion
D3DXVECTOR3 *pTranslation) PURE; // Returns the translation
// Callbacks
STDMETHOD(GetCallback)(THIS_
DOUBLE Position, // Position from which to find callbacks
DWORD Flags, // Callback search flags
DOUBLE *pCallbackPosition, // Returns the position of the callback
LPVOID *ppCallbackData) PURE; // Returns the callback data pointer
// Playback
STDMETHOD_(D3DXPLAYBACK_TYPE, GetPlaybackType)(THIS) PURE;
STDMETHOD_(DOUBLE, GetSourceTicksPerSecond)(THIS) PURE;
// Scale keys
STDMETHOD(GetCompressedData)(THIS_ LPD3DXBUFFER *ppCompressedData) PURE;
// Callback keys
STDMETHOD_(UINT, GetNumCallbackKeys)(THIS) PURE;
STDMETHOD(GetCallbackKeys)(THIS_ LPD3DXKEY_CALLBACK pCallbackKeys) PURE;
};
//----------------------------------------------------------------------------
// D3DXPRIORITY_TYPE:
// ------------------
// This enum defines the type of priority group that a track can be assigned to.
//----------------------------------------------------------------------------
typedef enum _D3DXPRIORITY_TYPE {
D3DXPRIORITY_LOW = 0, // This track should be blended with all low priority tracks before mixed with the high priority result
D3DXPRIORITY_HIGH = 1, // This track should be blended with all high priority tracks before mixed with the low priority result
D3DXPRIORITY_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DXPRIORITY_TYPE;
//----------------------------------------------------------------------------
// D3DXTRACK_DESC:
// ---------------
// This structure describes the mixing information of an animation track.
// The mixing information consists of the current position, speed, and blending
// weight for the track. The Flags field also specifies whether the track is
// low or high priority. Tracks with the same priority are blended together
// and then the two resulting values are blended using the priority blend factor.
// A track also has an animation set (stored separately) associated with it.
//----------------------------------------------------------------------------
typedef struct _D3DXTRACK_DESC
{
D3DXPRIORITY_TYPE Priority;
FLOAT Weight;
FLOAT Speed;
DOUBLE Position;
BOOL Enable;
} D3DXTRACK_DESC, *LPD3DXTRACK_DESC;
//----------------------------------------------------------------------------
// D3DXEVENT_TYPE:
// ---------------
// This enum defines the type of events keyable via the animation controller.
//----------------------------------------------------------------------------
typedef enum _D3DXEVENT_TYPE
{
D3DXEVENT_TRACKSPEED = 0,
D3DXEVENT_TRACKWEIGHT = 1,
D3DXEVENT_TRACKPOSITION = 2,
D3DXEVENT_TRACKENABLE = 3,
D3DXEVENT_PRIORITYBLEND = 4,
D3DXEVENT_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DXEVENT_TYPE;
//----------------------------------------------------------------------------
// D3DXTRANSITION_TYPE:
// --------------------
// This enum defines the type of transtion performed on a event that
// transitions from one value to another.
//----------------------------------------------------------------------------
typedef enum _D3DXTRANSITION_TYPE {
D3DXTRANSITION_LINEAR = 0x000, // Linear transition from one value to the next
D3DXTRANSITION_EASEINEASEOUT = 0x001, // Ease-In Ease-Out spline transtion from one value to the next
D3DXTRANSITION_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */
} D3DXTRANSITION_TYPE;
//----------------------------------------------------------------------------
// D3DXEVENT_DESC:
// ---------------
// This structure describes a animation controller event.
// It gives the event's type, track (if the event is a track event), global
// start time, duration, transition method, and target value.
//----------------------------------------------------------------------------
typedef struct _D3DXEVENT_DESC
{
D3DXEVENT_TYPE Type;
UINT Track;
DOUBLE StartTime;
DOUBLE Duration;
D3DXTRANSITION_TYPE Transition;
union
{
FLOAT Weight;
FLOAT Speed;
DOUBLE Position;
BOOL Enable;
};
} D3DXEVENT_DESC, *LPD3DXEVENT_DESC;
//----------------------------------------------------------------------------
// D3DXEVENTHANDLE:
// ----------------
// Handle values used to efficiently reference animation controller events.
//----------------------------------------------------------------------------
typedef DWORD D3DXEVENTHANDLE;
typedef D3DXEVENTHANDLE *LPD3DXEVENTHANDLE;
//----------------------------------------------------------------------------
// ID3DXAnimationCallbackHandler:
// ------------------------------
// This interface is intended to be implemented by the application, and can
// be used to handle callbacks in animation sets generated when
// ID3DXAnimationController::AdvanceTime() is called.
//----------------------------------------------------------------------------
typedef interface ID3DXAnimationCallbackHandler ID3DXAnimationCallbackHandler;
typedef interface ID3DXAnimationCallbackHandler *LPD3DXANIMATIONCALLBACKHANDLER;
#undef INTERFACE
#define INTERFACE ID3DXAnimationCallbackHandler
DECLARE_INTERFACE(ID3DXAnimationCallbackHandler)
{
//----------------------------------------------------------------------------
// ID3DXAnimationCallbackHandler::HandleCallback:
// ----------------------------------------------
// This method gets called when a callback occurs for an animation set in one
// of the tracks during the ID3DXAnimationController::AdvanceTime() call.
//
// Parameters:
// Track
// Index of the track on which the callback occured.
// pCallbackData
// Pointer to user owned callback data.
//
//----------------------------------------------------------------------------
STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE;
};
//----------------------------------------------------------------------------
// ID3DXAnimationController:
// -------------------------
// This interface implements the main animation functionality. It connects
// animation sets with the transform frames that are being animated. Allows
// mixing multiple animations for blended animations or for transistions
// It adds also has methods to modify blending parameters over time to
// enable smooth transistions and other effects.
//----------------------------------------------------------------------------
typedef interface ID3DXAnimationController ID3DXAnimationController;
typedef interface ID3DXAnimationController *LPD3DXANIMATIONCONTROLLER;
#undef INTERFACE
#define INTERFACE ID3DXAnimationController
DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown)
{
// IUnknown
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Max sizes
STDMETHOD_(UINT, GetMaxNumAnimationOutputs)(THIS) PURE;
STDMETHOD_(UINT, GetMaxNumAnimationSets)(THIS) PURE;
STDMETHOD_(UINT, GetMaxNumTracks)(THIS) PURE;
STDMETHOD_(UINT, GetMaxNumEvents)(THIS) PURE;
// Animation output registration
STDMETHOD(RegisterAnimationOutput)(THIS_
LPCSTR pName,
D3DXMATRIX *pMatrix,
D3DXVECTOR3 *pScale,
D3DXQUATERNION *pRotation,
D3DXVECTOR3 *pTranslation) PURE;
// Animation set registration
STDMETHOD(RegisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE;
STDMETHOD(UnregisterAnimationSet)(THIS_ LPD3DXANIMATIONSET pAnimSet) PURE;
STDMETHOD_(UINT, GetNumAnimationSets)(THIS) PURE;
STDMETHOD(GetAnimationSet)(THIS_ UINT Index, LPD3DXANIMATIONSET *ppAnimationSet) PURE;
STDMETHOD(GetAnimationSetByName)(THIS_ LPCSTR szName, LPD3DXANIMATIONSET *ppAnimationSet) PURE;
// Global time
STDMETHOD(AdvanceTime)(THIS_ DOUBLE TimeDelta, LPD3DXANIMATIONCALLBACKHANDLER pCallbackHandler) PURE;
STDMETHOD(ResetTime)(THIS) PURE;
STDMETHOD_(DOUBLE, GetTime)(THIS) PURE;
// Tracks
STDMETHOD(SetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET pAnimSet) PURE;
STDMETHOD(GetTrackAnimationSet)(THIS_ UINT Track, LPD3DXANIMATIONSET *ppAnimSet) PURE;
STDMETHOD(SetTrackPriority)(THIS_ UINT Track, D3DXPRIORITY_TYPE Priority) PURE;
STDMETHOD(SetTrackSpeed)(THIS_ UINT Track, FLOAT Speed) PURE;
STDMETHOD(SetTrackWeight)(THIS_ UINT Track, FLOAT Weight) PURE;
STDMETHOD(SetTrackPosition)(THIS_ UINT Track, DOUBLE Position) PURE;
STDMETHOD(SetTrackEnable)(THIS_ UINT Track, BOOL Enable) PURE;
STDMETHOD(SetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE;
STDMETHOD(GetTrackDesc)(THIS_ UINT Track, LPD3DXTRACK_DESC pDesc) PURE;
// Priority blending
STDMETHOD(SetPriorityBlend)(THIS_ FLOAT BlendWeight) PURE;
STDMETHOD_(FLOAT, GetPriorityBlend)(THIS) PURE;
// Event keying
STDMETHOD_(D3DXEVENTHANDLE, KeyTrackSpeed)(THIS_ UINT Track, FLOAT NewSpeed, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE;
STDMETHOD_(D3DXEVENTHANDLE, KeyTrackWeight)(THIS_ UINT Track, FLOAT NewWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE;
STDMETHOD_(D3DXEVENTHANDLE, KeyTrackPosition)(THIS_ UINT Track, DOUBLE NewPosition, DOUBLE StartTime) PURE;
STDMETHOD_(D3DXEVENTHANDLE, KeyTrackEnable)(THIS_ UINT Track, BOOL NewEnable, DOUBLE StartTime) PURE;
STDMETHOD_(D3DXEVENTHANDLE, KeyPriorityBlend)(THIS_ FLOAT NewBlendWeight, DOUBLE StartTime, DOUBLE Duration, D3DXTRANSITION_TYPE Transition) PURE;
// Event unkeying
STDMETHOD(UnkeyEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE;
STDMETHOD(UnkeyAllTrackEvents)(THIS_ UINT Track) PURE;
STDMETHOD(UnkeyAllPriorityBlends)(THIS) PURE;
// Event enumeration
STDMETHOD_(D3DXEVENTHANDLE, GetCurrentTrackEvent)(THIS_ UINT Track, D3DXEVENT_TYPE EventType) PURE;
STDMETHOD_(D3DXEVENTHANDLE, GetCurrentPriorityBlend)(THIS) PURE;
STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingTrackEvent)(THIS_ UINT Track, D3DXEVENTHANDLE hEvent) PURE;
STDMETHOD_(D3DXEVENTHANDLE, GetUpcomingPriorityBlend)(THIS_ D3DXEVENTHANDLE hEvent) PURE;
STDMETHOD(ValidateEvent)(THIS_ D3DXEVENTHANDLE hEvent) PURE;
STDMETHOD(GetEventDesc)(THIS_ D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc) PURE;
// Cloning
STDMETHOD(CloneAnimationController)(THIS_
UINT MaxNumAnimationOutputs,
UINT MaxNumAnimationSets,
UINT MaxNumTracks,
UINT MaxNumEvents,
LPD3DXANIMATIONCONTROLLER *ppAnimController) PURE;
};
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
//----------------------------------------------------------------------------
// D3DXLoadMeshHierarchyFromX:
// ---------------------------
// Loads the first frame hierarchy in a .X file.
//
// Parameters:
// Filename
// Name of the .X file
// MeshOptions
// Mesh creation options for meshes in the file (see d3dx9mesh.h)
// pD3DDevice
// D3D9 device on which meshes in the file are created in
// pAlloc
// Allocation interface used to allocate nodes of the frame hierarchy
// pUserDataLoader
// Application provided interface to allow loading of user data
// ppFrameHierarchy
// Returns root node pointer of the loaded frame hierarchy
// ppAnimController
// Returns pointer to an animation controller corresponding to animation
// in the .X file. This is created with default max tracks and events
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXLoadMeshHierarchyFromXA
(
LPCSTR Filename,
DWORD MeshOptions,
LPDIRECT3DDEVICE9 pD3DDevice,
LPD3DXALLOCATEHIERARCHY pAlloc,
LPD3DXLOADUSERDATA pUserDataLoader,
LPD3DXFRAME *ppFrameHierarchy,
LPD3DXANIMATIONCONTROLLER *ppAnimController
);
HRESULT WINAPI
D3DXLoadMeshHierarchyFromXW
(
LPCWSTR Filename,
DWORD MeshOptions,
LPDIRECT3DDEVICE9 pD3DDevice,
LPD3DXALLOCATEHIERARCHY pAlloc,
LPD3DXLOADUSERDATA pUserDataLoader,
LPD3DXFRAME *ppFrameHierarchy,
LPD3DXANIMATIONCONTROLLER *ppAnimController
);
#ifdef UNICODE
#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXW
#else
#define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXA
#endif
HRESULT WINAPI
D3DXLoadMeshHierarchyFromXInMemory
(
LPCVOID Memory,
DWORD SizeOfMemory,
DWORD MeshOptions,
LPDIRECT3DDEVICE9 pD3DDevice,
LPD3DXALLOCATEHIERARCHY pAlloc,
LPD3DXLOADUSERDATA pUserDataLoader,
LPD3DXFRAME *ppFrameHierarchy,
LPD3DXANIMATIONCONTROLLER *ppAnimController
);
//----------------------------------------------------------------------------
// D3DXSaveMeshHierarchyToFile:
// ----------------------------
// Creates a .X file and saves the mesh hierarchy and corresponding animations
// in it
//
// Parameters:
// Filename
// Name of the .X file
// XFormat
// Format of the .X file (text or binary, compressed or not, etc)
// pFrameRoot
// Root node of the hierarchy to be saved
// pAnimController
// The animation controller whose animation sets are to be stored
// pUserDataSaver
// Application provided interface to allow adding of user data to
// data objects saved to .X file
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXSaveMeshHierarchyToFileA
(
LPCSTR Filename,
DWORD XFormat,
CONST D3DXFRAME *pFrameRoot,
LPD3DXANIMATIONCONTROLLER pAnimcontroller,
LPD3DXSAVEUSERDATA pUserDataSaver
);
HRESULT WINAPI
D3DXSaveMeshHierarchyToFileW
(
LPCWSTR Filename,
DWORD XFormat,
CONST D3DXFRAME *pFrameRoot,
LPD3DXANIMATIONCONTROLLER pAnimController,
LPD3DXSAVEUSERDATA pUserDataSaver
);
#ifdef UNICODE
#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileW
#else
#define D3DXSaveMeshHierarchyToFile D3DXSaveMeshHierarchyToFileA
#endif
//----------------------------------------------------------------------------
// D3DXFrameDestroy:
// -----------------
// Destroys the subtree of frames under the root, including the root
//
// Parameters:
// pFrameRoot
// Pointer to the root node
// pAlloc
// Allocation interface used to de-allocate nodes of the frame hierarchy
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXFrameDestroy
(
LPD3DXFRAME pFrameRoot,
LPD3DXALLOCATEHIERARCHY pAlloc
);
//----------------------------------------------------------------------------
// D3DXFrameAppendChild:
// ---------------------
// Add a child frame to a frame
//
// Parameters:
// pFrameParent
// Pointer to the parent node
// pFrameChild
// Pointer to the child node
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXFrameAppendChild
(
LPD3DXFRAME pFrameParent,
CONST D3DXFRAME *pFrameChild
);
//----------------------------------------------------------------------------
// D3DXFrameFind:
// --------------
// Finds a frame with the given name. Returns NULL if no frame found.
//
// Parameters:
// pFrameRoot
// Pointer to the root node
// Name
// Name of frame to find
//
//----------------------------------------------------------------------------
LPD3DXFRAME WINAPI
D3DXFrameFind
(
CONST D3DXFRAME *pFrameRoot,
LPCSTR Name
);
//----------------------------------------------------------------------------
// D3DXFrameRegisterNamedMatrices:
// -------------------------------
// Finds all frames that have non-null names and registers each of those frame
// matrices to the given animation controller
//
// Parameters:
// pFrameRoot
// Pointer to the root node
// pAnimController
// Pointer to the animation controller where the matrices are registered
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXFrameRegisterNamedMatrices
(
LPD3DXFRAME pFrameRoot,
LPD3DXANIMATIONCONTROLLER pAnimController
);
//----------------------------------------------------------------------------
// D3DXFrameNumNamedMatrices:
// --------------------------
// Counts number of frames in a subtree that have non-null names
//
// Parameters:
// pFrameRoot
// Pointer to the root node of the subtree
// Return Value:
// Count of frames
//
//----------------------------------------------------------------------------
UINT WINAPI
D3DXFrameNumNamedMatrices
(
CONST D3DXFRAME *pFrameRoot
);
//----------------------------------------------------------------------------
// D3DXFrameCalculateBoundingSphere:
// ---------------------------------
// Computes the bounding sphere of all the meshes in the frame hierarchy.
//
// Parameters:
// pFrameRoot
// Pointer to the root node
// pObjectCenter
// Returns the center of the bounding sphere
// pObjectRadius
// Returns the radius of the bounding sphere
//
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DXFrameCalculateBoundingSphere