1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-09 02:24:55 +00:00
re3/sdk/rwsdk/include/d3d8/rtimport.h

1339 lines
46 KiB
C
Raw Normal View History

2019-05-18 10:39:39 +00:00
/***************************************************************************
* *
* Module : rtimport.h *
* *
* Purpose : World handling functions. *
* *
**************************************************************************/
#ifndef RTIMPORT_H
#define RTIMPORT_H
/**
2020-07-18 10:30:51 +00:00
* \defgroup rtworldimport RtWorldImport
* \ingroup basicgeometry
2019-05-18 10:39:39 +00:00
*
2020-07-18 10:30:51 +00:00
* World Import Toolkit for RenderWare.
2019-05-18 10:39:39 +00:00
*/
/**
* \defgroup selectors RtWorldImportPartitionSelectors
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* 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
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* 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
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* 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
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* 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
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* Tools to manipulate the \ref RtWorldImportGuideKDTree that is used to
* manually build the sectors of a world.
*/
/**
* \defgroup hints RtWorldImportHints
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
*
* 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
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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
2020-07-18 10:30:51 +00:00
/* maintained in Bin-tree */
#define CONGRUENTVERTEXCHILDREN 2
2019-05-18 10:39:39 +00:00
2020-07-18 10:30:51 +00:00
/* maintained in Quad-tree */
#define WELDVERTEXCHILDREN 4
2019-05-18 10:39:39 +00:00
2020-07-18 10:30:51 +00:00
/****************************************************************************
Global types
2019-05-18 10:39:39 +00:00
*/
2020-07-18 10:30:51 +00:00
#if (!defined(DOXYGEN))
2019-05-18 10:39:39 +00:00
typedef struct RtWorldImportVertex RtWorldImportVertex;
typedef struct RtWorldImportWeldVertex RtWorldImportWeldVertex;
typedef struct RtWorldImportBuildVertex RtWorldImportBuildVertex;
2020-07-18 10:30:51 +00:00
/* Internal use only */
typedef union RtWorldImportVertexState RtWorldImportVertexState;
2019-05-18 10:39:39 +00:00
2020-07-18 10:30:51 +00:00
/* 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)) */
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \struct RtWorldImportVertex
* Holds data for each vertex in the import world.
2019-05-18 10:39:39 +00:00
*
*/
2020-07-18 10:30:51 +00:00
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 */
};
2019-05-18 10:39:39 +00:00
typedef struct RtWorldImportBuildPolyInfo RtWorldImportBuildPolyInfo;
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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;
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \struct RtWorldImportBuildVertexMode
*
* Mode of the vertex.
*
*/
union RtWorldImportBuildVertexMode
{
RtWorldImportVertex *vpVert;
/**< The vertex */
RwInt32 index;
/**< The index */
};
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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...
*/
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
typedef struct RtWorldImportBuildClipStatistics RtWorldImportBuildClipStatistics;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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,
2020-07-18 10:30:51 +00:00
* disregarding overlaps */
2019-05-18 10:39:39 +00:00
RwInt32 numPotentialLeft;
/**< The number of potential polygons and fragments on the
2020-07-18 10:30:51 +00:00
* left of the partition, disregarding overlaps */
2019-05-18 10:39:39 +00:00
RwInt32 numPotentialRight;
/**< The number of potential polygons and fragments on the
2020-07-18 10:30:51 +00:00
* right of the partition, disregarding overlaps */
2019-05-18 10:39:39 +00:00
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 */
};
2020-07-18 10:30:51 +00:00
/*
* typedef for struct RtWorldImportPartition
2019-05-18 10:39:39 +00:00
*/
typedef struct RtWorldImportPartition RtWorldImportPartition;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
2020-07-18 10:30:51 +00:00
/*
* typedef for struct \ref RtWorldImportGuideKDTree
*/
typedef struct RtWorldImportGuideKDTree RtWorldImportGuideKDTree;
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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;
2020-07-18 10:30:51 +00:00
#if (!defined(DOXYGEN))
2019-05-18 10:39:39 +00:00
struct _rtWorldImportGuideKDStackElement
{
RwBool terminal;
RtWorldImportGuideKDTree *node;
_rtWorldImportGuideKDStackElement *next;
};
typedef struct _rtWorldImportGuideKDStack _rtWorldImportGuideKDStack;
struct _rtWorldImportGuideKDStack
{
_rtWorldImportGuideKDStackElement *top;
_rtWorldImportGuideKDStackElement *current;
_rtWorldImportGuideKDStackElement *bottom;
};
2020-07-18 10:30:51 +00:00
#endif /* (!defined(DOXYGEN)) */
2019-05-18 10:39:39 +00:00
2020-07-18 10:30:51 +00:00
/*
* typedef for struct RtWorldImportBuildSector
2019-05-18 10:39:39 +00:00
*/
typedef struct RtWorldImportBuildSector RtWorldImportBuildSector;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
2020-07-18 10:30:51 +00:00
/*
* typedef for struct RtWorldImportBuildStatus
2019-05-18 10:39:39 +00:00
*/
typedef struct RtWorldImportBuildStatus RtWorldImportBuildStatus;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
2020-07-18 10:30:51 +00:00
typedef struct RwRGBAUInt32 RwRGBAUInt32;
#if (!defined(DOXYGEN))
struct RwRGBAUInt32
2019-05-18 10:39:39 +00:00
{
2020-07-18 10:30:51 +00:00
RwUInt32 red, green, blue, alpha;
2019-05-18 10:39:39 +00:00
};
2020-07-18 10:30:51 +00:00
typedef struct RtWorldImportCongruentVertex RtWorldImportCongruentVertex;
struct RtWorldImportCongruentVertex
2019-05-18 10:39:39 +00:00
{
2020-07-18 10:30:51 +00:00
RwInt32 destIdx;
RtWorldImportVertex vertex;
RtWorldImportVertex Mean;
RwRGBAUInt32 preLitMean;
RwInt32 refCount;
RtWorldImportCongruentVertex *child[CONGRUENTVERTEXCHILDREN];
2019-05-18 10:39:39 +00:00
};
2020-07-18 10:30:51 +00:00
struct RtWorldImportWeldVertex
{
RtWorldImportVertex *sourcePtr;
RtWorldImportCongruentVertex *CongruentVertex;
RtWorldImportWeldVertex *child[WELDVERTEXCHILDREN];
};
#endif /* (!defined(DOXYGEN)) */
/*
2019-05-18 10:39:39 +00:00
* Holds data for each triangle in the import world.
*/
typedef struct RtWorldImportTriangle RtWorldImportTriangle;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
2020-07-18 10:30:51 +00:00
/*
* typedef for struct RtWorldImportBBoxHintDesc
*/
typedef struct RtWorldImportBBoxHintDesc RtWorldImportBBoxHintDesc;
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \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
2019-05-18 10:39:39 +00:00
*/
typedef struct RtWorldImportHints RtWorldImportHints;
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \struct RtWorldImportHints
* Bounding box hints used to control the world sectorization process.
* \see RtWorldImportHintsSet
*/
struct RtWorldImportHints
{
2020-07-18 10:30:51 +00:00
RtWorldImportBBoxHintDesc *boundingBoxes; /**< The bounding box hints */
RwInt32 numBoundingBoxes; /**< The number of bounding box hints */
2019-05-18 10:39:39 +00:00
};
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportHintGroup
2019-05-18 10:39:39 +00:00
*
2020-07-18 10:30:51 +00:00
* 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;
/*
2019-05-18 10:39:39 +00:00
* typedef for struct \ref RtWorldImportParameters
*/
typedef struct RtWorldImportParameters RtWorldImportParameters;
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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. */
};
2020-07-18 10:30:51 +00:00
/*
* typedef for struct RtWorldImport
2019-05-18 10:39:39 +00:00
*/
typedef struct RtWorldImport RtWorldImport;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportDestroyVertexUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* vertex destruction.
2020-07-18 10:30:51 +00:00
*
* \param pUserdata
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportDestroyVertexUserdataCallBack)(void **pUserdata);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportCloneVertexUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* vertex cloning.
2020-07-18 10:30:51 +00:00
*
* \param pUserdataDst
* \param pUserdataSrc
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportCloneVertexUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportInterpVertexUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* vertex interpolation.
2020-07-18 10:30:51 +00:00
*
* \param pUserdataDst
* \param pUserdata1
* \param pUserdata2
* \param delta
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportInterpVertexUserdataCallBack)(void **pUserdataDst, void **pUserdata1, void **pUserdata2, RwReal delta);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportDestroyPolygonUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* polygon destruction.
2020-07-18 10:30:51 +00:00
*
* \param pUserdata
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportDestroyPolygonUserdataCallBack)(void **pUserdata);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportSplitPolygonUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* polygon division.
2020-07-18 10:30:51 +00:00
*
* \param pUserdataDst
* \param pUserdataSrc
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportSplitPolygonUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportSectorSetVertexUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* the setting of the vertex user data.
2020-07-18 10:30:51 +00:00
*
* \param pUserdata
* \param sector
* \param index
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportSectorSetVertexUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportSectorSetPolygonUserdataCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the CallBack function that will be called during
* the setting of the polygon user data.
2020-07-18 10:30:51 +00:00
*
* \param pUserdata
* \param sector
* \param index
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportSectorSetPolygonUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportTerminationBuildCallBack
2019-05-18 10:39:39 +00:00
*
* 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.
2020-07-18 10:30:51 +00:00
*
* \param buildSector
* \param buildStatus
* \param pData
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwBool (*RtWorldImportTerminationBuildCallBack)
(RtWorldImportBuildSector *buildSector,
RtWorldImportBuildStatus *buildStatus,
void *pData);
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportPartitionBuildCallBack
2019-05-18 10:39:39 +00:00
*
* A pointer to the function that will be called during the
* build process to select a suitable sector partition.
2020-07-18 10:30:51 +00:00
*
* \param buildSector
* \param buildStatus
* \param partition
*
* \return
2019-05-18 10:39:39 +00:00
*/
typedef RwReal (*RtWorldImportPartitionBuildCallBack)
(RtWorldImportBuildSector *buildSector,
RtWorldImportBuildStatus *buildStatus,
RtWorldImportPartition *partition,
void *pData);
2020-07-18 10:30:51 +00:00
/*
2019-05-18 10:39:39 +00:00
* typedef for struct \ref RtWorldImportBuildCallBacks
*/
typedef struct RtWorldImportBuildCallBacks RtWorldImportBuildCallBacks; /* MAYBE: rename to SectorCallBacks ?*/
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
2020-07-18 10:30:51 +00:00
/*
2019-05-18 10:39:39 +00:00
* typedef for struct \ref RtWorldImportUserdataCallBacks
*/
typedef struct RtWorldImportUserdataCallBacks RtWorldImportUserdataCallBacks;
2020-07-18 10:30:51 +00:00
2019-05-18 10:39:39 +00:00
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
2019-05-18 10:39:39 +00:00
* \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 */
};
/**
2020-07-18 10:30:51 +00:00
* \ingroup rtworldimport
* \ref RtWorldImportBuildPartitionSelector
2019-05-18 10:39:39 +00:00
*
* 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);
2020-07-18 10:30:51 +00:00
extern RwReal
RtWorldImportPartitionHintPartitionSelector(RtWorldImportBuildSector *buildSector,
RtWorldImportBuildStatus *buildStatus,
RtWorldImportPartition *partition,
void * __RWUNUSED__ userData);
2019-05-18 10:39:39 +00:00
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
2020-07-18 10:30:51 +00:00
RtWorldImportHintsSetGroup(RtWorldImportHints *hints, RtWorldImportHintGroup group);
2019-05-18 10:39:39 +00:00
extern RtWorldImportHints *
2020-07-18 10:30:51 +00:00
RtWorldImportHintsGetGroup(RtWorldImportHintGroup group);
2019-05-18 10:39:39 +00:00
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();
2020-07-18 10:30:51 +00:00
/* Back compatibility with former hints which only permitted type zero (shield) hints... */
#define RtWorldImportHintsSet(_hints) \
RtWorldImportHintsSetGroup(_hints, rtWORLDIMPORTSHIELDHINT);
#define RtWorldImportHintsGet() \
RtWorldImportHintsGetGroup(rtWORLDIMPORTSHIELDHINT);
2019-05-18 10:39:39 +00:00
#endif /* RTIMPORT_H */