summaryrefslogtreecommitdiffstats
path: root/sdk/rwsdk/include/d3d8/rpprtstd.h
blob: ba0bf1d6a4ed57a5bc42a03b30353e9de467f73c (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073

#ifndef RPPRTSTD_H
#define RPPRTSTD_H

/*===========================================================================*
 *--- Include files ---------------------------------------------------------*
 *===========================================================================*/

#include "rwcore.h"
#include "rpworld.h"


/*---- start: ./prtstd.h----*/

#include "rwcore.h"
#include "rpworld.h"
#include "rpptank.h"

#include "rpprtstd.rpe"



/************************************************************************
 *
 *
 *
 ************************************************************************/

/**
 * \defgroup rpprtstd RpPrtStd
 * \ingroup particles
 *
 * Particle Animation Plugin for RenderWare Graphics.
 */

/*
 * Current version stamp
 */
#define rpPRTSTDVERSIONSTAMP                2

/*
 * Random Number Generation Macros
 */
#define PRTSTD_SRAND_MAX                    0xFFFFFFFF
#define PRTSTD_SRAND_IMAX                   ((RwReal) 1.0 / (RwReal) PRTSTD_SRAND_MAX)

#define PRTSTD_SRAND(_seed)                 ((_seed) = ((_seed) * 196314165 + 907633515))

/* Real rand -1.0 .. + 1.0 */
#define PRTSTD_RSRAND(_seed)                (((RwReal)((RwUInt32) (_seed) * PRTSTD_SRAND_IMAX) * \
                                            (RwReal) 2.0) - (RwReal) 1.0)



#define PRTSTD_2RSRAND2(_seed)               (((RwReal)((RwReal) (_seed) * PRTSTD_SRAND_IMAX) * \
                                            (RwReal)1.0))

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdParticleFlags, this type represents the different properties of
 * a particle.
 */
enum RpPrtStdParticleFlags
{
    rpPRTSTDPARTICLEFLAGEMITTER              = 0x00000001, /**<Particle is an emitter. */

    rpPRTSTDPARTICLEFLAGFORCEENUMSIZEINT    = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdParticleFlags RpPrtStdParticleFlags;

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdEmitterFlags, this type represents the different properties of
 * an emitter.
 */
enum RpPrtStdEmitterFlags
{
    rpPRTSTDEMITTERFLAGALIVE                = 0x00000001, /**< The emitter is alive and should not be removed */
    rpPRTSTDEMITTERFLAGACTIVE               = 0x00000002, /**< This indicates the emitter is active or idle */
    rpPRTSTDEMITTERFLAGPTANK                = 0x00000004, /**< The emitter uses the \ref rpptank */
    rpPRTSTDEMITTERFLAGEMIT                 = 0x00000008, /**< This indicates the emitter can emit new particles */
    rpPRTSTDEMITTERFLAGUPDATE               = 0x00000010, /**< This indicates if the emitter is to be updated. */
    rpPRTSTDEMITTERFLAGUPDATEPARTICLE       = 0x00000020, /**< This indicated if the emitter's particles are updated. */
    rpPRTSTDEMITTERFLAGRENDER               = 0x00000040, /**< This indicates if the emitter is rendered. */
    rpPRTSTDEMITTERFLAGRENDERPARTICLE       = 0x00000080, /**< This indicates if the emitter's particles are rendered. */
    rpPRTSTDEMITTERFLAGNOBUFFERSWAP         = 0x00000100, /**< Internal usage */
    rpPRTSTDEMITTERFLAGSTREAMREAD           = 0x00000200, /**< Internal usage */
    rpPRTSTDEMITTERFLAGFORCEENUMSIZEINT     = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdEmitterFlags RpPrtStdEmitterFlags;

/************************************************************************
 *
 *
 *
 ************************************************************************/

#define rpPRTSTDPARTICLECALLBACKMAX             7

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdParticleCallBackCode, this type represents the different callbacks for
 * processing a \ref RpPrtStdParticleBatch. These callbacks will be called at various point for
 * processing the particle's custom data.
 */
enum RpPrtStdParticleCallBackCode
{
    rpPRTSTDPARTICLECALLBACKUPDATE              = 0, /**< Particle update callback */
    rpPRTSTDPARTICLECALLBACKRENDER,                  /**< Particle render callback */
    rpPRTSTDPARTICLECALLBACKCREATE,                  /**< Particle create callback */
    rpPRTSTDPARTICLECALLBACKDESTROY,                 /**< Particle destroy callback */
    rpPRTSTDPARTICLECALLBACKFORCEENUMSIZEINT    = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdParticleCallBackCode RpPrtStdParticleCallBackCode;

#define rpPRTSTDEMITTERCALLBACKMAX              11

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdEmitterCallBackCode, this type represents the different callbacks for
 * processing a \ref RpPrtStdEmitter. These callbacks will be called at various point for
 * processing the emitter's custom data.
 */
enum RpPrtStdEmitterCallBackCode
{
    rpPRTSTDEMITTERCALLBACKEMIT                 = 0, /**< Emitter particle emission callback */
    rpPRTSTDEMITTERCALLBACKBEGINUPDATE,              /**< Emitter begin update call back */
    rpPRTSTDEMITTERCALLBACKENDUPDATE,                /**< Emitter end update callback */
    rpPRTSTDEMITTERCALLBACKBEGINRENDER,              /**< Emitter begin render callback */
    rpPRTSTDEMITTERCALLBACKENDRENDER,                /**< Emitter end render callback */
    rpPRTSTDEMITTERCALLBACKCREATE,                   /**< Emitter create callback */
    rpPRTSTDEMITTERCALLBACKDESTROY,                  /**< Emitter destroy callback */
    rpPRTSTDEMITTERCALLBACKSTREAMREAD,               /**< Emitter stream input callback */
    rpPRTSTDEMITTERCALLBACKSTREAMWRITE,              /**< Emitter stream output callback */
    rpPRTSTDEMITTERCALLBACKSTREAMGETSIZE,            /**< Emitter stream get size callback */
    rpPRTSTDEMITTERCALLBACKCLONE,                    /**< Emitter clone  callback */
    rpPRTSTDEMITTERCALLBACKFORCEENUMSIZEINT     = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdEmitterCallBackCode RpPrtStdEmitterCallBackCode;

typedef RwInt32 RpPrtStdPropertyCode;

/************************************************************************
 *
 *
 *
 ************************************************************************/

typedef struct RpPrtStdEmitter RWALIGN(RpPrtStdEmitter, rwMATRIXALIGNMENT);

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdEmitterCallBack
 * \ref RpPrtStdEmitterCallBack represents the function called for processing
 * a \ref RpPrtStdEmitter. There can several types of the functions, each performing a
 * specific task defined by \ref RpPrtStdEmitterCallBackCode.
 *
 * \param atomic        A pointer to the emitter's parent atomic.
 * \param emt           A pointer to the emitter.
 * \param data          A pointer to user data.
 *
 * \return A pointer to the emitter on success. NULL otherwise.
 */
typedef RpPrtStdEmitter *
        (*RpPrtStdEmitterCallBack)
            (RpAtomic *atomic, RpPrtStdEmitter *emt, void *data);

typedef struct RpPrtStdParticleBatch RWALIGN(RpPrtStdParticleBatch, rwMATRIXALIGNMENT);
/**
 * \ingroup rpprtstd
 * \ref RpPrtStdParticleCallBack represents the function called for processing
 * a \ref RpPrtStdParticleBatch. There can be several types of the functions, each
 * performing a specific task defined by \ref RpPrtStdParticleCallBackCode.
 *
 * \param emt           A pointer to the particle batch's parent emitter.
 * \param prtBatch      A pointer to the particle batch.
 * \param data          A pointer to user data.
 *
 * \return A pointer to the particle batch on success. NULL otherwise.
 */
typedef RpPrtStdParticleBatch *
        (*RpPrtStdParticleCallBack)
            (RpPrtStdEmitter *emt, RpPrtStdParticleBatch *prtBatch, void *data);

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdEmitterCallBackArray represents a set of callback functions for
 * processing a \ref RpPrtStdEmitter. All the functions are of the type \ref
 * RpPrtStdEmitterCallBack.
 *
 * \see RpPrtStdEmitterCallBackCode
 */
typedef RpPrtStdEmitterCallBack
        RpPrtStdEmitterCallBackArray[rpPRTSTDEMITTERCALLBACKMAX];

/**
 * \ingroup rpprtstd
 * \ref RpPrtStdParticleCallBackArray represents a set of callback functions for
 * processing a \ref RpPrtStdParticleBatch. All the functions are of the type \ref
 * RpPrtStdParticleCallBack.
 *
 * \see RpPrtStdParticleCallBackCode
 */
typedef RpPrtStdParticleCallBack
        RpPrtStdParticleCallBackArray[rpPRTSTDPARTICLECALLBACKMAX];


/************************************************************************
 *
 *
 *
 ************************************************************************/

typedef struct RpPrtStdEmitterClass RpPrtStdEmitterClass;
/**
 * \ingroup rpprtstd
 * \ref RpPrtStdEClassSetupCallBack represents the function called for setting up an
 * emitter class's set of callback function. The callback function is called
 * after an emitter class is streamed in.
 *
 * \param eClass        A pointer to an emitter class.
 *
 * \return A pointer to the emitter class on success. NULL otherwise.
 */
typedef RpPrtStdEmitterClass *
        (*RpPrtStdEClassSetupCallBack)
            (RpPrtStdEmitterClass *eClass);

typedef struct RpPrtStdParticleClass RpPrtStdParticleClass;
/**
 * \ingroup rpprtstd
 * \ref RpPrtStdPClassSetupCallBack represents the function called for setting up an
 * emitter class's set of callback function. The callback function is called
 * after an emitter class is streamed in.
 *
 * \param pClass        A pointer to a particle class.
 *
 * \return A pointer to the particle class on success. NULL otherwise.
 */
typedef RpPrtStdParticleClass *
        (*RpPrtStdPClassSetupCallBack)
            (RpPrtStdParticleClass *pClass);

/************************************************************************
 *
 *
 *
 ************************************************************************/

typedef struct RpPrtStdPropertyTable RpPrtStdPropertyTable;
/**
 * \ingroup rpprtstd
 * \struct RpPrtStdPropertyTable
 * A structure representing properties's data present in an emitter or
 * particle.
 * An emitter, or particle, are treated as a single block of memory. The
 * property table is used to describe the data presents in the memory block.
 * It stores the property's id, offset entry from the start of the memory
 * block and size in bytes.
 */
struct RpPrtStdPropertyTable
{
    RwUInt32                        *propPtr;       /**< Internal usage */
    RpPrtStdPropertyTable           *next;          /**< Internal usage */

    RwInt32                         id;             /**< Property table's id */
    RwInt32                         refCount;       /**< Reference count. Internal usage */

    RwInt32                         numProp;        /**< Number of properties in the table */
    RwInt32                         maxProp;        /**< Internal usage */
    RwInt32                         *propID;        /**< Array of properties's id */
    RwInt32                         *propOffset;    /**< Array of properties's offset */
    RwInt32                         *propSize;      /**< Array of properties's size */
    RwInt32                         *propSizeUA;    /**< Internal usage */
};

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterClass
 * A structure representing the collection of data and callbacks for an emitter. An emitter
 * class is used to create emitters that share the same properties and callback functions.
 * Once created, an emitter class cannot be altered. An emitter class should also not be
 * destroyed if emitters of the class are still in use.
 */
struct RpPrtStdEmitterClass
{
    RpPrtStdEmitterClass                    *next;          /**< Internal usage */

    RwInt32                                 id;             /**< Emitter class's id */
    RwInt32                                 refCount;       /**< Reference count. Internal usage */

    RwInt32                                 objSize;        /**< Size of the emitter */
    RpPrtStdPropertyTable                   *propTab;       /**< Reference to a table of emitter properties */

    RwInt32                                 numCallback;    /**< Number of callback arrays */
    RpPrtStdEmitterCallBackArray            *callback;      /**< Array of emitter callback functions */
};

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleClass
 * A structure representing the collection of data and callbacks for a particle. A particle
 * class is used to create particle that share the same properties and callback functions.
 * Once created, a particle class cannot be altered. A particle class should also not be
 * destroyed if particles of the class are still in use.
 */
struct RpPrtStdParticleClass
{
    RpPrtStdParticleClass                   *next;          /**< Internal usage */

    RwInt32                                 id;             /**< Particle class's id */
    RwInt32                                 refCount;       /**< Reference count. Internal usage */

    RwInt32                                 objSize;        /**< Size of a particle */
    RpPrtStdPropertyTable                   *propTab;       /**< Reference to a table of particle properties */

    RwInt32                                 numCallback;    /**< Number of callback sets */
    RpPrtStdParticleCallBackArray           *callback;      /**< Array of particle batch callback functions */
};


/************************************************************************
 *
 *
 *
 ************************************************************************/

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleBatch
 * A structure repsenting a group of particles. For efficient, particles are stored
 * in batches rather than individually. All live particles are stored at the head
 * of batch with no gaps of dead particles. A counter is used to record the number of
 * live particles in the batch. Once a batch has 0 live particles, it will removed
 * from the emitter's active particle list to the inactive list.
 * The first particle of the batch is given by an offset from the start of the
 * particle batch.
 */
struct RpPrtStdParticleBatch
{
    RpPrtStdParticleBatch       *next;                      /**< Pointer to the next particle batch */

    RpPrtStdParticleClass       *prtClass;                  /**< Pointer to the particle's class */

    RwInt32                     numPrt;                     /**< Number of particles in the batch */
    RwInt32                     maxPrt;                     /**< Maxium number of particles in batch */
    RwInt32                     newPrt;                     /**< Start of newly emitted particles in the batch */

    RwInt32                     offset;                     /**< Offset to the first particle, from the start of the
                                                             * particle batch */
};

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitter
 * A structure repsenting the mandatory data set for any emitter. Each emitter contains information of
 * itself and its particles, via the emitter class and particle class respectively. It also contains the
 * list of particles, in batches, it had emitted.
 * Optional data are stored immediately after the mandatory set. The contents of the optional data are
 * described in the emitter class's property table. The offset from the property table are from the start
 * of the emitter.
 *
 * The type of particles emitted are given by the particle class. Each emitter may have only emitter class
 * and particle class and these should not be changed during the lifetime of the emitter and its particles.
 * The emitter maintains two lists of particle batches, an acitive list, contain still active particles,
 * and an inactive list. The maximum number of particles in each batch is given by the prtBatchMaxPrt field.
 */
struct RpPrtStdEmitter
{
    RpPrtStdEmitter             *next;                      /**< Pointer to the next emitter */

    RwUInt32                    flag;                       /**< Emitter's property flag */

    RpAtomic                    *atomic;                    /**< Pointer to emitter's parent atomic */

    RpPrtStdEmitterClass        *emtClass;                  /**< Pointer the emitter's class */

    RwInt32                     prtActive;                  /**< Number of particles emitted */
    RwInt32                     prtBatchMaxPrt;             /**< Maximum number of particles per batch */
    RpPrtStdParticleClass       *prtClass;                  /**< Pointer to the particle's class */

    RpPrtStdParticleBatch       *inactiveBatch,             /**< Circular linked list of inactive particle batches */
                                *activeBatch;               /**< Circular linked list of active particle batches */

    RwReal                      boundingSphere;             /**< Emitter's bounding sphere. */
};



/************************************************************************
 *
 *
 *
 ************************************************************************/

#define rpPRTSTDPROPERTYCODEEMITTER                                 0
#define rpPRTSTDPROPERTYCODEEMITTERSTANDARD                         1
#define rpPRTSTDPROPERTYCODEEMITTERPRTCOLOR                         2
#define rpPRTSTDPROPERTYCODEEMITTERPRTTEXCOORDS                     3
#define rpPRTSTDPROPERTYCODEEMITTERPRTSIZE                          5
#define rpPRTSTDPROPERTYCODEEMITTERPTANK                            6
#define rpPRTSTDPROPERTYCODEEMITTERPRTVELOCITY                      7
#define rpPRTSTDPROPERTYCODEEMITTERPRTMATRIX                        8

#define rpPRTSTDEMITTERPROPERTYCOUNT                                9

#define rpPRTSTDEMITTERDATAFLAGSTANDARD                     0x00000001
#define rpPRTSTDEMITTERDATAFLAGPRTCOLOR                     0x00000002
#define rpPRTSTDEMITTERDATAFLAGPRTTEXCOORDS                 0x00000004
#define rpPRTSTDEMITTERDATAFLAGPRTSIZE                      0x00000010
#define rpPRTSTDEMITTERDATAFLAGPTANK                        0x00000020
#define rpPRTSTDEMITTERDATAFLAGPRTMATRIX                    0x00000040


typedef struct RpPrtStdEmitterStandard RpPrtStdEmitterStandard;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterStandard
 * A structure represent the set of properties for a basic emitter. The structure is stored as
 * a single optional data in the emitter property table.
 *
 * The basic emitter uses a 'time' variable to control particle emissions. A large time gap between
 * emission can give pulse effects where as a small time gap produces a streaming effects. Particles
 * can be emitted from a single point, line, area or a volume.
 *
 * Particles emitted from an emitter are of the same type. An emitter cannot emit different types of
 * particles. Once an emitter has reached its maximum number of particles, no further particles are
 * emitted until some of the existing particles have died.
 *
 * Most properties have a bias value to vary the property's value. This uses the seed field
 * to give a degreee of randomness.
 */
struct RpPrtStdEmitterStandard
{
    RwInt32                     seed;                           /**< Seed for random number generator */

    RwInt32                     maxPrt;                         /**< Maximum number of active particles */

    RwReal                      currTime,                       /**< Current timestamp for emitter */
                                prevTime;                       /**< Previous timestamp for emitter */
    RwV3d                       force;                          /**< External force applied to particles */

    RwV3d                       emtPos,                         /**< Emitter position */
                                emtSize;                        /**< Emitter size. This is the volume where new particles
                                                                 * are emitted */
    RwReal                      emtEmitGap,                     /**< Time gap between emission */
                                emtEmitGapBias,                 /**< Time gap bias */
                                emtPrevEmitTime,                /**< Previous particle emission time */
                                emtEmitTime;                    /**< Next particle emission time */
    RwInt32                     emtPrtEmit,                     /**< Number of particle emit per emission */
                                emtPrtEmitBias;                 /**< Particle emission bias */

    RwReal                      prtInitVel,                     /**< Particle's initial speed */
                                prtInitVelBias;                 /**< Particle's initial speed bias */
    RwReal                      prtLife,                        /**< Particle's duration */
                                prtLifeBias;                    /**< Particle's duration bias */

    RwV3d                       prtInitDir,                     /**< Particle's initial direction */
                                prtInitDirBias;                 /**< particle's initial direction bias */

    RwV2d                       prtSize;                        /**< Particle's size */

    RwRGBA                      prtColor;                       /**< Particle's color */

    RwTexCoords                 prtUV[4];                       /**< Particle's texture coordindates */
    RwTexture                   *texture;                       /**< Particle's texture */

    RwMatrix                    *ltm;                           /**< LTM to transform particle coordinates from local space
                                                                 * to world space */
};

typedef struct RpPrtStdEmitterPrtColor RpPrtStdEmitterPrtColor;
/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterPrtColor
 * An optional structure to represent the change in color of a particle from birth to death.
 * The particles will start with the prtStartCol and ends with endPrtColor. The particle's
 * life is used to interpolate the colors.
 *
 * If this structure is not present, then the particles will have a constant color.
 */
struct RpPrtStdEmitterPrtColor
{
    RwRGBAReal                  prtStartCol,                    /**< Particle start color */
                                prtStartColBias;                /**< Particle start color bias */
    RwRGBAReal                  prtEndCol,                      /**< Particle end color */
                                prtEndColBias;                  /**< Particle end color bias */
};

typedef struct RpPrtStdEmitterPrtTexCoords RpPrtStdEmitterPrtTexCoords;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterPrtTexCoords
 * An optional structure to represent the change in texcoords of a particle from birth to death.
 * The particles will start with prtStartUV0 and prtStartUV1 and ends with endPrtEndUV0 and endPrtEndUV1.
 * The particle's life is used to interpolate the texcoords.
 *
 * A particle can have two texcoords representing the top left and bottom right respectively. By varying
 * the texcoords can give an animated texture effect on a particle.
 *
 * If this structure is not present, then the particles will have a constant texcoords.
 */
struct RpPrtStdEmitterPrtTexCoords
{
    RwTexCoords                 prtStartUV0,                        /**< Particle start top left texcoords */
                                prtStartUV0Bias;                    /**< Particle start top left texcoords bias */
    RwTexCoords                 prtEndUV0,                          /**< Particle end top left texcoords */
                                prtEndUV0Bias;                      /**< Particle end top left texcoords bias */
    RwTexCoords                 prtStartUV1,                        /**< Particle start bottom right texcoords */
                                prtStartUV1Bias;                    /**< Particle start botton right texcoords bias */
    RwTexCoords                 prtEndUV1,                          /**< Particle end bottom right texcoords */
                                prtEndUV1Bias;                      /**< Particle end bottom right texcoords bias */
};

typedef struct RpPrtStdEmitterPrtSize RpPrtStdEmitterPrtSize;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterPrtSize
 * An optional structure to represent the change in size of a particle from birth to death.
 * The particles will start with prtStartSize and ends with prtEndSize. The particle's life
 * is used to interpolate the size.
 *
 * If this structure is not present, then the particles will have a constant size.
 */
struct RpPrtStdEmitterPrtSize
{
    RwV2d                       prtStartSize,                       /**< Particle start size */
                                prtStartSizeBias;                   /**< Particle start size bias */
    RwV2d                       prtEndSize,                         /**< Particle end size */
                                prtEndSizeBias;                     /**< Particle end size bias */
};


/**
 * \ingroup rpprtstd
 * A set of flag settings for use in the \ref RpPrtStdEmitterPrtMatrix flag
 */
enum RpPrtStdEmitterPrtMatrixFlags
{
    rpPRTSTDEMITTERPRTMTXFLAGSCNSMTX = 0x00000001,                  /**< Apply the prtCnsMtx matrix to
                                                                     * each particle if set */
    RPPRTSTDEMITTERPRTMTXFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdEmitterPrtMatrixFlags RpPrtStdEmitterPrtMatrixFlags;

typedef struct RpPrtStdEmitterPrtMatrix RWALIGN(RpPrtStdEmitterPrtMatrix, rwMATRIXALIGNMENT);

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterPrtMatrix
 *
 * An optional structure to construct a matrix for each particle during emissions. A particle
 * can be represented as a single matrix. This gives the particles an orientation rather than
 * just a simple position.
 *
 * This allows transformation to be applied to the particles, such as rotation. If
 * \ref rpPRTSTDEMITTERPRTMTXFLAGSCNSMTX is set in the flag, then the prtCnsMatrix is applied to each
 * particle during particle update.
 *
 * If this structure is not present, then it assumes the  particles will have just a position
 * property.
 */
struct RpPrtStdEmitterPrtMatrix
{
    RwMatrix                    prtCnsMtx;       /**< Transformation matrix to be applied to each particle */

    RwV3d                       prtPosMtxAt,     /**< Particle initial look at vector */
                                prtPosMtxAtBias; /**< Particle initial look at vector bias */
    RwV3d                       prtPosMtxUp,     /**< Particle initial up vector. */
                                prtPosMtxUpBias; /**< Particle initial up vector bias */

    RwInt32                     flags;           /**< Particle matrix flag. See \ref RpPrtStdEmitterPrtMatrixFlags */
};

/************************************************************************
 *
 *
 *
 ************************************************************************/



enum RpPrtStdPTankPropertyCode
{
    rpPRTSTDPTANKPROPPARTICLESMAX                   = 0,
    rpPRTSTDPTANKPROPDATAFLAGS,
    rpPRTSTDPTANKPROPPLATFORMFLAGS,
    rpPRTSTDPTANKPROPPTANK,
    rpPRTSTDPTANKPROPFORCEENUMSIZEINT               = RWFORCEENUMSIZEINT
};

typedef enum RpPrtStdPTankPropertyCode RpPrtStdPTankPropertyCode;

typedef struct RpPrtStdEmitterPTank RpPrtStdEmitterPTank;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdEmitterPTank
 *
 * A structure for storing the data required to create a RpPTank for use
 * with the emitter. The structure allows the user to create a RpPTank
 * manually.
 */
struct RpPrtStdEmitterPTank
{
    RwUInt32                    dataFlags,      /**< Data flag used in RpPTank creation. See
                                                 * \ref RpPTankAtomicCreate  */
                                platFlags,      /**< Platform flag used in RpPTank creation. See
                                                 * \ref RpPTankAtomicCreate */
                                numPrt,         /**< An integer representing the current number of active
                                                 * particles */
                                maxPrt,         /**< An integer representing the maxiumum number of particles
                                                 * stored in the RpPTank */
                                updateFlags,    /**< A flag representing the properties to be updated by
                                                 * the particle emiiter during update. A user may select to
                                                 * update some properties manually by unsetting the relevant
                                                 * bits in the flag.
                                                 * The flag settings are the same as \ref RpPTankDataFlags */
                                emitFlags;      /**< A flag representing the properties to be initialised
                                                 * by the particle emitter during particles emission. A user
                                                 * may select to initialise some properties manually by
                                                 * unsetting the relevant bits in the flag.
                                                 * The flag settings are the same as \ref RpPTankDataFlags */
    RpAtomic                    *pTank;         /**< Pointer to the RpPTank */
    RwChar                      **dataInPtrs,   /**< Internal usage */
                                **dataOutPtrs;  /**< Internal usage */
    RwInt32                     *dataStride;    /**< Internal usage */
    RwUInt32                    strSrcBlend;    /**< Internal usage */
    RwUInt32                    strDstBlend;    /**< Internal usage */
    RwBool                      strVtxABlend;   /**< Internal usage */
};

/************************************************************************
 *
 *
 *
 ************************************************************************/

#define rpPRTSTDPROPERTYCODEPARTICLESTANDARD                0
#define rpPRTSTDPROPERTYCODEPARTICLEPOSITION                1
#define rpPRTSTDPROPERTYCODEPARTICLECOLOR                   2
#define rpPRTSTDPROPERTYCODEPARTICLETEXCOORDS               3
#define rpPRTSTDPROPERTYCODEPARTICLESIZE                    5
#define rpPRTSTDPROPERTYCODEPARTICLEVELOCITY                6
#define rpPRTSTDPROPERTYCODEPARTICLEMATRIX                  7

#define rpPRTSTDPARTICLEPROPERTYCOUNT                       8

#define rpPRTSTDPARTICLEDATAFLAGSTANDARD                    0x00000001
#define rpPRTSTDPARTICLEDATAFLAGPOSITION                    0x00000002
#define rpPRTSTDPARTICLEDATAFLAGCOLOR                       0x00000004
#define rpPRTSTDPARTICLEDATAFLAGTEXCOORDS                   0x00000008
#define rpPRTSTDPARTICLEDATAFLAGSIZE                        0x00000020
#define rpPRTSTDPARTICLEDATAFLAGVELOCITY                    0x00000040
#define rpPRTSTDPARTICLEDATAFLAGMATRIX                      0x00000080


/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleStandard
 * A structure represent the set of properties for a basic particle. This structure is mandatory
 * for all particles.
 * The structure contain the life duration of the particle. The particle will be removed when the current
 * time is greater than the end time. The particle timer always starts at zero.
 *
 * The inverted end time is for interpolating optional particle properties.
 */
typedef struct RpPrtStdParticleStandard RpPrtStdParticleStandard;
struct RpPrtStdParticleStandard
{
    RwInt32                     flag;                               /**< Particle's property flag */
    RwReal                      currTime,                           /**< Particle's curr time  */
                                endTime,                            /**< Particle's end time */
                                invEndTime;                         /**< Particle's inv end for interpolation */
};


typedef struct RpPrtStdParticleColor RpPrtStdParticleColor;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleColor
 * A structure representing the change in a particle's color during its life time. The structure is optional
 * and should not be used if particles have a constant color.
 */
struct RpPrtStdParticleColor
{
    RwRGBAReal                  startCol,                           /**< Particle's end size bias */
                                deltaCol;                           /**< Particle's color rate of change */
};

typedef struct RpPrtStdParticleTexCoords RpPrtStdParticleTexCoords;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleTexCoords
 * A structure representing the change in a particle's texcoords during its life time. The structure is optional
 * and should not be used if particles have a constant texcoords.
 */
struct RpPrtStdParticleTexCoords
{
    RwTexCoords                 startUV0,                           /**< Particle's starting top left texcoords */
                                startUV1;                           /**< Particle's starting bottom right texcoords */
    RwTexCoords                 deltaUV0,                           /**< Particle's top left texcoords rate of change */
                                deltaUV1;                           /**< Particle's bottom right texcoords rate of change */
};

typedef struct RpPrtStdParticleSize RpPrtStdParticleSize;

/**
 * \ingroup rpprtstd
 * \struct RpPrtStdParticleSize
 * A structure representing the change in a particle's size during its life time. The structure is optional
 * and should not be used if particles have a constant size.
 */
struct RpPrtStdParticleSize
{
    RwV2d                       startSize,                          /**< Particle's starting size */
                                deltaSize;                          /**< Particle's size rate of change */
    RwV2d                       currSize,                           /**< Particle's current size. Internal use only */
                                invCurrSize;                        /**< Particle's inverse current size. Internal use only */
};

/************************************************************************
 *
 *
 *
 ************************************************************************/

#ifdef    __cplusplus
extern "C"
{
#endif         /* __cplusplus */

/************************************************************************/

extern RwBool
RpPrtStdPluginAttach( void );

/************************************************************************/

extern RwBool
RpAtomicIsParticleEmitter(RpAtomic *atomic);

extern RpAtomic *
RpPrtStdAtomicCreate(RpPrtStdEmitterClass *eClass, void *data);

extern RpAtomic *
RpPrtStdAtomicUpdate(RpAtomic *atomic, void *data);

extern RpAtomic *
RpPrtStdAtomicSetEmitter(RpAtomic *atomic, RpPrtStdEmitter *emt);

extern RpPrtStdEmitter *
RpPrtStdAtomicGetEmitter(RpAtomic *atomic);

extern RpAtomic *
RpPrtStdAtomicForAllEmitter(RpAtomic *atomic,
                            RpPrtStdEmitterCallBack callback,
                            void *data);

extern RpAtomic *
RpPrtStdAtomicAddEmitter(RpAtomic *,
                         RpPrtStdEmitter *emt);


/************************************************************************/


extern RpPrtStdEmitter *
RpPrtStdEmitterCreate(RpPrtStdEmitterClass *eClass);

extern RwBool
RpPrtStdEmitterDestroy(RpPrtStdEmitter *emt);

extern RpPrtStdEmitter *
RpPrtStdEmitterClone(RpPrtStdEmitter *emt);

extern RpPrtStdEmitter *
RpPrtStdEmitterForAllParticleBatch(RpPrtStdEmitter *emt,
                                    RpPrtStdParticleCallBack callback,
                                    void * data);


extern RpPrtStdEmitter *
RpPrtStdEmitterAddEmitter(RpPrtStdEmitter *emtHead,
                          RpPrtStdEmitter *emt);

extern RpPrtStdEmitter *
RpPrtStdEmitterLinkPTank(RpPrtStdEmitter *emt,RpAtomic *ptank);


extern RpPrtStdEmitter *
RpPrtStdEmitterDestroyParticleBatch(RpPrtStdEmitter *emt);

extern RpPrtStdParticleBatch *
RpPrtStdEmitterNewParticleBatch(RpPrtStdEmitter *emt);

extern RpPrtStdEmitter *
RpPrtStdEmitterAddParticleBatch(RpPrtStdEmitter *emt,
                                RpPrtStdParticleBatch *prtBatch);


extern RpPrtStdEmitter *
RpPrtStdEmitterSetPClass(RpPrtStdEmitter *emt,
                                 RpPrtStdParticleClass *pClass,
                                 RwInt32 maxPrt);

extern RpPrtStdEmitter *
RpPrtStdEmitterGetPClass(RpPrtStdEmitter *emt,
                                 RpPrtStdParticleClass **pClass,
                                 RwInt32 *maxPrt);


/************************************************************************/

extern RpPrtStdParticleBatch *
RpPrtStdParticleBatchCreate(RpPrtStdParticleClass *pClass, RwInt32 maxPrt);

extern RwBool
RpPrtStdParticleBatchDestroy(RpPrtStdParticleBatch *prtBatch);

extern RpPrtStdParticleBatch *
RpPrtStdParticleBatchAddBatch(RpPrtStdParticleBatch *prtBatchHead,
                              RpPrtStdParticleBatch *prtBatch);

/************************************************************************/

extern RpPrtStdPropertyTable *
RpPrtStdPropTabCreate(RwInt32 numProp,
                            RwInt32 *propID, RwInt32 *propStride);

extern RwBool
RpPrtStdPropTabDestroy(RpPrtStdPropertyTable *propTab);


extern RpPrtStdPropertyTable *
RpPrtStdPropTabGetProperties(RpPrtStdPropertyTable *propTab,
                             RwInt32 *numProp,
                             RwInt32 **propID,
                             RwInt32 **propOffset,
                             RwInt32 **propSize);

extern RwInt32
RpPrtStdPropTabGetPropOffset(RpPrtStdPropertyTable *propTab,
                             RwInt32 propID);

extern RwInt32
RpPrtStdPropTabGetPropIndex(RpPrtStdPropertyTable *propTab,
                            RwInt32 propID);


extern RpPrtStdPropertyTable *
RpPrtStdPropTabGet(RwInt32 id);

extern RpPrtStdPropertyTable *
RpPrtStdPropTabStreamRead(RwStream *stream);

extern RpPrtStdPropertyTable *
RpPrtStdPropTabStreamWrite(RpPrtStdPropertyTable *eClass,
                           RwStream *stream);

extern RwInt32
RpPrtStdPropTabStreamGetSize(RpPrtStdPropertyTable *eClass);
/************************************************************************/

extern RwBool
RpPrtStdEClassDestroy(RpPrtStdEmitterClass *eClass);

extern RpPrtStdEmitterClass *
RpPrtStdEClassCreate( void );

extern RpPrtStdEmitterClass *
RpPrtStdEClassSetCallBack(RpPrtStdEmitterClass *eClass,
                                RwInt32 numCallback,
                                RpPrtStdEmitterCallBackArray *emtCB);

extern RpPrtStdEmitterClass *
RpPrtStdEClassGetCallBack(RpPrtStdEmitterClass *eClass,
                           RwInt32 *numCallback,
                           RpPrtStdEmitterCallBackArray **emtCB);

extern RpPrtStdEmitterClass *
RpPrtStdEClassSetPropTab(RpPrtStdEmitterClass *eClass,
                         RpPrtStdPropertyTable *propTab);

extern RpPrtStdEmitterClass *
RpPrtStdEClassGetPropTab(RpPrtStdEmitterClass *eClass,
                         RpPrtStdPropertyTable **propTab);


extern RpPrtStdEmitterClass *
RpPrtStdEClassGet(RwInt32 id);

extern RpPrtStdEmitterClass *
RpPrtStdEClassStreamRead(RwStream *stream);

extern RpPrtStdEmitterClass *
RpPrtStdEClassStreamWrite(RpPrtStdEmitterClass *eClass,
                                 RwStream *stream);

extern RwInt32
RpPrtStdEClassStreamGetSize(RpPrtStdEmitterClass *eClass);

/************************************************************************/

extern RpPrtStdParticleClass *
RpPrtStdPClassCreate( void );

extern RwBool
RpPrtStdPClassDestroy(RpPrtStdParticleClass *pClass);

extern RpPrtStdParticleClass *
RpPrtStdPClassSetCallBack(RpPrtStdParticleClass *pClass,
                                 RwInt32 numCallback,
                                 RpPrtStdParticleCallBackArray *prtCB);

extern RpPrtStdParticleClass *
RpPrtStdPClassGetCallBack(RpPrtStdParticleClass *pClass,
                                 RwInt32 *numCallback,
                                 RpPrtStdParticleCallBackArray **prtCB);

extern RpPrtStdParticleClass *
RpPrtStdPClassSetPropTab(RpPrtStdParticleClass *pClass,
                                      RpPrtStdPropertyTable *propTab);

extern RpPrtStdParticleClass *
RpPrtStdPClassGetPropTab(RpPrtStdParticleClass *pClass,
                                      RpPrtStdPropertyTable **propTab);

extern RpPrtStdParticleClass *
RpPrtStdPClassGet(RwInt32 id);

extern RpPrtStdParticleClass *
RpPrtStdPClassStreamRead(RwStream *stream);

extern RpPrtStdParticleClass *
RpPrtStdPClassStreamWrite(RpPrtStdParticleClass *pClass,
                                 RwStream *stream);

extern RwInt32
RpPrtStdPClassStreamGetSize(RpPrtStdParticleClass *pClass);

/************************************************************************/

extern RwBool
RpPrtStdSetEClassSetupCallBack(RpPrtStdEClassSetupCallBack emtCB);

extern RwBool
RpPrtStdGetEClassSetupCallBack(RpPrtStdEClassSetupCallBack *emtCB);

extern RwBool
RpPrtStdSetPClassSetupCallBack(RpPrtStdPClassSetupCallBack prtCB);

extern RwBool
RpPrtStdGetPClassSetupCallBack(RpPrtStdPClassSetupCallBack *prtCB);

/************************************************************************/


extern RwStream *
RpPrtStdGlobalDataStreamRead(RwStream *stream);

extern RwStream *
RpPrtStdGlobalDataStreamWrite(RwStream *stream);

extern RwInt32
RpPrtStdGlobalDataStreamGetSize( void );

extern void
RpPrtStdGlobalDataSetStreamEmbedded( RwBool embedded );

extern RwBool
RpPrtStdGlobalDataGetStreamEmbedded( void );

/************************************************************************/

extern RpPrtStdEmitter *
RpPrtStdEmitterDefaultCB(RpAtomic * atomic,
                         RpPrtStdEmitter *prtEmt, void * data);


extern RpPrtStdParticleBatch *
RpPrtStdParticleDefaultCB(RpPrtStdEmitter * prtEmt,
                          RpPrtStdParticleBatch *prtBatch, void * data);

/************************************************************************/

extern RpPrtStdParticleBatch *
RpPrtStdParticleStdUpdateCB(RpPrtStdEmitter *emt,
                                 RpPrtStdParticleBatch *prtBatch, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdEmitCB(RpAtomic *atomic,
                              RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdCloneCB(RpAtomic *atomic,
                                RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdCreateCB(RpAtomic *atomic,
                                RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdDestroyCB(RpAtomic *atomic,
                                RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdBeginUpdateCB(RpAtomic *atomic,
                                     RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdEndUpdateCB(RpAtomic *atomic,
                                   RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdRenderCB(RpAtomic *atomic,
                                RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdStreamReadCB(RpAtomic *atomic,
                                    RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdStreamWriteCB(RpAtomic *atomic,
                                     RpPrtStdEmitter *emt, void *data);

extern RpPrtStdEmitter *
RpPrtStdEmitterStdStreamGetSizeCB(RpAtomic *atomic,
                                       RpPrtStdEmitter *emt, void *data);



extern RpPrtStdEmitterClass *
RpPrtStdEClassStdCreate( RwInt32 dataFlag );

extern RwInt32
RpPrtStdEClassStdCreateID( RwInt32 dataFlag );

extern RpPrtStdParticleClass *
RpPrtStdPClassStdCreate( RwInt32 dataFlag );

extern RwInt32
RpPrtStdPClassStdCreateID( RwInt32 dataFlag );

extern RpPrtStdEmitterClass *
RpPrtStdEClassStdSetupCB(RpPrtStdEmitterClass *eClass);

extern RpPrtStdParticleClass *
RpPrtStdPClassStdSetupCB(RpPrtStdParticleClass *pClass);


#ifdef    __cplusplus
}
#endif         /* __cplusplus */

/*---- end: ./prtstd.h----*/

/*---- start: c:/daily/rwsdk/plugin/prtstd/d3d8/prtstdplatform.h----*/
/*---- end: c:/daily/rwsdk/plugin/prtstd/d3d8/prtstdplatform.h----*/

#endif /* RPPRTSTD_H */