summaryrefslogtreecommitdiffstats
path: root/rwsdk/include/d3d8/rpptank.h
blob: d4c1116dc0aba32579e9a18b773bacd08800a000 (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

#ifndef RPPTANK_H
#define RPPTANK_H

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

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

/*---- start: ./ptank.h----*/

/**
 * \defgroup rpptank RpPTank
 * \ingroup particles
 *
 * PTank Plugin for RenderWare.
 */

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

#include <string.h>

#include "rwcore.h"

#include "rpptank.rpe"    /* automatically generated header file */

/******************************************************************************
 *  Global Types
 */

/**
 * \ingroup rpptank
 * Passed to \ref RpPTankAtomicCreate, these flags specify
 * the type and properties held by the particles.
 * Some flags are mutually exclusive and should not be mixed.
 * The debug version of the library will assert and signal these problems.
 */
enum RpPTankDataFlags
{
    rpPTANKDFLAGNONE                     = ((int)0x00000000),
    rpPTANKDFLAGPOSITION                 = ((int)0x00000001),   /**<Uses a position per particle*/
    rpPTANKDFLAGCOLOR                    = ((int)0x00000002),   /**<Uses a color per particle*/
    rpPTANKDFLAGSIZE                     = ((int)0x00000004),   /**<Uses a size per particle*/
    rpPTANKDFLAGMATRIX                   = ((int)0x00000008),   /**<Uses a matrix per particle*/
    rpPTANKDFLAGNORMAL                   = ((int)0x00000010),   /**<Uses a normal per particle*/
    rpPTANKDFLAG2DROTATE                 = ((int)0x00000020),   /**<Uses a 2D rotation per particle*/
    rpPTANKDFLAGVTXCOLOR                 = ((int)0x00000040),   /**<Uses a color per Billboard vertex*/
    rpPTANKDFLAGVTX2TEXCOORDS            = ((int)0x00000080),   /**<Uses Top-Left and Bottom-Right Texture coordinates*/
    rpPTANKDFLAGVTX4TEXCOORDS            = ((int)0x00000100),   /**<Uses a texture UV per vertex*/
/*    free                               = ((int)0x00000200),    */
/*    free                               = ((int)0x00000400),    */
/*    free                               = ((int)0x00000800),    */
/*    free                               = ((int)0x00001000),    */
/*    free                               = ((int)0x00002000),    */
/*    free                               = ((int)0x00004000),    */
    rpPTANKDFLAGCNSMATRIX                = ((int)0x00008000),   /**<Uses a constant matrix*/
    rpPTANKDFLAGCNSNORMAL                = ((int)0x00010000),   /**<Uses a constant normal*/
    rpPTANKDFLAGCNS2DROTATE              = ((int)0x00020000),   /**<Uses a constant 2D rotation*/
    rpPTANKDFLAGCNSVTXCOLOR              = ((int)0x00040000),   /**<Uses a constant color per Billboard vertex*/
    rpPTANKDFLAGCNSVTX2TEXCOORDS         = ((int)0x00080000),   /**<Uses constant Top-Left and Bottom-Right Texture coordinates*/
    rpPTANKDFLAGCNSVTX4TEXCOORDS         = ((int)0x00100000),   /**<Uses a constant texture UV per vertex*/
/*    free                               = ((int)0x00200000),    */
/*    free                               = ((int)0x00400000),    */
/*    free                               = ((int)0x00800000),    */
    rpPTANKDFLAGUSECENTER                = ((int)0x01000000),    /**<The position of the particles are shifted*/
/*    free                               = ((int)0x04000000),    */
/*    free                               = ((int)0x08000000),    */
    rpPTANKDFLAGARRAY                    = ((int)0x10000000),    /**<Data is organized in an array */
    rpPTANKDFLAGSTRUCTURE                = ((int)0x20000000),    /**<Data is organized in a structure */

    RPPTANKDATAFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
};
typedef enum RpPTankDataFlags RpPTankDataFlags;

#define rpPTANKDFLAGTHINPARTICLES (rpPTANKDFLAGPOSITION)
#define rpPTANKDFLAGFATPARTICLES ( rpPTANKDFLAGPOSITION | rpPTANKDFLAGSIZE        \
                                 | rpPTANKDFLAG2DROTATE | rpPTANKDFLAGVTXCOLOR \
                                 | rpPTANKDFLAGVTX4TEXCOORDS)


/**
 * \ingroup rpptank
 * Passed to \ref RpPTankAtomicLock, these flags specify
 * the data accessed.
 * those flags are mutually exclusive and should not be mixed.
 */
enum RpPTankDataLockFlags
{
    rpPTANKLFLAGNONE                     = ((int)0x00000000),
    rpPTANKLFLAGPOSITION                 = ((int)0x00000001),   /**<Access the positions buffer*/
    rpPTANKLFLAGCOLOR                    = ((int)0x00000002),   /**<Access the colors buffer*/
    rpPTANKLFLAGSIZE                     = ((int)0x00000004),   /**<Access the sizes buffer*/
    rpPTANKLFLAGMATRIX                   = ((int)0x00000008),   /**<Access the matrixes buffer*/
    rpPTANKLFLAGNORMAL                   = ((int)0x00000010),   /**<Access the normals buffer*/
    rpPTANKLFLAG2DROTATE                 = ((int)0x00000020),   /**<Access the 2D rotations buffer*/
    rpPTANKLFLAGVTXCOLOR                 = ((int)0x00000040),   /**<Access the colors buffer (when using a color per vertex) */
    rpPTANKLFLAGVTX2TEXCOORDS            = ((int)0x00000080),   /**<Access the Top-Left and Bottom-Right Texture coordinates buffer*/
    rpPTANKLFLAGVTX4TEXCOORDS            = ((int)0x00000100),   /**<Access the texture UVs Buffer (when using a color per vertex)*/

    RPPTANKLOCKFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
};
typedef enum RpPTankDataLockFlags RpPTankDataLockFlags;


#if (!defined(DOXYGEN))

/**
 * \ingroup rpptank
 * RpPTankInstanceFlags
 */
enum RpPTankInstanceFlags
{
    rpPTANKIFLAGNONE             = ((int)0x00000000),
    rpPTANKIFLAGPOSITION         = ((int)0x00000001),    /**<Particles position changed*/
    rpPTANKIFLAGCOLOR            = ((int)0x00000002),   /**<Particles color changed*/
    rpPTANKIFLAGSIZE             = ((int)0x00000004),   /**<Particles size changed*/
    rpPTANKIFLAGMATRIX           = ((int)0x00000008),   /**<Particles matrix changed*/
    rpPTANKIFLAGNORMAL           = ((int)0x00000010),   /**<Particles normal changed*/
    rpPTANKIFLAG2DROTATE         = ((int)0x00000020),   /**<Particles 2D rotation changed*/
    rpPTANKIFLAGVTXCOLOR         = ((int)0x00000040),    /**<Vertex color changed*/
    rpPTANKIFLAGVTX2TEXCOORDS    = ((int)0x00000080),   /**<Vertex 2 Texture coordinates changed*/
    rpPTANKIFLAGVTX4TEXCOORDS    = ((int)0x00000100),   /**<Vertex 4 Texture coordinates changed*/
/*    free                       = ((int)0x00000200),    */
/*    free                       = ((int)0x00000400),    */
/*    free                       = ((int)0x00000800),    */
/*    free                       = ((int)0x00001000),    */
    rpPTANKIFLAGCNSCOLOR         = ((int)0x00002000),   /**<Constant color changed*/
    rpPTANKIFLAGCNSSIZE          = ((int)0x00004000),   /**<Constant size changed*/
    rpPTANKIFLAGCNSMATRIX        = ((int)0x00008000),   /**<Constant matrix changed*/
    rpPTANKIFLAGCNSNORMAL        = ((int)0x00010000),   /**<Constant normal changed*/
    rpPTANKIFLAGCNS2DROTATE      = ((int)0x00020000),   /**<Constant 2D rotation changed*/
    rpPTANKIFLAGCNSVTXCOLOR      = ((int)0x00040000),   /**<Constant vertex color changed*/
    rpPTANKIFLAGCNSVTX2TEXCOORDS = ((int)0x00080000),   /**<Constant vertex 2 Texture coordinates changed*/
    rpPTANKIFLAGCNSVTX4TEXCOORDS = ((int)0x00100000),   /**<Constant vertex 4 Texture coordinates changed*/
/*    free                       = ((int)0x00200000),    */
/*    free                       = ((int)0x00400000),    */
    rpPTANKIFLAGACTNUMCHG        = ((int)0x00800000),    /**<Number of active particle changed*/
    rpPTANKIFLAGCENTER           = ((int)0x01000000),    /**<Center position changed*/
/*    free                       = ((int)0x04000000),    */
/*    free                       = ((int)0x08000000),    */
    rpPTANKIFLAGALPHABLENDING    = ((int)0x10000000),    /**<Internal Use*/
    rpPTANKIFLAGALL              = ((int)0xFFFFFFFF),

    RPPTANKINSTANCEFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
};

typedef enum RpPTankInstanceFlags RpPTankInstanceFlags;

#endif

/**
 * \ingroup rpptank
 * Passed to \ref RpPTankAtomicLock to specify the type of access needed.
 *
 * Accessing data using \ref rpPTANKLOCKWRITE will force the PTank object to reinstance
 * the rendered data. The instantiation of this data takes place at rendering
 * time and is done once per frame.
 */
enum RpPTankLockFlags
{
    rpPTANKLOCKWRITE     = ((int)0x40000000),    /**<Lock data for writing. */
    rpPTANKLOCKREAD      = ((int)0x80000000)    /**<Lock data for reading. */
};

typedef enum RpPTankLockFlags RpPTankLockFlags;

typedef struct RpPTankLockStruct RpPTankLockStruct;

/**
 * \ingroup rpptank
 * \struct RpPTankLockStruct
 * Returned by \ref RpPTankAtomicLock
 */
struct  RpPTankLockStruct{
    RwUInt8 *data;            /**<Pointer to the locked data. */
    RwInt32 stride;            /**<Stride of the data accessed. */
};

typedef struct RpPTankFormatDescriptor RpPTankFormatDescriptor;

/**
 * \ingroup rpptank
 * \struct RpPTankFormatDescriptor
 * Returned by \ref RpPTankAtomicGetDataFormat
 */
struct RpPTankFormatDescriptor
{
    RwInt32 numClusters;    /**<Number of clusters */
    RwInt32 stride;         /**<Size of a single structure when using
                             * structure organization, 0 otherwise */
    RwInt32 dataFlags;      /**<flags passed to \ref RpPTankAtomicCreate */
};

#if (!defined(DOXYGEN))

typedef struct RpPTankData RpPTankData;

struct RpPTankData
{
    void     *data;         /*  PI data array
                             * in the A form :
                             * Point to the ptrList table
                             * in the S form :
                             * point to the structure
                             *
                             */
    RpPTankLockStruct clusters[9];

    void *userData;         /* void pointer for platform use */

    RpPTankFormatDescriptor format;

    /* constant values */
    RwUInt32    srcBlend;
    RwUInt32    dstBlend;
    RwBool      vertexAlphaBlend;

    RwV2d           cCenter;
    RwV2d           cSize;
    RwReal          cRotate;
    RwRGBA          cColor;
    RwRGBA          cVtxColor[4];
    RwTexCoords     cUV[4];
    RwMatrix cMatrix;
};




/* data piece size */
extern const RwInt32 datasize[];

#define RPPTANKSIZEPOSITION         0
#define RPPTANKSIZEMATRIX           1
#define RPPTANKSIZENORMAL           2
#define RPPTANKSIZESIZE             3
#define RPPTANKSIZECOLOR            4
#define RPPTANKSIZEVTXCOLOR         5
#define RPPTANKSIZE2DROTATE         6
#define RPPTANKSIZEVTX2TEXCOORDS    7
#define RPPTANKSIZEVTX4TEXCOORDS    8


/**
 * \ingroup rpptank
 * \ref RpPTankAllocCallBack
 *
 * ...
 */
typedef void *(* RpPTankAllocCallBack)(RpPTankData *ptankGlobal,
                                        RwInt32 maxPCount,
                                        RwUInt32 dataFlags,
                                        RwUInt32 platFlags);

/**
 * \ingroup rpptank
 * \ref RpPTankCreateCallBack
 *
 * ...
 */
typedef RwBool (* RpPTankCreateCallBack)(RpAtomic *atomic,
                                        RpPTankData *ptankGlobal,
                                        RwInt32 maxPCount,
                                        RwUInt32 dataFlags,
                                        RwUInt32 platFlags);

/**
 * \ingroup rpptank
 * \ref RpPTankInstanceCallBack
 * ...
 */
typedef RwBool (* RpPTankInstanceCallBack)(RpAtomic *atomic,
                                            RpPTankData *ptankGlobal,
                                            RwInt32 actPCount,
                                            RwUInt32 instFlags);

/**
 * \ingroup rpptank
 * \ref RpPTankRenderCallBack
 * ...
 */
typedef RwBool (* RpPTankRenderCallBack)(RpAtomic *atomic,
                                            RpPTankData *ptankGlobal,
                                            RwInt32 actPCount);

typedef struct RpPTankCallBacks RpPTankCallBacks;

struct RpPTankCallBacks
{
    RpPTankAllocCallBack        alloc;
    RpPTankCreateCallBack       create;
    RpPTankInstanceCallBack        instance;
    RpPTankRenderCallBack        render;
};

/* private typedefs */
typedef struct RpPTANKInstanceSetupData RpPTANKInstanceSetupData;

struct RpPTANKInstanceSetupData
{
    RwBool instancePositions;
    RwBool instanceUVs;
    RwBool instanceColors;
    RwBool instanceNormals;

    RpPTankLockStruct positionOut;
    RpPTankLockStruct UVOut;
    RpPTankLockStruct colorsOut;
    RpPTankLockStruct normalsOut;

    RwV3d right;
    RwV3d up;

};

typedef void (* RpPTankGENInstancePosCallback)(
    RpPTankLockStruct *dstCluster,
    RwV3d *right,
    RwV3d *up,
    RwInt32 pCount,
    RpPTankData *ptankGlobal);

typedef void (* RpPTankGENInstanceCallback)(
    RpPTankLockStruct *dstCluster,
    RwInt32 pCount,
    RpPTankData *ptankGlobal);

typedef void (* RpPTankGENInstanceSetupCallback)(
    RpPTANKInstanceSetupData *data,
    RpAtomic *atomic,
    RpPTankData *ptankGlobal,
    RwInt32 actPCount,
    RwUInt32 instFlags);

typedef void (* RpPTankGENInstanceEndingCallback)(
    RpPTANKInstanceSetupData *data,
    RpAtomic *atomic,
    RpPTankData *ptankGlobal,
    RwInt32 actPCount,
    RwUInt32 instFlags);

typedef struct RpPTankAtomicExtPrv RpPTankAtomicExtPrv;

struct RpPTankAtomicExtPrv
{
    RwInt32  maxPCount;        /* max number of particles */
    RwInt32  actPCount;       /* number of actives particles */

    RwBool   isAStructure;  /* is in a structure of array form */
    void    *rawdata;        /* unaligned pointer to the PI data */

    /* Rendering callback */
    RpAtomicCallBackRender defaultRenderCB;

    RpPTankCallBacks       ptankCallBacks;
    
    /* Instancing CallBacks */
    RpPTankGENInstanceSetupCallback     insSetupCB;
    RpPTankGENInstancePosCallback       insPosCB;
    RpPTankGENInstanceCallback          insUVCB;
    RpPTankGENInstanceCallback          insColorsCB;
    RpPTankGENInstanceCallback          insNormalsCB;
    RpPTankGENInstanceEndingCallback    insEndingCB;

    RwUInt32 lockFlags;
    RwUInt32 instFlags;
    RwUInt32 platFlags;

    RpPTankData publicData;
};

/*--- Plugin API Functions ---*/

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

/* private globals */
extern RwInt32 _rpPTankAtomicDataOffset; /* Offset in RpAtomic */

extern RwInt32 _rpPTankGlobalsOffset; /* Offset in RwEngine */

/* Macro tools */
#define RPATOMICPTANKPLUGINDATA(atomic)                \
    (*RWPLUGINOFFSET(RpPTankAtomicExtPrv *, (atomic), _rpPTankAtomicDataOffset))

#define GLOBALPTANKPLUGINDATA()                \
    (*RWPLUGINOFFSET(void *, RwEngineInstance, _rpPTankGlobalsOffset))

#endif


extern RwBool
RpPTankPluginAttach(void);


/*
 * PTank Management API ******************************************************
 */

extern RpAtomic *
RpPTankAtomicCreate(RwInt32 maxParticleNum,
                    RwUInt32 dataFlags,
                    RwUInt32 platFlags);

extern void
RpPTankAtomicDestroy(RpAtomic *ptank);

extern RwBool
RpAtomicIsPTank(RpAtomic *atomic);

extern const RpPTankFormatDescriptor *
RpPTankAtomicGetDataFormat(RpAtomic *atomic);

/*
 * Particles Management API **************************************************
 */

#define RpPTankAtomicGetActiveParticlesCountMacro(_atm)\
                     (RPATOMICPTANKPLUGINDATA(_atm)->actPCount)

#define RpPTankAtomicGetMaximumParticlesCountMacro(_atm)\
                     (RPATOMICPTANKPLUGINDATA(_atm)->maxPCount)

#define RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGACTNUMCHG;\
    RPATOMICPTANKPLUGINDATA(atm_)->actPCount = cnt_;\
}\
MACRO_STOP

#define RpPTankAtomicSetTextureMacro(atm_, tex_)\
MACRO_START\
{\
RpMaterialSetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0), tex_);\
}\
MACRO_STOP

#define RpPTankAtomicGetTextureMacro(atm_)\
    (RpMaterialGetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0)))

#define RpPTankAtomicGetMaterialMacro(atm_)\
    (RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0))

#define RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend = src_;\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend = dst_;\
}\
MACRO_STOP    

#define RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_)\
MACRO_START\
{\
    *src_ =\
    (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend);\
    *dst_ =\
    (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend);\
}\
MACRO_STOP

#define RpPTankAtomicSetVertexAlphaMacro(atm_, vas_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend = vas_;\
}\
MACRO_STOP

#define RpPTankAtomicGetVertexAlphaMacro(atm_)\
    (RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend)

#define RpPTankAtomicSetConstantCenterMacro(atm_, ctr_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter = *ctr_;\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCENTER;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantCenterMacro(atm_)\
        (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter))


#define RpPTankAtomicSetConstantSizeMacro(atm_, size_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize = *size_;\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSSIZE;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantSizeMacro(atm_)\
        (&RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize)

#define RpPTankAtomicSetConstantRotateMacro(atm_, rot_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate = rot_;\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNS2DROTATE;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantRotateMacro(atm_)\
    (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate)

#define RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_)\
MACRO_START\
{\
    RwMatrixCopy(&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix),mtx_);\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSMATRIX;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantMatrixMacro(atm_)\
        (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix))

#define RpPTankAtomicSetConstantColorMacro(atm_, col_)\
MACRO_START\
{\
    RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor = *col_;\
    if( RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0) )\
    {\
        (void)RpMaterialSetColor(\
        RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0),\
        &RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor);\
    }\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSCOLOR;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantColorMacro(atm_)\
    (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor))

#define RpPTankAtomicSetConstantVtxColorMacro(atm_, col_)\
MACRO_START\
{\
    memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor,\
            col_,\
            sizeof(RwRGBA)*4);\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTXCOLOR;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantVtxColorMacro(atm_)\
    (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor)

#define RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_)\
MACRO_START\
{\
    memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\
            uv_,\
            sizeof(RwTexCoords)*2);\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX2TEXCOORDS;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\
    (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV)

#define RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_)\
MACRO_START\
{\
    memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\
            uv_,\
            sizeof(RwTexCoords)*4);\
    RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX4TEXCOORDS;\
}\
MACRO_STOP

#define RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_)\
    (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV)

#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE))
extern RwInt32
RpPTankAtomicGetActiveParticlesCount(RpAtomic *atomic);

extern RwInt32
RpPTankAtomicGetMaximumParticlesCount(RpAtomic *atomic);

extern void
RpPTankAtomicSetActiveParticlesCount(RpAtomic *atomic, RwInt32 count);

extern void
RpPTankAtomicSetTexture(RpAtomic *atomic, RwTexture *texture);

extern RwTexture *
RpPTankAtomicGetTexture(RpAtomic *atomic);

extern RpAtomic *
RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material);

extern RpMaterial *
RpPTankAtomicGetMaterial(RpAtomic *atomic);

extern void
RpPTankAtomicSetBlendModes(RpAtomic *atomic,
                                 RwBlendFunction srcBlendMode,
                                 RwBlendFunction dstBlendMode );

extern void
RpPTankAtomicGetBlendModes(RpAtomic *atomic,
                                 RwBlendFunction *srcBlendMode,
                                 RwBlendFunction *dstBlendMode );

extern void
RpPTankAtomicSetVertexAlpha(RpAtomic *atomic, RwBool vtxAlphaState);

extern RwBool
RpPTankAtomicGetVertexAlpha(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantCenter(RpAtomic *atomic, RwV2d *center);

const RwV2d *
RpPTankAtomicGetConstantCenter(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantSize(RpAtomic *atomic, RwV2d *size);

extern const RwV2d *
RpPTankAtomicGetConstantSize(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantRotate(RpAtomic *atomic, RwReal rotate);

extern RwReal
RpPTankAtomicGetConstantRotate(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantMatrix(RpAtomic *atomic, RwMatrix *matrix);

extern const RwMatrix *
RpPTankAtomicGetConstantMatrix(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantColor(RpAtomic *atomic, RwRGBA *color);

extern const RwRGBA *
RpPTankAtomicGetConstantColor(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantVtxColor(RpAtomic *atomic, RwRGBA *color);

extern const RwRGBA *
RpPTankAtomicGetConstantVtxColor(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantVtx2TexCoords(RpAtomic *atomic, RwTexCoords *UVs);

extern const RwTexCoords *
RpPTankAtomicGetConstantVtx2TexCoords(RpAtomic *atomic);

extern void
RpPTankAtomicSetConstantVtx4TexCoords(RpAtomic *atomic, RwTexCoords *UVs);

extern const RwTexCoords *
RpPTankAtomicGetConstantVtx4TexCoords(RpAtomic *atomic);
#else

#define RpPTankAtomicGetActiveParticlesCount(atm_)\
        RpPTankAtomicGetActiveParticlesCountMacro(atm_)

#define RpPTankAtomicGetMaximumParticlesCount(atm_)\
        RpPTankAtomicGetMaximumParticlesCountMacro(atm_)

#define RpPTankAtomicSetActiveParticlesCount(atm_,cnt_)\
        RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_)


#define RpPTankAtomicSetTexture(atm_,tex_)\
        RpPTankAtomicSetTextureMacro(atm_,tex_)

#define RpPTankAtomicGetTexture(atm_)\
        RpPTankAtomicGetTextureMacro(atm_)

extern RpAtomic *
RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material);

#define RpPTankAtomicGetMaterial(atm_)\
        RpPTankAtomicGetMaterialMacro(atm_)

#define RpPTankAtomicSetBlendModes(atm_,src_,dst_)\
        RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_)

#define RpPTankAtomicGetBlendModes(atm_,src_,dst_)\
        RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_)

#define RpPTankAtomicSetVertexAlpha(atm_, vas_)\
        RpPTankAtomicSetVertexAlphaMacro(atm_, vas_)

#define RpPTankAtomicGetVertexAlpha(atm_)\
        RpPTankAtomicGetVertexAlphaMacro(atm_)

#define RpPTankAtomicSetConstantCenter(atm_, ctr_)\
        RpPTankAtomicSetConstantCenterMacro(atm_, ctr_)

#define RpPTankAtomicGetConstantCenter(atm_)\
        RpPTankAtomicGetConstantCenterMacro(atm_)

#define RpPTankAtomicSetConstantSize(atm_, size_)\
        RpPTankAtomicSetConstantSizeMacro(atm_, size_)

#define RpPTankAtomicGetConstantSize(atm_)\
        RpPTankAtomicGetConstantSizeMacro(atm_)

#define RpPTankAtomicSetConstantRotate(atm_, rot_)\
        RpPTankAtomicSetConstantRotateMacro(atm_, rot_)

#define RpPTankAtomicGetConstantRotate(atm_)\
        RpPTankAtomicGetConstantRotateMacro(atm_)

#define RpPTankAtomicSetConstantMatrix(atm_, mtx_)\
        RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_)

#define RpPTankAtomicGetConstantMatrix(atm_)\
        RpPTankAtomicGetConstantMatrixMacro(atm_)

#define RpPTankAtomicSetConstantColor(atm_, col_)\
        RpPTankAtomicSetConstantColorMacro(atm_, col_)

#define RpPTankAtomicGetConstantColor(atm_)\
        RpPTankAtomicGetConstantColorMacro(atm_)

#define RpPTankAtomicSetConstantVtxColor(atm_, _col)\
        RpPTankAtomicSetConstantVtxColorMacro(atm_, _col)

#define RpPTankAtomicGetConstantVtxColor(atm_)\
        RpPTankAtomicGetConstantVtxColorMacro(atm_)

#define RpPTankAtomicSetConstantVtx2TexCoords(atm_, uv_)\
        RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_)

#define RpPTankAtomicGetConstantVtx2TexCoords(atm_)\
        RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\

#define RpPTankAtomicSetConstantVtx4TexCoords(atm_, uv_)\
        RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_)

#define RpPTankAtomicGetConstantVtx4TexCoords(atm_)\
        RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_)

#endif

/*
 * Data access API ***********************************************************
 */

extern RwBool
RpPTankAtomicLock(RpAtomic *atomic, RpPTankLockStruct *dst,
            RwUInt32 dataFlags, RpPTankLockFlags lockFlag);

extern void *
RpPTankAtomicLockByIndex(RpAtomic *atomic, RwInt32 idx, RwUInt32 dataFlags, RpPTankLockFlags lockFlag);

extern RpAtomic *
RpPTankAtomicUnlock(RpAtomic *atomic);


/*
 * Stealth functions *********************************************************
 */
RpAtomic*
_rpPTankAtomicCreateCustom(RwInt32 maxParticleNum,
                RwUInt32 dataFlags, RwUInt32 platFlags, 
                RpPTankCallBacks *callbacks);

#ifdef    __cplusplus
}
#endif                          /* __cplusplus */

/*---- end: ./ptank.h----*/

/*---- start: c:/daily/rwsdk/plugin/ptank/d3d8/ptankplatform.h----*/

/**
 * \defgroup rpptankd3d8 D3D8
 * \ingroup rpptank
 *
 * D3D8 specific documentation.
 */

/**
 * \ingroup rpptankd3d8
 * \par D3D8 specific data flags
 *
 * <ul>
 * <li> rpPTANKD3D8FLAGSUSEPOINTSPRITES selects the D3D8 optimized pipeline. At the 
 * moment, this pipeline use point sprites when the hardware supports them,
 * which don't allow use of all the PTank flags. Only the following flags are
 * supported when using the D3D8 optimized pipes:
 *
 * <ul>
 * <li> rpPTANKDFLAGPOSITION
 * <li> rpPTANKDFLAGNORMAL
 * <li> rpPTANKDFLAGSIZE (if the hardware supports the D3DFVF_PSIZE vertex format flag)
 * <li> rpPTANKDFLAGCOLOR
 * <li> rpPTANKDFLAGUSECENTER
 * <li> rpPTANKDFLAGARRAY
 * <li> rpPTANKDFLAGSTRUCTURE
 * </ul>
 *
 * The texture coordinates are generated by the hardware and can't be specified.
 * </ul>
 *
 * If the hardware does not support point sprites, the default pipeline is used
 * instead.
 * 
 */

enum RpPTankD3D8Flags
{
    rpPTANKD3D8FLAGSUSEPOINTSPRITES = 0x00000001,

    rpPTANKD3D8FLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
};

typedef enum RpPTankD3D8Flags RpPTankD3D8Flags;

/*---- end: c:/daily/rwsdk/plugin/ptank/d3d8/ptankplatform.h----*/

#endif /* RPPTANK_H */