#ifndef RPPATCH_H #define RPPATCH_H /** * \defgroup rppatch RpPatch * \ingroup rpplugin * * Bezier patch library * * This library provides efficient evaluation of patches. */ /*===========================================================================* *--- Include files ---------------------------------------------------------* *===========================================================================*/ #include "rwcore.h" #include "rpworld.h" #include "rpcriter.h" #include "rppatch.rpe" /*===========================================================================* *--- Defines ---------------------------------------------------------------* *===========================================================================*/ /** * \ingroup rppatch * \def rpQUADPATCHNUMCONTROLPOINTS defines the number of control points in * a quadrilateral patch. * * \see RpQuadPatch * \see rpQUADPATCHNUMCONTROLINDICES * \see RpPatchMeshSetQuadPatch */ #define rpQUADPATCHNUMCONTROLPOINTS (16) /** * \ingroup rppatch * \def rpTRIPATCHNUMCONTROLPOINTS defines the number of control points in * a triangular patch. * * \see RpTriPatch * \see rpTRIPATCHNUMCONTROLINDICES * \see RpPatchMeshSetTriPatch */ #define rpTRIPATCHNUMCONTROLPOINTS (10) /** * \ingroup rppatch * \def rpQUADPATCHNUMCONTROLINDICES defines the number of control point * indices in a \ref RpQuadPatch quadrilateral patch. * * \see rpQUADPATCHNUMCONTROLPOINTS * \see RpPatchMeshSetQuadPatch */ #define rpQUADPATCHNUMCONTROLINDICES rpQUADPATCHNUMCONTROLPOINTS /** * \ingroup rppatch * \def rpTRIPATCHNUMCONTROLINDICES defines the number of control points * indices in a \ref RpTriPatch triangular patch. * * \see rpTRIPATCHNUMCONTROLPOINTS * \see RpPatchMeshSetTriPatch */ #define rpTRIPATCHNUMCONTROLINDICES rpTRIPATCHNUMCONTROLPOINTS /** * \ingroup rppatch * \def rpPATCHLODMAXVALUE defines the maximum value that can be returned for * the patch evaluation LOD. * * \see rpPATCHSKINLODMAXVALUE * \see rpPATCHLODMINVALUE * \see RpPatchLODCallBack */ #define rpPATCHLODMAXVALUE (20) /** * \ingroup rppatch * \def rpPATCHSKINLODMAXVALUE defines the maximum value that can be returned * for the skinned patch evaluation LOD. * * \see rpPATCHLODMAXVALUE * \see rpPATCHLODMINVALUE * \see RpPatchLODCallBack */ #define rpPATCHSKINLODMAXVALUE (18) /** * \ingroup rppatch * \def rpPATCHLODMINVALUE defines the minimum value that can be returned for * the patch evaluation LOD. * * \see rpPATCHSKINLODMAXVALUE * \see rpPATCHLODMAXVALUE * \see RpPatchLODCallBack */ #define rpPATCHLODMINVALUE (4) /** * \ingroup rppatch * \def rpPATCHMESHTEXCOORDSETS Multi texture coordinate format specifier * for \ref RpPatchMeshCreate(). This should be OR'd into the * \ref RpPatchMeshFlag . */ #define rpPATCHMESHTEXCOORDSETS(_num) \ ((_num & 0xff) << 16) /** * \ingroup rppatch * \def rpPATCHMESHLOCKTEXCOORDSIDX * Convenience macro for generating a texture coordinate lock flag. */ #define rpPATCHMESHLOCKTEXCOORDSIDX(_idx) \ (rpPATCHMESHLOCKTEXCOORDS1 << (_idx)) /*===========================================================================* *--- Global Types ----------------------------------------------------------* *===========================================================================*/ /** * \ingroup rppatch * \ref RpPatchMeshFlag * When creating a \ref RpPatchMesh, these flags can be OR'ed together to * specify the format along with the \ref rpPATCHMESHTEXCOORDSETS (n) macro * to specify the number of texture coordinate sets required. * * \see RpPatchMeshCreate */ enum RpPatchMeshFlag { rpNAPATCHMESHFLAG = 0, rpPATCHMESHPOSITIONS = 0x01, /**definition.flag) #define RpPatchMeshSetFlagsMacro(patchMesh, flags) \ (patchMesh->definition.flag = flags) #define RpPatchMeshGetNumControlPointsMacro(patchMesh) \ (patchMesh->definition.numControlPoints) #define RpPatchMeshGetNumTriPatchesMacro(patchMesh) \ (patchMesh->definition.numTriPatches) #define RpPatchMeshGetNumQuadPatchesMacro(patchMesh) \ (patchMesh->definition.numQuadPatches) #define RpPatchMeshGetNumTexCoordSetsMacro(patchMesh) \ (patchMesh->definition.numTexCoordSets) #define RpPatchMeshGetPositionsMacro(patchMesh) \ (patchMesh->positions) #define RpPatchMeshGetNormalsMacro(patchMesh) \ (patchMesh->normals) #define RpPatchMeshGetPreLightColorsMacro(patchMesh) \ (patchMesh->preLightColors) #define RpPatchMeshGetTexCoordsMacro(patchMesh, index) \ (patchMesh->texCoords[index - 1]) /*---------------------------------------------------------------------------*/ #if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) /*---------------------------------------------------------------------------*/ extern RwUInt32 RpPatchMeshGetFlags( const RpPatchMesh *patchMesh ); extern RpPatchMesh * RpPatchMeshSetFlags( RpPatchMesh *patchMesh, RwUInt32 flags ); extern RwUInt32 RpPatchMeshGetNumControlPoints( const RpPatchMesh *patchMesh ); extern RwUInt32 RpPatchMeshGetNumTriPatches( const RpPatchMesh *patchMesh ); extern RwUInt32 RpPatchMeshGetNumQuadPatches( const RpPatchMesh *patchMesh ); extern RwUInt32 RpPatchMeshGetNumTexCoordSets( const RpPatchMesh *patchMesh ); extern RwV3d * RpPatchMeshGetPositions( const RpPatchMesh *patchMesh ); extern RwV3d * RpPatchMeshGetNormals( const RpPatchMesh *patchMesh ); extern RwRGBA * RpPatchMeshGetPreLightColors( const RpPatchMesh *patchMesh ); extern RwTexCoords * RpPatchMeshGetTexCoords( const RpPatchMesh *patchMesh, RwTextureCoordinateIndex index ); /*---------------------------------------------------------------------------*/ #else /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ /*---------------------------------------------------------------------------*/ #define RpPatchMeshGetFlags(patchMesh) \ RpPatchMeshGetFlagsMacro(patchMesh) #define RpPatchMeshSetFlags(patchMesh, flags) \ RpPatchMeshSetFlagsMacro(patchMesh, flags) #define RpPatchMeshGetNumControlPoints(patchMesh) \ RpPatchMeshGetNumControlPointsMacro(patchMesh) #define RpPatchMeshGetNumTriPatches(patchMesh) \ RpPatchMeshGetNumTriPatchesMacro(patchMesh) #define RpPatchMeshGetNumQuadPatches(patchMesh) \ RpPatchMeshGetNumQuadPatchesMacro(patchMesh) #define RpPatchMeshGetNumTexCoordSets(patchMesh) \ RpPatchMeshGetNumTexCoordSetsMacro(patchMesh) #define RpPatchMeshGetPositions(patchMesh) \ RpPatchMeshGetPositionsMacro(patchMesh) #define RpPatchMeshGetNormals(patchMesh) \ RpPatchMeshGetNormalsMacro(patchMesh) #define RpPatchMeshGetPreLightColors(patchMesh) \ RpPatchMeshGetPreLightColorsMacro(patchMesh) #define RpPatchMeshGetTexCoords(patchMesh, index) \ RpPatchMeshGetTexCoordsMacro(patchMesh, index) /*---------------------------------------------------------------------------*/ #endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ /*---------------------------------------------------------------------------* *- Patch streaming functions -* *---------------------------------------------------------------------------*/ extern RwUInt32 RpPatchMeshStreamGetSize( const RpPatchMesh *patchMesh ); extern RpPatchMesh * RpPatchMeshStreamRead( RwStream *stream ); extern const RpPatchMesh * RpPatchMeshStreamWrite( const RpPatchMesh *patchMesh, RwStream *stream ); /*---------------------------------------------------------------------------* *- Patch Mesh patch functions -* *---------------------------------------------------------------------------*/ extern RpPatchMesh * RpPatchMeshSetQuadPatch( RpPatchMesh *patchMesh, RwUInt32 quadIndex, RpQuadPatch *quadPatch ); extern RpPatchMesh * RpPatchMeshSetTriPatch( RpPatchMesh *patchMesh, RwUInt32 triIndex, RpTriPatch *triPatch ); extern const RpQuadPatch * RpPatchMeshGetQuadPatch( const RpPatchMesh *patchMesh, RwUInt32 quadIndex ); extern const RpTriPatch * RpPatchMeshGetTriPatch( const RpPatchMesh *patchMesh, RwUInt32 triIndex ); /*---------------------------------------------------------------------------* *- Patch Mesh material functions -* *---------------------------------------------------------------------------*/ extern RpPatchMesh * RpPatchMeshSetQuadPatchMaterial( RpPatchMesh *patchMesh, RwUInt32 quadIndex, RpMaterial *material ); extern RpPatchMesh * RpPatchMeshSetTriPatchMaterial( RpPatchMesh *patchMesh, RwUInt32 triIndex, RpMaterial *material ); extern RpMaterial * RpPatchMeshGetQuadPatchMaterial( const RpPatchMesh *patchMesh, RwUInt32 quadIndex ); extern RpMaterial * RpPatchMeshGetTriPatchMaterial( const RpPatchMesh *patchMesh, RwUInt32 triIndex ); extern const RpPatchMesh * RpPatchMeshForAllMaterials( const RpPatchMesh *patchMesh, RpMaterialCallBack callBack, void *userData ); extern RwUInt32 RpPatchMeshGetNumMaterials( const RpPatchMesh *patchMesh ); extern RpMaterial * RpPatchMeshGetMaterial( const RpPatchMesh *patchMesh, RwUInt32 materialIndex ); /*---------------------------------------------------------------------------* *- Patch Skin functions -* *---------------------------------------------------------------------------*/ #if (defined(RPSKIN_H)) extern RpSkin * RpPatchMeshGetSkin( RpPatchMesh *patchMesh ); extern RpPatchMesh * RpPatchMeshSetSkin( RpPatchMesh *patchMesh, RpSkin *skin ); #endif /* (defined(RPSKIN_H)) */ /*---------------------------------------------------------------------------* *- Patch Atomic functions -* *---------------------------------------------------------------------------*/ extern RpAtomic * RpPatchAtomicSetPatchMesh( RpAtomic *atomic, RpPatchMesh *patchMesh ); extern RpPatchMesh * RpPatchAtomicGetPatchMesh( const RpAtomic *atomic ); /*---------------------------------------------------------------------------* *- Patch Atomic LOD functions -* *---------------------------------------------------------------------------*/ extern RwBool RpPatchAtomicSetPatchLODCallBack( RpAtomic *atomic, RpPatchLODCallBack callback, RpPatchLODUserData userData ); extern RwBool RpPatchAtomicGetPatchLODCallBack( const RpAtomic *atomic, RpPatchLODCallBack *callback, RpPatchLODUserData *userData ); /*---------------------------------------------------------------------------* *- Patch default LOD range -* *---------------------------------------------------------------------------*/ extern RwBool RpPatchSetDefaultLODCallBackRange( RpPatchLODRange *lodRange ); extern RwBool RpPatchGetDefaultLODCallBackRange( RpPatchLODRange *lodRange ); /*---------------------------------------------------------------------------* *- Patch pipeline -* *---------------------------------------------------------------------------*/ /** * \ingroup rppatch * \ref RpPatchType defines the different ways a patch atomic can be rendered. * Once a \ref RpPatchMesh has been attached to an \ref RpAtomic with * \ref RpPatchAtomicSetPatchMesh the atomic must be setup with the correct * rendering pipeline with \ref RpPatchAtomicSetType . * * The patch plugin makes no assumptions about how to render the * patch atomics. Once an \ref RpPatchMesh has been attached to an * \ref RpAtomic it is necessary to attach a suitable patch * rendering pipeline. The patch plugin supports four different * rendering types, these are defined in the \ref RpPatchType * enumeration:- * \li \ref rpPATCHTYPEGENERIC * The patch \ref RpAtomic will be rendered with the * default generic patch rendering pipeline. * \li \ref rpPATCHTYPESKIN * The patch \ref RpAtomic will be rendered with a * custom pipeline for rendering skinning patches. Make sure * an \ref RpSkin has been attached to the \ref RpPatchMesh * and an \ref RpHAnimHierarchy has been attached to the * \ref RpAtomic. * \li \ref rpPATCHTYPEMATFX * The patch \ref RpAtomic will be rendered with a * custom pipeline for rendering the material effects * of patches. The * patch matfx pipeline supports all the material effects * defined in the \ref rpmatfx plugin. The patches * materials should be setup as usual. * \li \ref rpPATCHTYPESKINMATFX * The patch \ref RpAtomic will be rendered with a * custom skinned material effects patch rendering pipeline. * The \ref RpPatchMesh, \ref RpAtomic and the patches' * \ref RpMaterial's must be setup correctly. */ enum RpPatchType { rpNAPATCHTYPE = 0, /**