summaryrefslogtreecommitdiffstats
path: root/sdk/rwsdk/include/d3d8/rtimport.h
blob: 2cc6383b717c81287535bc15457cca506e004f93 (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
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
/***************************************************************************
 *                                                                         *
 * Module  : rtimport.h                                                    *
 *                                                                         *
 * Purpose : World handling functions.                                     *
 *                                                                         *
 **************************************************************************/

#ifndef RTIMPORT_H
#define RTIMPORT_H

/**
 * \defgroup rtworldimport RtWorldImport
 * \ingroup basicgeometry
 *
 * World Import Toolkit for RenderWare.
 */

/**
 * \defgroup selectors RtWorldImportPartitionSelectors
 * \ingroup rtworldimport
 *
 * The set of provided RtWorldImportPartitionSelectors:
 * Selects a good partition by calling one of the
 * \ref iterators and then
 * one of the \ref evaluators to
 * see which is best.
 */

/**
 * \defgroup iterators RtWorldImportPartitionIterators
 * \ingroup rtworldimport
 *
 * The set of provided RtWorldImportPartitionIterators:
 * Iterates through a set of candidate partitions, possibly
 * using the geometric information in the build sector, or perhaps
 * using some other criteria.
 */

/**
 * \defgroup evaluators RtWorldImportPartitionEvaluators
 * \ingroup rtworldimport
 *
 * The set of provided RtWorldImportPartitionEvaluators:
 * Uses a combination of statistics, build sector, build status, and 
 * possibly other criteria to evaluate a partition. While the value
 * returned can be any real value, all provided evaluators are return
 * lower values for better partitioners, and are in the range [0..1]
 * where appropriate
 */

/**
 * \defgroup terminators RtWorldImportPartitionTerminators
 * \ingroup rtworldimport
 *
 * The set of provided RtWorldImportPartitionTerminators:
 * Checks given criteria about the statistics, build sector, build status, and
 * possibly other criteria to see whether the building process should be
 * allowed to terminate, or whether more parititoning is necessary.
 */

/**
 * \defgroup kd RtWorldImportGuideKD
 * \ingroup rtworldimport
 *
 * Tools to manipulate the \ref RtWorldImportGuideKDTree that is used to
 * manually build the sectors of a world.
 */

/**
 * \defgroup hints RtWorldImportHints
 * \ingroup rtworldimport
 *
 * Tools to aid the build process by giving hints as to what geometry should
 * not be split, and what geometry makes for a good partitioning guide.
 */

/****************************************************************************
 Includes
 */
#include "rwcore.h"
#include "rpworld.h"

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

/****************************************************************************
 Defines
 */

/* Progress callback message types */
#define rtWORLDIMPORTPROGRESSBSPBUILDSTART      0
#define rtWORLDIMPORTPROGRESSBSPBUILDUPDATE     1
#define rtWORLDIMPORTPROGRESSBSPBUILDEND        2
#define rtWORLDIMPORTPROGRESSBSPCOMPRESSSTART   3
#define rtWORLDIMPORTPROGRESSBSPCOMPRESSUPDATE  4
#define rtWORLDIMPORTPROGRESSBSPCOMPRESSEND     5

/**
 * \ingroup rtworldimport
 * \def rtWORLDIMPORTINVALIDPARTITION
 *
 * This value means that no partition was found, or that the partition was
 * invalid or impractical. The value represents infinity. 
 */
#define rtWORLDIMPORTINVALIDPARTITION  RwRealMAXVAL

/*  maintained in Bin-tree  */
#define CONGRUENTVERTEXCHILDREN 2

/*  maintained in Quad-tree  */
#define WELDVERTEXCHILDREN 4

/****************************************************************************
 Global types
 */
#if (!defined(DOXYGEN))
typedef struct RtWorldImportVertex RtWorldImportVertex;

typedef struct RtWorldImportWeldVertex RtWorldImportWeldVertex;

typedef struct RtWorldImportBuildVertex RtWorldImportBuildVertex;

/* Internal use only */
typedef union RtWorldImportVertexState RtWorldImportVertexState;

/* Internal use only */
union RtWorldImportVertexState
{
    /* clipFlags, two types, first is based on partition only, 2nd is
     * also based on partition, but takes overlaps into consideration. i.e.
     * number splits is usually higher in clipFlags[0] than [1] */
    RwInt32                    clipFlags[2];       /* Internal use only */
    RwInt32                    forwardingAddress;  /* Internal use only */
    RtWorldImportVertex       *vpVert;             /* Internal use only */
    RtWorldImportWeldVertex   *vpWeldVert;         /* Internal use only */
    RtWorldImportBuildVertex  *vpBuildVert;        /* Internal use only */
    RwSList                   *slist;              /* Internal use only */
};
#endif /* (!defined(DOXYGEN)) */

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportVertex
 * Holds data for each vertex in the import world.
 *
 */
struct RtWorldImportVertex
{
    RwV3d           OC;         /**< World space vertex position */
    RwV3d           normal;     /**< World space vertex normal */
    RwRGBA          preLitCol;  /**< Vertex Prelight color */
    RwTexCoords     texCoords[rwMAXTEXTURECOORDS];  
                                /**< Vertex texture coordinates */
    RtWorldImportVertexState state;  /**< Internal use only */
    RwInt32         matIndex;   /**< Vertex material index */
    void           *pUserdata;  /**< Pointer to unspecified per vertex user data */
};

typedef struct RtWorldImportBuildPolyInfo RtWorldImportBuildPolyInfo;
/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildPolyInfo
 *
 * Information about a polygon
 */
struct RtWorldImportBuildPolyInfo
{
    RwInt16 matIndex;
    /**< The material index */
    RwUInt8 clipFlags;
    /**< Clipping flags */
    RwUInt8 hasAlpha;
    /**< Alpha status */
    void   *pUserdata;
    /**< Userdata */
};

typedef union RtWorldImportBuildVertexMode RtWorldImportBuildVertexMode;
/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildVertexMode
 *
 * Mode of the vertex.
 *
 */
union RtWorldImportBuildVertexMode
{
    RtWorldImportVertex     *vpVert;
    /**< The vertex */
    RwInt32                     index;
    /**< The index */
};

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildVertex
 *
 * A list of polygons as a list of vertices where the end of poly boundary
 * is marked by mode.vpVert == NULL.
 *
 */
struct RtWorldImportBuildVertex
{
    RtWorldImportBuildVertexMode mode;
    /**< The mode of the element */

    RtWorldImportBuildPolyInfo pinfo;
    /**< we store some poly info in the end marker of a boundary */
};

/* NB Merged RtWorldImportPartition with RtWorldImportBuildClipStatistics because
 * there was a unique one-to-one relationship between them, and it made things easier
 * just updating one stucture, without having to update both in sequence...
 */


typedef struct RtWorldImportBuildClipStatistics RtWorldImportBuildClipStatistics;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildClipStatistics
 *
 * Holds statistics about a partition or candidate partition during
 * the build process.
 */
struct RtWorldImportBuildClipStatistics
{
    RwInt32 numPotentialSplit;
    /**< The number of polygons split by the partition,
     *   disregarding overlaps */

    RwInt32 numPotentialLeft;
    /**< The number of potential polygons and fragments on the
     *   left of the partition, disregarding overlaps */

    RwInt32 numPotentialRight;
    /**< The number of potential polygons and fragments on the
     *   right of the partition, disregarding overlaps */


    RwInt32 numActualSplit;
    /**< The number of polygons split by the partition */

    RwInt32 numActualLeft;
    /**< The number of polygons and fragments on the
     *   left of the partition */

    RwInt32 numActualRight;
    /**< The number of polygons and fragments on the
     *   right of the partition */


    RwInt32 numMaterialLeft;
    /**< The number of materials on the left of the partition */

    RwInt32 numMaterialRight;
    /**< The number of materials on the right of the partition */

    RwInt32 numMaterialSplits;
    /**< The number of materials split by the partition */

    
    RwInt32 numMaterialSector;
    /**< The total number of materials in the sector containing
     *   the partition */


    RwReal overlapLeft;
    /**< The actual, relative size of the overlap on the left of the partition */

    RwReal overlapRight;
    /**< The actual, relative size of the overlap on the right of the partition */
};

/*
 * typedef for struct RtWorldImportPartition
 */
typedef struct RtWorldImportPartition RtWorldImportPartition;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportPartition
 *
 * A partitioning plane.
 */
struct RtWorldImportPartition
{
    RwInt32 type;
    /**< Plane type, i.e. 0,4,8 for being normal to the x,y,z axes respectively. */

    RwReal  value;
    /**< The distance of the plane from the origin */

    RwReal  maxLeftValue;
    /**< The maximum value of the left face of the overlap. This is derived
     *   from the maxOverlapPercent value in \ref RtWorldImportParameters
     */

    RwReal  maxRightValue;
    /**< The maximum value of the right face of the overlap. This is derived
     *   from the maxOverlapPercent value in \ref RtWorldImportParameters
     */

    RtWorldImportBuildClipStatistics buildStats;
    /**< The statistics for the partition */
};

/*
 * typedef for struct \ref RtWorldImportGuideKDTree
 */
typedef struct RtWorldImportGuideKDTree RtWorldImportGuideKDTree;


/**
 * \ingroup rtworldimport
 * \struct RtWorldImportGuideKDTree
 * Represents the structure of a binary tree with
 * no contents per se. It is used to build a BSP in a user specified
 * manner instead of using any heuristic.
 *
 */
struct RtWorldImportGuideKDTree
{
    RtWorldImportPartition partition;
    /**< A partitioning plane */

    RwBBox      bbox;
    /**< Bounding box of the sector or super-sector */

    RtWorldImportGuideKDTree  *parent;
    /**< Pointer to its parent */

    RwInt32     order;
    /**< Relationship information - 0 for left child, 1 for right child */

    RtWorldImportGuideKDTree  *left;
    /**< Left child */

    RtWorldImportGuideKDTree  *right;
    /**< Right child */
};

typedef struct _rtWorldImportGuideKDStackElement _rtWorldImportGuideKDStackElement;

#if (!defined(DOXYGEN))
struct _rtWorldImportGuideKDStackElement
{
    RwBool terminal;
    RtWorldImportGuideKDTree *node;
    _rtWorldImportGuideKDStackElement *next;
};

typedef struct _rtWorldImportGuideKDStack _rtWorldImportGuideKDStack;

struct _rtWorldImportGuideKDStack
{
    _rtWorldImportGuideKDStackElement *top;
    _rtWorldImportGuideKDStackElement *current;
    _rtWorldImportGuideKDStackElement *bottom;
};
#endif /* (!defined(DOXYGEN)) */

/*
 * typedef for struct RtWorldImportBuildSector
 */
typedef struct RtWorldImportBuildSector RtWorldImportBuildSector;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildSector
 *
 * Holds information about the sector that is being subdivided
 */
struct RtWorldImportBuildSector
{
    RwInt32 type;                   
    /**< Sector type (so can handle in an RpWorld) */

    RtWorldImportVertex *vertices;
    /**< A pointer to the list of vertices */

    RwInt32 numVertices;
    /**< The number of vertices */

    RtWorldImportBuildVertex *boundaries;
    /**< A list of boundaries \see RtWorldImportBuildVertex */
        
    RwInt32 numBoundaries;
    /**< The number of boundaries */

    RwInt32 numPolygons;
    /**< The number of polygons (triangles) */

    RwBBox boundingBox;
    /**< Sector's bounding box */

    RwReal overlap;
    /**< The percentage that the sector overlaps with its neighbour */

    RwUInt32 maxNumMaterials;
    /**< Maximum number of materials in the in the world */
};

/*
 * typedef for struct RtWorldImportBuildStatus
 */
typedef struct RtWorldImportBuildStatus RtWorldImportBuildStatus;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildStatus
 * World Import Build Status Structure
 * Used to store the current tree's build status
 */
struct RtWorldImportBuildStatus
{
    RwInt32 depth; /**< current depth in the tree */
};

typedef struct RwRGBAUInt32 RwRGBAUInt32;

#if (!defined(DOXYGEN))
struct RwRGBAUInt32
{
    RwUInt32            red, green, blue, alpha;
};

typedef struct RtWorldImportCongruentVertex RtWorldImportCongruentVertex;

struct RtWorldImportCongruentVertex
{
    RwInt32             destIdx;
    RtWorldImportVertex vertex;
    RtWorldImportVertex Mean;
    RwRGBAUInt32        preLitMean;
    RwInt32             refCount;
    RtWorldImportCongruentVertex *child[CONGRUENTVERTEXCHILDREN];
};

struct RtWorldImportWeldVertex
{
    RtWorldImportVertex *sourcePtr;
    RtWorldImportCongruentVertex *CongruentVertex;
    RtWorldImportWeldVertex *child[WELDVERTEXCHILDREN];
};
#endif /* (!defined(DOXYGEN)) */

/*
 * Holds data for each triangle in the import world.
 */
typedef struct RtWorldImportTriangle RtWorldImportTriangle;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportTriangle
 * Holds data for each triangle in the import world.
 *
 * \see RtWorldImportTriangle
 */
struct RtWorldImportTriangle
{
    RwInt32             matIndex;       /**< Index into material list */
    RwInt32             vertIndex[3];   /**< Indices into vertex list */
    void               *pUserdata;      /**< Pointer to unspecified per triangle user data */
};




/*
 * typedef for struct RtWorldImportBBoxHintDesc
 */
typedef struct RtWorldImportBBoxHintDesc RtWorldImportBBoxHintDesc;
/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBBoxHintDesc
 * Bounding box hints and (priority) values used to control the world
 * sectorization process.
 */
struct RtWorldImportBBoxHintDesc
{
    RwBBox bBox;        /**< The (necessarily orthogonal) bounding box */
    RwReal value;       /**< The value or priority of the hint (highest is most important) */
};

/*
 * typedef for struct RtWorldImportHints
 */
typedef struct RtWorldImportHints RtWorldImportHints;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportHints
 * Bounding box hints used to control the world sectorization process.
 * \see RtWorldImportHintsSet
 */
struct RtWorldImportHints
{    
    RtWorldImportBBoxHintDesc *boundingBoxes;      /**< The bounding box hints */
    RwInt32 numBoundingBoxes;   /**< The number of bounding box hints */
};


/**
 * \ingroup rtworldimport
 * \ref RtWorldImportHintGroup
 *
 * An enumeration that can be passed to
 * \ref RtWorldImportHintsSetGroup and \ref RtWorldImportHintsGetGroup to determine
 * whether hints will contribute towards the shield hint group or partition hint group
 */
typedef enum 
{
    rtWORLDIMPORTSHIELDHINT = 0,
    rtWORLDIMPORTPARTITIONHINT,

    rtWORLDIMPORTFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
}
RtWorldImportHintGroup;




/*
 * typedef for struct \ref RtWorldImportParameters
 */
typedef struct RtWorldImportParameters RtWorldImportParameters;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportParameters
 * Parameters used with \ref RtWorldImportCreateWorld.
 * They are initialized to default values using \ref RtWorldImportParametersInit.
 * 
 */
struct RtWorldImportParameters
{
    RwReal              worldSectorMaxSize;
    /**< The maximum world sector size. */
    RwInt32             maxWorldSectorPolygons;
    /**< The maximum number of polygons in a world sector. */
    RwReal              maxOverlapPercent;
    /**< Total fraction of world sector overlap allowed. */
    RwReal              weldThreshold;
    /**< Threshold for welding vertices. */
    RwReal              angularThreshold;
    /**< Angular threshold for welding vertex normals */
    RwBool              calcNormals;
    /**< If TRUE then importer creates normals. */
    RwBool              conditionGeometry;
    /**< If TRUE perform vertex welding and degenerate triangle removal.*/
    RwBool              userSpecifiedBBox;
    /**< If TRUE allows user to specify minimum bounding-box for the
     *   world using the userBBox parameter. */
    RwBBox              userBBox;
    /**< User specified world bounding-box if userSpecifiedBBox is TRUE.*/
    RwReal              uvLimit;
    /**< If conditionGeometry is TRUE limit texture coordinates to this
     *  value. */
    RwBool              retainCreases;
    /**< If TRUE then duplicate vertices with differing normals will not
     *  be merged. */
    RwBool              fixTJunctions;
    /**< If TRUE then T-junctions are fixed in the geometry (slow). */
    RwBool              weldPolygons;
    /**< If TRUE then polygons are welded where possible to reduce the
     *  polygon count. */
    RwInt32             flags;
    /**< Conversion flags (see RpWorldFlag). */
    RwTextureAddressMode mode;
    /**< If \ref rwTEXTUREADDRESSWRAP than weld vertices according to
     *   mod(1) congruent texture coordinates */
    RwBool              sortPolygons;
    /**< If TRUE then polygons are sorted by their centroid */
    RwBool              cullZeroAreaPolygons;    
    /**< If TRUE then zero-area polygons are culled  */
    RwInt32             numTexCoordSets;
    /**< The number of texture coordinate sets to use. If set to zero, then
     *   the number is taken from the flags parameter which, for backward
     *   compatibility, can include the \ref rpWORLDTEXTURED or \ref rpWORLDTEXTURED2
     *   flags. These specify one or two sets respectively. */
    RwBool              terminatorCheck;
    /**< If TRUE the world will be checked for validity during the build process. */
};

/*
 * typedef for struct RtWorldImport
 */
typedef struct RtWorldImport RtWorldImport;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImport
 * World Import State Structure
 */
struct RtWorldImport
{
    RpMaterialList      matList;     /**< Material list */
    RtWorldImportVertex *vertices;   /**< Vertex array */
    RwInt32             numVertices; /**< Vertex count */

    RtWorldImportTriangle *polygons; /**< Triangle array */
    RwInt32             numPolygons; /**< Triangle count */
};

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportProgressCallBack is the type for the callback function supplied to
 * \ref RtWorldImportSetProgressCallBack.
 *
 * \param  msg   Message type corresponding to one of the following:
 *      \li rtWORLDIMPORTPROGRESSBSPBUILDSTART -
 *          The BSP creation process is about to start.
 *          The argument value is equal to 0.0.
 *      \li rtWORLDIMPORTPROGRESSBSPBUILDUPDATE -
 *          The BSP creation process has finished processing a subsection of
 *          the world. The argument value is equal to the percentage of the
 *          world processed up to this point.
 *      \li rtWORLDIMPORTPROGRESSBSPBUILDEND -
 *          The BSP creation process has ended.
 *          The argument value is equal to 100.0.
 *      \li rtWORLDIMPORTPROGRESSBSPCOMPRESSSTART -
 *          The BSP compression process is about to start. The argument value
 *          is equal to 0.0.
 *      \li rtWORLDIMPORTPROGRESSBSPCOMPRESSUPDATE -
 *          The BSP compression has finished processing a subsection of the
 *          world. The argument value is equal to the percentage of the world
 *          processed up to this point.
 *      \li rtWORLDIMPORTPROGRESSBSPCOMPRESSEND -
 *          The BSP compression process has ended. The argument value is equal
 *          to 100.0.
 *
 * \param  value   The percentage of the progress made in either BSP
 *          building or BSP compression.
 *
 * \return TRUE to continue BSP processing, FALSE to abort.
 *
 * \see RtWorldImportSetProgressCallBack
 */
typedef RwBool (*RtWorldImportProgressCallBack)(RwInt32 msg, RwReal value);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportDestroyVertexUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * vertex destruction.
 *
 * \param pUserdata
 *
 * \return 
 */
typedef RwBool (*RtWorldImportDestroyVertexUserdataCallBack)(void **pUserdata);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportCloneVertexUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * vertex cloning.
 *
 * \param pUserdataDst
 * \param pUserdataSrc
 *
 * \return
 */
typedef RwBool (*RtWorldImportCloneVertexUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportInterpVertexUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * vertex interpolation.
 *
 * \param pUserdataDst
 * \param pUserdata1
 * \param pUserdata2
 * \param delta
 *
 * \return
 */
typedef RwBool (*RtWorldImportInterpVertexUserdataCallBack)(void **pUserdataDst, void **pUserdata1, void **pUserdata2, RwReal delta);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportDestroyPolygonUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * polygon destruction.
 *
 * \param pUserdata
 *
 * \return
 */
typedef RwBool (*RtWorldImportDestroyPolygonUserdataCallBack)(void **pUserdata);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportSplitPolygonUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * polygon division.
 *
 * \param pUserdataDst
 * \param pUserdataSrc
 *
 * \return
 */
typedef RwBool (*RtWorldImportSplitPolygonUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportSectorSetVertexUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * the setting of the vertex user data.
 *
 * \param pUserdata
 * \param sector
 * \param index
 *
 * \return
 */
typedef RwBool (*RtWorldImportSectorSetVertexUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportSectorSetPolygonUserdataCallBack
 *
 * A pointer to the CallBack function that will be called during
 * the setting of the polygon user data.
 *
 * \param pUserdata
 * \param sector
 * \param index
 *
 * \return
 */
typedef RwBool (*RtWorldImportSectorSetPolygonUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index);




/**
 * \ingroup rtworldimport
 * \ref RtWorldImportTerminationBuildCallBack
 *
 * A pointer to the function that will be called during the
 * build process to determine whether the current sector should
 * be subdivided further, or terminated.
 *
 * \param buildSector
 * \param buildStatus
 * \param pData
 *
 * \return
 */
typedef RwBool (*RtWorldImportTerminationBuildCallBack)
               (RtWorldImportBuildSector *buildSector,
    	 	    RtWorldImportBuildStatus *buildStatus,
                void *pData);

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportPartitionBuildCallBack
 *
 * A pointer to the function that will be called during the
 * build process to select a suitable sector partition.
 *
 * \param buildSector
 * \param buildStatus
 * \param partition
 *
 * \return
 */
typedef RwReal (*RtWorldImportPartitionBuildCallBack)
             (RtWorldImportBuildSector *buildSector,
              RtWorldImportBuildStatus *buildStatus,
              RtWorldImportPartition *partition,
              void *pData);

/*
 * typedef for struct \ref RtWorldImportBuildCallBacks
 */
typedef struct RtWorldImportBuildCallBacks RtWorldImportBuildCallBacks; /* MAYBE: rename to SectorCallBacks ?*/

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportBuildCallBacks
 * Sectorization callbacks
 */
struct RtWorldImportBuildCallBacks
{
    RtWorldImportPartitionBuildCallBack  partitionBuild;
    /**< Callback for choosing partition */
    void *partitionUserData;
    /**< Partition callback user data */
    RtWorldImportTerminationBuildCallBack terminationBuild;
    /**< Callback for termination of further partitioning */
    void *terminationUserData;
    /**< Termination callback user data */    
};

/*
 * typedef for struct \ref RtWorldImportUserdataCallBacks
 */
typedef struct RtWorldImportUserdataCallBacks RtWorldImportUserdataCallBacks;

/**
 * \ingroup rtworldimport
 * \struct RtWorldImportUserdataCallBacks
 * Bundle of callbacks
 */
struct RtWorldImportUserdataCallBacks
{
    RtWorldImportDestroyVertexUserdataCallBack destroyVertexUserdata;
        /**< Callback on vertex destruction */
    RtWorldImportCloneVertexUserdataCallBack cloneVertexUserdata;
        /**< Callback on vertex cloning */
    RtWorldImportInterpVertexUserdataCallBack interpVertexUserdata;
        /**< Callback on vertex interpolation */
    RtWorldImportDestroyPolygonUserdataCallBack destroyPolygonUserdata;
        /**< Callback on polygon destruction */
    RtWorldImportSplitPolygonUserdataCallBack splitPolygonUserdata;
        /**< Callback on polygon division */
    RtWorldImportSectorSetVertexUserdataCallBack sectorSetVertexUserdata;
        /**< Callback on setting vertex user data */
    RtWorldImportSectorSetPolygonUserdataCallBack sectorSetPolygonUserdata;
        /**< Callback on setting polygon user data */
};

/**
 * \ingroup rtworldimport
 * \ref RtWorldImportBuildPartitionSelector
 *
 * An enumeration that can be passed to
 * \ref RtWorldImportSetStandardBuildPartitionSelector to determine
 * whether partitioning will be achieved automatically, using the
 * default partition selected, or manually using the \ref RtWorldImportGuideKDTree
 */
typedef enum 
{
    rwBUILDPARTITIONSELECTOR_DEFAULT,
        /**< Sets the default automated process */
    rwBUILDPARTITIONSELECTOR_GUIDED
        /**< Sets the guided manual process */
}
RtWorldImportBuildPartitionSelector;




/* Builds overlaps from plane and conversion params */
#define BuildSectorSetOverlapsMacro(_boundingBox, _partition, _conversionParams)    \
MACRO_START                                                                         \
{                                                                                   \
    RwReal sup = GETCOORD((_boundingBox).sup, (_partition).type);                   \
    RwReal inf = GETCOORD((_boundingBox).inf, (_partition).type);                   \
                                                                                    \
    (_partition).maxLeftValue =                                                       \
        (_partition).value +                                                        \
        ((sup - (_partition).value) * (_conversionParams).maxOverlapPercent);       \
                                                                                    \
    (_partition).maxRightValue =                                                        \
        (_partition).value -                                                        \
        ((((_partition).value) - inf) * (_conversionParams).maxOverlapPercent);     \
}                                                                                   \
MACRO_STOP

/*****************************************************************************
 *  Function prototypes
 */

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

extern RwBool
_rtImportBuildSectorFindBBox(RtWorldImportBuildSector *buildSector, RwBBox *bbpOut);

extern void
    _rtWorldImportGuideKDCopy(RtWorldImportGuideKDTree *KD, RpSector *spSector, RwInt32 depth);
extern void _rtWorldImportGuideKDStackDestroy(_rtWorldImportGuideKDStack *stack);
extern void
_rtWorldImportGuideKDEncodeAsStack(RtWorldImportGuideKDTree *tree, _rtWorldImportGuideKDStack *stack);

extern RtWorldImportGuideKDTree *RtWorldImportGuideKDCreate(RwBBox *bbox);
extern RtWorldImportGuideKDTree *RtWorldImportGuideKDAddPartition
                        (RtWorldImportGuideKDTree *KD, RwInt32 type, RwReal value);
extern void RtWorldImportGuideKDDeletePartition(RtWorldImportGuideKDTree *KD);
extern void RtWorldImportGuideKDDestroy(RtWorldImportGuideKDTree *KD);

extern RtWorldImportGuideKDTree *RtWorldImportGuideKDWrite(
                        RtWorldImportGuideKDTree *guideKD, const RwChar *filename);
extern RtWorldImportGuideKDTree * RtWorldImportGuideKDRead(
                        const RwChar *filename, const RwBBox *bbox);

/*****************************************************************************
 *  PARTITION SELECTORS - These callbacks for used to select a partition
 *  from a sector.
 */

extern RwReal
RtWorldImportBalancedCullPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportMaterialCountPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportMaterialSeparatePartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);
extern RwReal
RtWorldImportPartitionHintPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * __RWUNUSED__ userData);


extern RwReal
RtWorldImportMaximumOccluderPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportDisjointOccluderPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportLeastCutAndBalancedPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportMaximumExtentPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportCullMiddleSpacePartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportCullEndSpacePartitionSelector(RtWorldImportBuildSector * buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportCullSpacePartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportHintBBoxPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportGeneralOccluderPartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportBalancedTreePartitionSelector(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

/*****************************************************************************
 *  PARTITION ITERATORS - These callbacks iterate though a set of partitions
 */

extern RwBool
RtWorldImportOrthogonalAutoPartitionIterator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData,
                                    RwInt32* loopCounter);


extern RwBool
RtWorldImportRegularIntervalPartitionIterator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData,
                                    RwInt32* loopCounter);


extern RwBool
RtWorldImportMiddleAxisPartitionIterator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData,
                                    RwInt32 * loopCounter);


extern RwBool 
RtWorldImportMedianPercentagePartitionIterator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData,
                                    RwInt32 *loopCounter);


extern RwBool
RtWorldImportHintBBoxPartitionIterator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData,
                                    RwInt32* loopCounter);

extern RwBool
RtWorldImportHighestVertexAccommodatingPlanePartitionIterator(RtWorldImportBuildSector *buildSector,
                                                              RtWorldImportBuildStatus * buildStatus,
                                                              RtWorldImportPartition *partition,
                                                              void * userData,
                                                              RwInt32* loopCounter);

extern RwBool
RtWorldImportMaterialBoundsPartitionIterator(RtWorldImportBuildSector *buildSector,
                                             RtWorldImportBuildStatus * buildStatus,
                                             RtWorldImportPartition *partition,
                                             void *userData,
                                             RwInt32 *loopCounter);

/*****************************************************************************
 *  PARTITION EVALUATORS - These callbacks iterate though a set of partitions
 */

extern RwReal
RtWorldImportFuzzyBalancedPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);


extern RwReal
RtWorldImportPotentialSplitPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);


extern RwReal
RtWorldImportBalancedPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);


extern RwReal
RtWorldImportExtentPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);


extern RwReal
RtWorldImportOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);


extern RwReal
RtWorldImportWeightedOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void * userData);

extern RwReal
RtWorldImportHintBBoxPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                    RtWorldImportBuildStatus *buildStatus,
                                    RtWorldImportPartition *partition,
                                    void *userData);

extern RwReal
RtWorldImportVolumeBalancedPartitionEvaluator(RtWorldImportBuildSector * buildSector,
                                              RtWorldImportBuildStatus * buildStatus,
                                              RtWorldImportPartition *partition,
                                              void * userData);

extern RwReal
RtWorldImportWeightedDisjointOccluderPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                                        RtWorldImportBuildStatus *buildStatus,
                                                        RtWorldImportPartition *partition,
                                                        void * userData);

extern RwReal
RtWorldImportMaterialCutsPartitionEvaluator(RtWorldImportBuildSector * buildSector,
                                            RtWorldImportBuildStatus * buildStatus,
                                            RtWorldImportPartition *partition,
                                            void * userData);

extern RwReal
RtWorldImportMaterialBalancedPartitionEvaluator(RtWorldImportBuildSector * buildSector,
                                                RtWorldImportBuildStatus *buildStatus,
                                                RtWorldImportPartition *partition,
                                                void * userData);

extern RwReal
RtWorldImportAspectPartitionEvaluator(RtWorldImportBuildSector *buildSector,
                                      RtWorldImportBuildStatus * buildStatus,
                                      RtWorldImportPartition *partition,
                                      void * userData);

extern RwReal
RtWorldImportMaterialSeparatorPartitionEvaluator(RtWorldImportBuildSector * buildSector,
                                                 RtWorldImportBuildStatus * buildStatus,
                                                 RtWorldImportPartition *partition,
                                                 void * userData);
/*****************************************************************************
 *  PARTITION TERMINATORS - These callbacks are used to decide when
 *  partitioning of a sector should stop
 */
extern RwBool
RtWorldImportNeverPartitionTerminator(RtWorldImportBuildSector * buildSector,
                    RtWorldImportBuildStatus * buildStatus,
                    void * userData);

extern RwBool
RtWorldImportMaximumLegalPartitionTerminator(RtWorldImportBuildSector * buildSector,
                    RtWorldImportBuildStatus * __RWUNUSED__ buildStatus,
                    void * __RWUNUSED__ userData);

extern RwBool
RtWorldImportDefaultPartitionTerminator(RtWorldImportBuildSector * buildSector,
                    RtWorldImportBuildStatus * buildStatus,
                    void * pData);


extern RwBool
RtWorldImportDepthPartitionTerminator(RtWorldImportBuildSector * buildSector,
                    RtWorldImportBuildStatus * buildStatus,
                    void * userData);


extern RwBool
RtWorldImportSectorHeightPartitionTerminator(RtWorldImportBuildSector * buildSector,
                    RtWorldImportBuildStatus * buildStatus,
                    void * userData);

extern RwBool
RtWorldImportSizePartitionTerminator(RtWorldImportBuildSector * buildSector,
                                     RtWorldImportBuildStatus * buildStatus,
                                     void * userData);

extern RwBool
RtWorldImportSectorAspectSizePartitionTerminator(RtWorldImportBuildSector * buildSector,
                                                 RtWorldImportBuildStatus * buildStatus,
                                                 void * userData);




/* WorldImport hints */
extern void
RtWorldImportHintsSetGroup(RtWorldImportHints *hints, RtWorldImportHintGroup group);

extern RtWorldImportHints *
RtWorldImportHintsGetGroup(RtWorldImportHintGroup group);

extern RtWorldImportHints *
RtWorldImportHintsCreate(void);

extern RwBool
RtWorldImportHintsDestroy(RtWorldImportHints *hints);

extern RtWorldImportHints *
RtWorldImportHintsAddBoundingBoxes(RtWorldImportHints *hints, RwInt32 numBoundingBoxes);

extern void
RtWorldImportMaterialGroupHintGenerator(RtWorldImportBuildSector *buildSector,
                                        RtWorldImportHints *materialGroupHints);

/* Initializing the conversion structure */
extern RtWorldImportParameters *RtWorldImportParametersInit(void);
extern void RtWorldImportParametersSet(RtWorldImportParameters *params);
extern RtWorldImportParameters *RtWorldImportParametersGet(void);


extern RpWorld *RtWorldImportCreateWorld(RtWorldImport *
                                         nohsworld,
                                         RtWorldImportParameters
                                         * conversionParams);

extern RpGeometry *RtWorldImportCreateGeometry(RtWorldImport *
                                               nohsworld,
                                               RtWorldImportParameters
                                               * conversionParams);

extern RtWorldImport *RtWorldImportCreate(void);

extern RwBool RtWorldImportDestroy(RtWorldImport * nohsworld);

extern RtWorldImport *RtWorldImportAddNumVertices(RtWorldImport *
                                                  nohsworld,
                                                  RwInt32
                                                  numNewVertices);

extern RtWorldImport *RtWorldImportAddNumTriangles(RtWorldImport *
                                                   nohsworld,
                                                   RwInt32
                                                   numNewTriangles);

extern RpMaterial *RtWorldImportGetMaterial(RtWorldImport *
                                            nohsworld,
                                            RwInt32 matInd);

extern RwInt32 RtWorldImportGetNumVertices(RtWorldImport * nohsworld);

extern RtWorldImportVertex *RtWorldImportGetVertices(RtWorldImport *
                                                     nohsworld);

extern RwInt32 RtWorldImportGetNumTriangles(RtWorldImport * nohsworld);

extern RtWorldImportTriangle *
RtWorldImportGetTriangles(RtWorldImport * nohsworld);


/* Progress callbacks */
extern void
RtWorldImportSetProgressCallBack(RtWorldImportProgressCallBack CB);

extern RpWorldSector * RtWorldImportGetNumMaterials(RpWorldSector *worldSector, void *data);

extern void
_rtImportWorldSendProgressMessage(RwInt32 msgtype, RwReal value);

/* Reading and Writing */

extern RtWorldImport *RtWorldImportWrite(RtWorldImport * world,
                                         RwChar * filename);

extern RtWorldImport *RtWorldImportRead(RwChar * filename);

extern RwInt32 RtWorldImportAddMaterial(RtWorldImport * nohsworld,
                                        RpMaterial * material);

extern RwInt32 RtWorldImportGetMaterialIndex(RtWorldImport * nohsworld,
                                             RpMaterial * material);

extern RtWorldImport *RtWorldImportForAllMaterials(RtWorldImport *
                                                   nohsworld,
                                                   RpMaterialCallBack
                                                   fpCallBack,
                                                   void *pData);

extern void
RtWorldImportSetUserdataCallBacks(RtWorldImportDestroyVertexUserdataCallBack
                                    destroyVertexUserdataCB,
                                  RtWorldImportCloneVertexUserdataCallBack
                                    cloneVertexUserdataCB,
                                  RtWorldImportInterpVertexUserdataCallBack
                                    interpVertexUserdataCB,
                                  RtWorldImportSectorSetVertexUserdataCallBack
                                    sectorSetVertexUserdata,
                                  RtWorldImportDestroyPolygonUserdataCallBack
                                    destroyPolygonUserdataCB,
                                  RtWorldImportSplitPolygonUserdataCallBack
                                    splitPolygonUserdataCB,
                                  RtWorldImportSectorSetPolygonUserdataCallBack
                                    sectorSetPolygonUserdata);

extern void
RtWorldImportSetBuildCallBacks(RtWorldImportPartitionBuildCallBack
                                partitionBuildCB,
                               RtWorldImportTerminationBuildCallBack
                                terminationBuildCB);

extern void
RtWorldImportSetPartitionStatistics(RtWorldImportBuildSector * buildSector,
                                      RtWorldImportPartition * partition);

extern void
RtWorldImportSetBuildCallBacksUserData(void *partitionUserData,
                                       void *terminateUserData);


extern void
RtWorldImportSetStandardBuildPartitionSelector(RtWorldImportBuildPartitionSelector partitionSelector, void* userData);

#ifdef    __cplusplus
}
#endif                          /* __cplusplus */


#define RtWorldImportParametersInitialize(_paramsPtr) \
    *(_paramsPtr) = *RtWorldImportParametersInit();

/* Back compatibility with former hints which only permitted type zero (shield) hints... */
#define RtWorldImportHintsSet(_hints) \
RtWorldImportHintsSetGroup(_hints, rtWORLDIMPORTSHIELDHINT);

#define RtWorldImportHintsGet() \
RtWorldImportHintsGetGroup(rtWORLDIMPORTSHIELDHINT);


#endif                          /* RTIMPORT_H */