This library provides efficient evaluation of patches.
The RpPatch plugin extends the RenderWare Graphics API to support patches. Quadrilateral and triangular bi-cubic patches are supported using 16 and 10 control points respectively.
A patch provides several benefits for representing curved surfaces over a regular triangular mesh because of some of its inherent properties.
The advantages of using patches rather than triangular meshes are:
The process of refining the patch mesh's control points into a triangle mesh varies on each platform. Depending on the hardware of the host platform the patch mesh will either be refined and retained or refined every frame:
Before using any of the RpPatch functions the plugin should be attached with:
There are two different types of patches:-
However changing an RpPatchMesh's flags will not automatically allocate memory, as it would if the flags had been defined at creation time.
Each patch within the patch mesh should normally have an RpMaterial attached to it. The patches are grouped by material when rendered. The patch materials should be accessed with the following functions:-
RpPatchMesh 'es may be written to and read from a binary stream using:-
An RpPatchMesh defines but does not render its mesh. It must be attached to an RpAtomic to be rendered; a system very similar to that used with the RpGeometry.
A patch mesh can be skinned in the same way as a geometry. An RpSkin should be created as usual for the control points and then attached to the RpPatchMesh with:-
When the patches rendering the control points are refined into triangles the level of tesselation is controlled by LOD callback functions. All patch atomics by default will use the default LOD function. The user may control this by defining the LOD ranges:-
The patch plugin makes no assumptions about how to render the patch atomics. Once an RpPatchMesh has been attached to an RpAtomic it is necessary to attach a suitable patch rendering pipeline. The patch plugin supports four different rendering types, these are defined in the RpPatchType enumeration:-
|
defines the maximum value that can be returned for the patch evaluation LOD.
|
|
defines the minimum value that can be returned for the patch evaluation LOD.
|
|
Convenience macro for generating a texture coordinate lock flag. |
|
Multi texture coordinate format specifier for RpPatchMeshCreate(). This should be OR'd into the RpPatchMeshFlag . |
|
defines the maximum value that can be returned for the skinned patch evaluation LOD.
|
|
defines the number of control point indices in a RpQuadPatch quadrilateral patch.
|
|
defines the number of control points in a quadrilateral patch.
|
|
defines the number of control points indices in a RpTriPatch triangular patch.
|
|
defines the number of control points in a triangular patch.
|
|
RpPatchLODCallBack typedef for the patch atomic LOD calculation function.
|
|
RpPatchLODUserData typedef for the user data passed to the RpPatchLODCallBack function which calculates the atomics' LOD. |
|
RpPatchMeshFlag When creating a RpPatchMesh, these flags can be OR'ed together to specify the format along with the rpPATCHMESHTEXCOORDSETS(num) macro to specify the number of texture coordinate sets required.
|
|
RpPatchMeshLockMode patch mesh lock flags.
|
|
RpPatchType defines the different ways a patch atomic can be rendered. Once a RpPatchMesh has been attached to an RpAtomic with RpPatchAtomicSetPatchMesh the atomic must be setup with the correct rendering pipeline with RpPatchAtomicSetType . The patch plugin makes no assumptions about how to render the patch atomics. Once an RpPatchMesh has been attached to an RpAtomic it is necessary to attach a suitable patch rendering pipeline. The patch plugin supports four different rendering types, these are defined in the RpPatchType enumeration:-
|
|
RpPatchAtomicGetPatchLODCallBack is used to retrieve the atomic's LOD callback function. The patch plugin must be attached before using this function.
|
|
RpPatchAtomicGetPatchMesh is used to retrieve the patch mesh referenced by the specified atomic. The patch plugin must be attached before using this function.
|
|
Returns the RpPatchType of the rendering pipeline attached to the atomic. The patch plugin must be attached before using this function.
|
|
RpPatchAtomicSetFreeListCreateParams allows the developer to specify how many PatchAtomicData s to preallocate space for. Call before RwEngineInit.
|
|
RpPatchAtomicSetPatchLODCallBack is used to define a callback function that determines which LOD should be used to facet the specified atomic. This allows a custom LOD selection defined by the application. If a NULL callback is specified then a default callback is registered for the atomic that calculates the LOD using linear interpolation between a near and far range. Values beyond the range are clamped to use the max rpPATCHLODMAXVALUE and min rpPATCHLODMINVALUE LOD respectively. The format of the callback function is RpPatchLODCallBack: RwUInt32 (* RpPatchLODCallBack) ( RpAtomic *atomic, RpPatchLODUserData userData ); The patch plugin must be attached before using this function.
|
|
RpPatchAtomicSetPatchMesh is used to attach the specified patch mesh to the given atomic. Setting the patch mesh also sets the atomic's bounding sphere equal to the bounding sphere of the patch mesh. If a patch mesh is already attached to the given atomic then that patch mesh is destroyed (unless it is still used by another atomic) before the new one is added. The patch plugin must be attached before using this function.
|
|
Sets up the patch RpAtomic with the correct rendering pipeline. The RpPatchMesh should be attached to the RpAtomic with RpPatchAtomicSetPatchMesh before setting up the RpAtomic's rendering pipeline. The patch plugin must be attached before using this function.
|
|
RpPatchGeometrySetFreeListCreateParams allows the developer to specify how many PatchGeometryData s to preallocate space for. Call before RwEngineInit.
|
|
RpPatchGetDefaultLODCallBackRange is used to query the setup of the default LOD callback. The values returned in RpPatchLODRange are used by the default patch atomic LOD callback. The patch plugin must be attached before using this function.
|
|
RpPatchMeshCreate is used to created a new empty RpPatchMesh. The number of RpQuadPatch patches and RpTriPatch patches must be defined. The number of control points must also be specified. The patch mesh is created locked with RpPatchMeshLockMode rpPATCHMESHLOCKALL and should be unlocked with RpPatchMeshUnlock once the control points and patches have been defined. The patch plugin must be attached before using this function.
|
|
RpPatchMeshDestroy is used to destroy an RpPatchMesh. This destroys the patch mesh together with any privately allocated data structure. The patch plugin must be attached before using this function.
|
|
RpPatchMeshForAllMaterials is used to apply the given callback function to all materials referenced by patches in the specified patch mesh. The format of the callback function is: RpMaterial * (* RpMaterialCallBack)(RpMaterial *material, void *userData) where data is a user-supplied data pointer to pass to the callback function. Note that if any invocation of the callback function returns a failure status the iteration is terminated. However, RpPatchMeshForAllMaterials will still return successfully. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetFlags is used to retrieve the property flags associated with the specified patch mesh. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetMaterial is used to retrieve the material with the given index from the specified patch mesh's material list. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNormals is used to retrieve the array of control point normals from the specified patch mesh. The array only exists if the patch mesh has been created using the rpPATCHMESHNORMALS flag. Use this function to initialize or redefine the patch mesh's control point normal list. There is a one-to-one correspondence between the control point position list array and the control point normal list array. The patch mesh must be locked before the control point normal data can be modified. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNumControlPoints is used to determine the number of control points defining the specified patch mesh. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNumMaterials is used to retrieve the number of different materials in use by all the patches in the specified patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNumQuadPatches is used to retrieve the number of quad patches that define the specified patch mesh. The quad patches define the patch mesh's topology and material properties. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNumTexCoordSets is used to determine the number of sets of texture coordinates in the specified patch mesh. Each set has one texture coordinate per control point. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetNumTriPatches is used to retrieve the number of tri patches that define the specified patch mesh. The tri patches define the patch mesh's topology and material properties. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetPositions is used to retrieve the array of control point positions from the specified patch mesh. The array only exists if the patch mesh has been created using the rpPATCHMESHPOSITIONS flag. Use this function to initialize or redefine the patch mesh's control point position list. There is a one-to-one correspondence between the control point position array and the control point normal array. The patch mesh must be locked before the control point position data can be modified. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetPreLightColors is used to retrieve the array of pre-lighting colors from the specified patch mesh. The array only exists if the patch mesh has been created using the rpPATCHMESHPRELIGHTS flag. The pre-lighting colors reside within the patch mesh's control point topology, at one color per control point. Use this function to initialize or redefine the pre-lighting colors. The patch mesh must be locked before the control point pre-lighting colors data can be modified. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetQuadPatch is used to get a set of quadrilateral (quad) patch control point indices from the patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetQuadPatchMaterial is used to retrieve the material associated with the specified quad patch in the given patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetSkin is used to retrieve the RpSkin attached to the patch mesh. The patch plugin must be attached before using this function. The skin plugin must also be attached before using this function.
|
|
RpPatchMeshGetTexCoords is used to retrieve a particular set of control point texture coordinates, if they exist in the specified patch mesh. The number of sets available may be determined using RpPatchMeshGetNumTexCoordSets, and is fixed when the patch mesh is created (see RpPatchMeshCreate). Control point texture coordinates reside within the patch mesh's topology, with each set having a (u,v) coordinate pair per control point. Use this function to initialize or redefine the control point texture coordinates. There is a one-to-one correspondence between the control point texture coordinates array and other control point list arrays. The patch mesh must be locked before modifying the control point texture coordinates. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetTriPatch is used to get a set of triangle (tri) patch control point indices from the patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshGetTriPatchMaterial is used to retrieve the material associated with the specified tri patch in the given patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshLock should be called before any of the patch mesh's control points or patches are changed. This function also prepares the patch mesh for unlocking after its data has been modified so that the platform specific instance can be rebuilt. A newly created patch mesh is already locked.
|
|
RpPatchMeshSetFlags is used to modify the property flags for the given patch mesh. Note that the new flag settings will completely replace the existing ones. Developers can logically OR (or add) flags together to combine them. Note that this function is used for debug purposes only and, for efficiency, is available as a macro for the final release version of an application. The patch plugin must be attached before using this function.
|
|
RpPatchMeshSetQuadPatch is used to add a set of quadrilateral (quad) patch control point indices to the patch mesh. The quad patch RpQuadPatch object consists of rpQUADPATCHNUMCONTROLINDICES control points. The quad patch indices are copied internally and not referenced. The patch mesh must be locked with RpPatchMeshLockMode rpPATCHMESHLOCKPATCHES before the patch indices are added. The patch plugin must be attached before using this function.
|
|
RpPatchMeshSetQuadPatchMaterial is used to associate the specified material with the given quad patch in the given patch mesh. The patch mesh's material list is modified accordingly. The material's reference count will be incremented if it's the first patch in the patch mesh to reference the material. Before updating the patch mesh's materials, the patch mesh should be locked with rpPATCHMESHLOCKPATCHES. When the patch mesh is unlocked, the patches will be collected into material groups. This decreases the number of renderstate changes when rendering the patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshSetSkin is used to attach the RpSkin to the specified patch mesh. The skin data is used during rendering to skin the patch mesh. The patch plugin and the skin plugin must be attached before using this function.
|
|
RpPatchMeshSetTriPatch is used to add a set of triangle (tri) patch control point indices to the patch mesh. The tri patch RpTriPatch object consists of rpTRIPATCHNUMCONTROLINDICES control points. The tri patch indices are copied internally and not referenced. The patch mesh must be locked with RpPatchMeshLockMode rpPATCHMESHLOCKPATCHES before the patch indices are added. The patch plugin must be attached before using this function.
|
|
RpPatchMeshSetTriPatchMaterial is used to associate the specified material with the given tri patch in the given patch mesh. The patch mesh's material list is modified accordingly. The material's reference count will be incremented if it's the first patch in the patch mesh to reference the material. Before updating the patch mesh's materials, the patch mesh should be locked with rpPATCHMESHLOCKPATCHES. When the patch mesh is unlocked, the patches will be collected into material groups. This decreases the number of renderstate changes when rendering the patch mesh. The patch plugin must be attached before using this function.
|
|
RpPatchMeshStreamGetSize is used to determine the size in bytes of the binary representation of the specified patch mesh. This is used in the binary chunk header to indicate the size of the patch mesh chunk. The size does not include the size of the chunk header. The patch plugin must be attached before using this function.
|
|
RpPatchMeshStreamRead is used to read a patch mesh from the specified binary stream. Prior to this function call, a binary patch mesh chunk must have been found in the stream using the RwStreamFindChunk API function.. The sequence to locate and read a patch mesh from a binary stream is as follows: RwStream *stream; RpPatchMesh *newPatchMesh; stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx"); if( stream ) { if( RwStreamFindChunk(stream, rwID_PATCHMESH, NULL, NULL) ) { newPatchMesh = RpPatchMeshStreamRead(stream); } RwStreamClose(stream, NULL); } The patch plugin must be attached before using this function.
|
|
RpPatchMeshStreamWrite is used to write the specified patch mesh to the given binary stream. The stream must have been opened prior to this function call. The patch plugin must be attached before using this function.
|
|
RpPatchMeshTransform is used to apply the specified transformation matrix to the given patch mesh. The transformation is applied equally to all the control point positions and control point normals. The patch mesh bounding sphere is recalculated after the transform. Note that the transformation modifies the patch mesh data and is permanent. Note also that patch mesh locking and unlocking is performed, as appropriate, before and after applying the transformation. The patch plugin must be attached before using this function.
|
|
RpPatchMeshUnlock is used to unlock the specified patch mesh. This function will release the internal sections of the patch mesh which were locked with RpPatchMeshLock. Unlocking a patch mesh may force the patch mesh to be reinstanced. When the patch mesh is instanced the individual patches are grouped by material into patch material meshes which substantially speeds up the rendering process. The reinstancing, particularly the re-grouping process, is potentially slow, especially if the patch material meshes are rebuilt. Hence the locking and unlocking of patch meshes should be used carefully between rendering frames. Newly created patch meshes are always locked and should be unlocked before they are used in any rendering. The patch plugin must be attached before using this function.
|
|
RpPatchPluginAttach is used to attach the patch plugin to the RenderWare system to enable the use of patch modelling for atomics. The patch plugin must be attached between initializing the system with RwEngineInit and opening it with RwEngineOpen. Note that the include file rppatch.h is required and must be included by an application wishing to use this plugin. The patch plugin library is contained in the file rppatch.lib.
|
|
RpPatchSetDefaultLODCallBackRange is used to setup the default LOD callback. The values in RpPatchLODRange are used by the default patch atomic LOD callback. The minimum range defines the distance when the patch is at the maximum LOD. Atomics closer than this distance are facetted at the maximum LOD. The maximum range defines the distance when the patch is at the minimum LOD. Atomics futher than this distance are facetted at the minimum LOD. Atomics within the minimum and maximum range will have an LOD in inverse proportion to the distance from the viewer. The minimum and maximum values set the minimum and maximum LOD. The patch plugin must be attached before using this function.
|
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |