diff --git a/premake5.lua b/premake5.lua index f7e54d31..67766af5 100644 --- a/premake5.lua +++ b/premake5.lua @@ -7,11 +7,16 @@ workspace "re3" files { "src/modelinfo/*.*" } files { "src/entities/*.*" } files { "src/render/*.*" } + files { "src/control/*.*" } + files { "src/audio/*.*" } - includedirs { "src", "src/modelinfo" } - includedirs { "src", "src/entities" } - includedirs { "src", "src/render" } - includedirs { os.getenv("RWSDK33") } + includedirs { "src" } + includedirs { "src/modelinfo" } + includedirs { "src/entities" } + includedirs { "src/render" } + includedirs { "src/control" } + includedirs { "src/audio" } + includedirs { "rwsdk/include/d3d8" } project "re3" kind "SharedLib" diff --git a/rwsdk/include/d3d8/baaplylt.c b/rwsdk/include/d3d8/baaplylt.c new file mode 100644 index 00000000..ad518e6a --- /dev/null +++ b/rwsdk/include/d3d8/baaplylt.c @@ -0,0 +1,793 @@ + +/* If this file is used outside of the core RW SDK, + * the following things need to be defined + */ +#if (!defined(RWASSERT)) +#define RWASSERT(_assertval) /* No op */ +#endif +#if (!defined(RWFUNCTION)) +#define RWFUNCTION(_rwfunctionstring) /* No op */ +#endif +#if (!defined(RWRETURN)) +#define RWRETURN(_rwreturnval) return(_rwreturnval) +#endif +#if (!defined(RWRETURNVOID)) +#define RWRETURNVOID() return +#endif + +/* These are used by specular lighting, + * sorry I have to leave them in here... IDBS + * I'll make it neater when I have time. + */ +#if (!defined(FALLOFFAMBIENT)) +#define FALLOFFAMBIENT() /* No op */ +#endif +#if (!defined(FALLOFFDIRECTIONAL)) +#define FALLOFFDIRECTIONAL() /* No op */ +#endif +#if (!defined(FALLOFFPOINT)) +#define FALLOFFPOINT() /* No op */ +#endif +#if (!defined(FALLOFFSPOT)) +#define FALLOFFSPOT() /* No op */ +#endif +#if (!defined(FALLOFFSOFTSPOT)) +#define FALLOFFSOFTSPOT() /* No op */ +#endif + +/*************************************************************************** + _rwApplyAmbientLight + + On entry : Instanced data + : Light + : Optional inverse object matrix + : (to transform light to object space) + : Inverse scale of object + : Surface properties of the light + On exit : + */ + +static void +_rwApplyAmbientLight(VERTSARG, + const void *voidLight, + const RwMatrix * __RWUNUSED__ inverseMat, + RwReal __RWUNUSED__ invScale, + const RwSurfaceProperties * surfaceProps) +{ + CAMVERTDECL; + NUMVERTDECL; + const RpLight *light = (const RpLight *) voidLight; + RwReal scale; + RwV3d vertToLight; + + RWFUNCTION(RWSTRING("_rwApplyAmbientLight")); + RWASSERT(light); + RWASSERT(surfaceProps); + + CAMVERTINIT(); + NUMVERTINIT(); + + /* No directional component: + * (this is used in CAMVERTADDRGBA in a specular lighting node) */ + vertToLight.x = 0; + vertToLight.y = 0; + vertToLight.z = 0; + + /* rpLIGHTAMBIENT - Constant illumination on all vertices + */ + if (rwObjectTestPrivateFlags(light, rpLIGHTPRIVATENOCHROMA)) + { + scale = 255.0f * light->color.red * surfaceProps->ambient; + + /* Ambient light affects all vertices the same */ + while (numVert--) + { + RwReal lum = scale; + +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFAMBIENT + CAMVERTADDRGBA(1, 1, 1, 0); + CAMVERTINC(); + } + } + else + /* perform for coloured lights */ + { + scale = 255.0f * surfaceProps->ambient; + + /* Ambient light affects all vertices the same */ + while (numVert--) + { + RwReal lum = scale; + +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFAMBIENT + CAMVERTADDRGBA(light->color.red, light->color.green, + light->color.blue, 0); + CAMVERTINC(); + } + } + RWRETURNVOID(); +} + +/*************************************************************************** + _rwApplyDirectionalLight + + On entry : Instanced data + : Light + : Optional inverse object matrix + : (to transform light to object space) + : Inverse scale of object + : Surface properties of the light + On exit : + */ + +static void +_rwApplyDirectionalLight(VERTSARG, + const void *voidLight, + const RwMatrix * inverseMat, + RwReal __RWUNUSED__ invScale, + const RwSurfaceProperties * surfaceProps) +{ + OBJCAMVERTDECL; + NUMVERTDECL; + const RpLight *light = (const RpLight *) voidLight; + RwV3d vertToLight; + RwReal scale; + RwReal dot; + RwFrame *lightFrame; + + RWFUNCTION(RWSTRING("_rwApplyDirectionalLight")); + RWASSERT(light); + RWASSERT(surfaceProps); + + OBJCAMVERTINIT(); + NUMVERTINIT(); + + /* rpLIGHTDIRECTIONAL - Lighting scaled by dot product + * of vertex normal and light lookAt vector. + */ + /* This may not have a frame - we need to check */ + lightFrame = RpLightGetFrame(light); + if (lightFrame) + { + vertToLight = RwFrameGetLTM(lightFrame)->at; + + /* Transform the light into object space if necessary */ + if (inverseMat) + { + RwV3dTransformVectors(&vertToLight, &vertToLight, 1, inverseMat); + _rwV3dNormalize(&vertToLight, &vertToLight); + } + + /* Vert TO light */ + RwV3dScale(&vertToLight, &vertToLight, -1); + + /* Optimise for grey lights? */ + if (rwObjectTestPrivateFlags(light, rpLIGHTPRIVATENOCHROMA)) + { + /* Use one of the light colour intensities as general intensity */ + /* light vector tests are to be identical to others */ + scale = 255.0f * light->color.red * surfaceProps->diffuse; + + /* Loop through each of the vertices */ + while (numVert--) + { + RwV3d objNormal; + + OBJVERTGETNORMAL(&objNormal); + /* Calculate angle between vertex normal and light vector */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + + /* Ensure vector is facing light, + * don't light areas not facing */ + + if (dot > 0.0f) + { + RwReal lum = dot * scale; + +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFDIRECTIONAL + CAMVERTADDRGBA(1, 1, 1, 0); + } + + /* Next vertex */ + OBJCAMVERTINC(); + } + } + else + /* perform for coloured lights */ + { + scale = 255.0f * surfaceProps->diffuse; + + /* Loop through each of the vertices */ + while (numVert--) + { + RwV3d objNormal; + + OBJVERTGETNORMAL(&objNormal); + /* Calculate angle between vertex normal and light vector */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + + /* Ensure vector is facing light, + * don't light areas not facing */ + + if (dot > 0.0f) + { + RwReal lum = dot * scale; + +#define FALLOFFCALC FALLOFFDIRECTIONAL + CAMVERTADDRGBA(light->color.red, light->color.green, + light->color.blue, 0); + } + + /* Next vertex */ + OBJCAMVERTINC(); + } + } + } + + RWRETURNVOID(); +} + +/*************************************************************************** + _rwApplyPointLight + + On entry : Instanced data + : Light + : Optional inverse object matrix + : (to transform light to object space) + : Inverse scale of object + : Surface properties of the light + On exit : + */ + +static void +_rwApplyPointLight(VERTSARG, const void *voidLight, + const RwMatrix * inverseMat, + RwReal invScale, const RwSurfaceProperties * surfaceProps) +{ + OBJCAMVERTDECL; + NUMVERTDECL; + const RpLight *light = (const RpLight *) voidLight; + RwReal scale, recipRad; + RwV3d lightPos, vertToLight; + RwReal radSquared; + + RWFUNCTION(RWSTRING("_rwApplyPointLight")); + RWASSERT(light); + RWASSERT(surfaceProps); + + OBJCAMVERTINIT(); + NUMVERTINIT(); + + /* rpLIGHTPOINT - Linear falloff with distance, scaled by + * dot product of vertex normal and light to vertex vector. + */ + lightPos = RwFrameGetLTM(RpLightGetFrame(light))->pos; + + if (inverseMat) + { + RwReal scaledRad; + + scaledRad = ((light->radius) * (invScale)); + radSquared = ((scaledRad) * (scaledRad)); + recipRad = (((RwReal) (1)) / (scaledRad)); + + /* Transform light into object space */ + RwV3dTransformPoints(&lightPos, &lightPos, 1, inverseMat); + } + else + { + radSquared = ((light->radius) * (light->radius)); + recipRad = (((RwReal) (1)) / (light->radius)); + } + + if (rwObjectTestPrivateFlags(light, rpLIGHTPRIVATENOCHROMA)) + { + /* The scale encapsulates the common elements to do + * with light intensity and surface lighting properties + */ + scale = + ((((RwReal) (255)) * (light->color.red))) * + (surfaceProps->diffuse); + + while (numVert--) + { + RwV3d objVertex, objNormal; + RwReal dot, dist2; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Discover the vector between vertex and light and it's length */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + /* Ensure vertex lies within the light's radius */ + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + if (dist2 < radSquared) + { + RwReal lum; + RwReal recipDist; + RwReal dist; + + rwSqrt(&dist, dist2); + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + /* + * The following simplifies down to: + * + * -scale * + * (dot/dist) * + * (1 - dist/lightRadius) + * + * Where + * scale + * takes care of the light intensity and + * diffuse lighting coefficient + * (dot/dist) + * is a normalised dot product of + * light->vertex vector and vertex normal + * (1 - dist/lightRadius) + * is a linear falloff factor + */ + lum = scale * dot * (recipDist - recipRad); + + /* Calculate the luminance at vertex */ +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFPOINT + CAMVERTADDRGBA(1, 1, 1, 0); + } + } + + OBJCAMVERTINC(); + } + } + else + { + scale = (((RwReal) (255)) * (surfaceProps->diffuse)); + + while (numVert--) + { + RwV3d objVertex, objNormal; + RwReal dot, dist2; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Discover the vector between vertex and light and it's length */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + + /* Ensure vertex lies within the light's radius */ + if (dist2 < radSquared) + { + RwReal lum; + RwReal recipDist; + RwReal dist; + + /* Only now calculate the actual length of vector */ + rwSqrt(&dist, dist2); + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + lum = scale * dot * (recipDist - recipRad); + /* Alter the luminance according to light colour */ +#define FALLOFFCALC FALLOFFPOINT + CAMVERTADDRGBA(light->color.red, light->color.green, + light->color.blue, 0); + } + } + + /* Next point */ + OBJCAMVERTINC(); + } + } + RWRETURNVOID(); +} + +/*************************************************************************** + _rwApplySpotLight + + On entry : Instanced data + : Light + : Optional inverse object matrix + : (to transform light to object space) + : Inverse scale of object + : Surface properties of the light + On exit : + */ + +static void +_rwApplySpotLight(VERTSARG, + const void *voidLight, + const RwMatrix * inverseMat, + RwReal invScale, const RwSurfaceProperties * surfaceProps) +{ + OBJCAMVERTDECL; + NUMVERTDECL; + const RpLight *light = (const RpLight *) voidLight; + RwReal recipRad; + RwReal radSquared; + RwV3d lightPos, at; + + RWFUNCTION(RWSTRING("_rwApplySpotLight")); + RWASSERT(light); + RWASSERT(surfaceProps); + + OBJCAMVERTINIT(); + NUMVERTINIT(); + + /* rpLIGHTSPOT - Linear falloff with distance, cone to restrict + * angle that light has effect, constant intensity across cone, + * scaled by dot product of vertex normal and light to vertex vector. + */ + + lightPos = RwFrameGetLTM(RpLightGetFrame(light))->pos; + at = RwFrameGetLTM(RpLightGetFrame(light))->at; + + if (inverseMat) + { + RwReal scaledRad; + + scaledRad = ((light->radius) * (invScale)); + recipRad = (((RwReal) (1)) / (scaledRad)); + radSquared = ((scaledRad) * (scaledRad)); + + /* Transform light into object space */ + /* The at is required to ensure within cone */ + RwV3dTransformPoints(&lightPos, &lightPos, 1, inverseMat); + RwV3dTransformVectors(&at, &at, 1, inverseMat); + _rwV3dNormalize(&at, &at); + } + else + { + recipRad = (((RwReal) (1)) / (light->radius)); + radSquared = ((light->radius) * (light->radius)); + } + + if (rwObjectTestPrivateFlags(light, rpLIGHTPRIVATENOCHROMA)) + { + RwReal scale = + + ((RwReal) 255) * (light->color.red) * (surfaceProps->diffuse); + + while (numVert--) + { + RwV3d vertToLight, objVertex, objNormal; + RwReal dot; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Find the squared distance from light point to vertex */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + RwReal dist2; + + /* Ensure vertex lies within the light's radius */ + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + if (dist2 < radSquared) + { + RwReal dist; + RwReal compare; + RwReal proj; + + rwSqrt(&dist, dist2); + compare = dist * light->minusCosAngle; + proj = RwV3dDotProduct(&vertToLight, &at); + + if (proj < compare) + { + RwReal lum; + RwReal recipDist; + + /* Get the real distance from the light + * to the vertex (not squared) */ + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + /* This model is the same as the point source + * inside the cone, zero outside the cone */ + lum = scale * dot * (recipDist - recipRad); +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFSPOT + CAMVERTADDRGBA(1, 1, 1, 0); + } + } + /* Next vertex */ + OBJCAMVERTINC(); + } + } + } + else + { + RwReal scale = + + (((RwReal) (255)) * (surfaceProps->diffuse)); + + while (numVert--) + { + RwV3d vertToLight, objVertex, objNormal; + RwReal dot; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Find the squared distance from light point to vertex */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + RwReal dist2; + + /* Ensure vertex lies within the light's radius */ + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + if (dist2 < radSquared) + { + RwReal dist; + RwReal compare; + RwReal proj; + + rwSqrt(&dist, dist2); + compare = dist * light->minusCosAngle; + proj = RwV3dDotProduct(&vertToLight, &at); + + if (proj < compare) + { + RwReal lum; + RwReal recipDist; + + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + /* This model is the same as the point source + * inside the cone, zero outside the cone */ + lum = scale * dot * (recipDist - recipRad); + + /* Introduce the light colours as a + * scaling factor for luminance */ +#define FALLOFFCALC FALLOFFSPOT + CAMVERTADDRGBA(light->color.red, + light->color.green, light->color.blue, + 0); + } + } + } + + /* Next */ + OBJCAMVERTINC(); + } + } + + RWRETURNVOID(); +} + +/*************************************************************************** + _rwApplySpotSoftLight + + On entry : Instanced data + : Light + : Optional inverse object matrix + : (to transform light to object space) + : Inverse scale of object + : Surface properties of the light + On exit : + */ + +static void +_rwApplySpotSoftLight(VERTSARG, const void *voidLight, + const RwMatrix * inverseMat, RwReal invScale, + const RwSurfaceProperties * surfaceProps) +{ + OBJCAMVERTDECL; + NUMVERTDECL; + const RpLight *light = (const RpLight *) voidLight; + RwReal recipRad; + RwReal radSquared; + RwV3d lightPos, at; + + RWFUNCTION(RWSTRING("_rwApplySpotSoftLight")); + RWASSERT(light); + RWASSERT(surfaceProps); + + OBJCAMVERTINIT(); + NUMVERTINIT(); + + /* rpLIGHTSPOTSOFT - Linear falloff with distance, cone to restrict + * angle that light has effect, falloff to edge of cone, scaled by + * dot product of vertex normal and light to vertex vector. + */ + + lightPos = RwFrameGetLTM(RpLightGetFrame(light))->pos; + at = RwFrameGetLTM(RpLightGetFrame(light))->at; + + if (inverseMat) + { + RwReal scaledRad; + + scaledRad = ((light->radius) * (invScale)); + recipRad = (((RwReal) (1)) / (scaledRad)); + radSquared = ((scaledRad) * (scaledRad)); + + /* Transform light into object space */ + /* The at is required to ensure within cone */ + RwV3dTransformPoints(&lightPos, &lightPos, 1, inverseMat); + RwV3dTransformVectors(&at, &at, 1, inverseMat); + _rwV3dNormalize(&at, &at); + } + else + { + recipRad = 1.0f / light->radius; + radSquared = light->radius * light->radius; + } + + if (rwObjectTestPrivateFlags(light, rpLIGHTPRIVATENOCHROMA)) + { + RwReal scale = + + ((RwReal) 255) * (light->color.red) * (surfaceProps->diffuse); + + while (numVert--) + { + RwV3d vertToLight, objVertex, objNormal; + RwReal dot; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Find the squared distance from light point to vertex */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + RwReal dist2; + + /* Ensure vertex lies within the light's radius */ + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + if (dist2 < radSquared) + { + RwReal dist; + RwReal compare; + RwReal proj; + + rwSqrt(&dist, dist2); + compare = dist * light->minusCosAngle; + proj = RwV3dDotProduct(&vertToLight, &at); + + if (proj < compare) + { + RwReal lum; + RwReal recipDist; + RwReal normalise; + + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + /* This model is the same as the point source + * inside the cone, zero outside the cone */ + lum = scale * dot * (recipDist - recipRad); + + /* It has an extra term for quadratic falloff + * across the cone though */ + normalise = (dist + compare); + RWASSERT(normalise >= 0.0f); + if (normalise > 0.0f) + { + normalise = (dist + proj) / normalise; + + normalise *= normalise; + lum *= (((RwReal) 1) - normalise); + } + +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFSOFTSPOT + CAMVERTADDRGBA(1, 1, 1, 0); + } + } + } + + /* Next */ + OBJCAMVERTINC(); + } + } + + else + { + RwReal scale = 255.0f * surfaceProps->diffuse; + + while (numVert--) + { + RwV3d vertToLight, objVertex, objNormal; + RwReal dot; + + OBJVERTGETPOS(&objVertex); + OBJVERTGETNORMAL(&objNormal); + + /* Find the squared distance from light point to vertex */ + RwV3dSub(&vertToLight, &lightPos, &objVertex); + + /* Ensure that this vertex is facing the light source */ + dot = RwV3dDotProduct(&vertToLight, &objNormal); + if (dot > 0.0f) + { + RwReal dist2; + + /* Ensure vertex lies within the light's radius */ + dist2 = RwV3dDotProduct(&vertToLight, &vertToLight); + if (dist2 < radSquared) + { + RwReal dist; + RwReal compare; + RwReal proj; + + rwSqrt(&dist, dist2); + compare = dist * light->minusCosAngle; + proj = RwV3dDotProduct(&vertToLight, &at); + + if (proj < compare) + { + + RwReal lum; + RwReal normalise; + RwReal recipDist; + + /* Get the real distance from the light + * to the vertex (not squared) */ + recipDist = + (dist > 0.0f) ? (((RwReal) 1) / dist) : 0.0f; + + /* This model is the same as the point source + * inside the cone, zero outside the cone */ + lum = scale * dot * (recipDist - recipRad); + + /* It has an extra term for quadratic falloff + * across the cone though */ + /* It has an extra term for quadratic falloff + * across the cone though */ + normalise = (dist + compare); + RWASSERT(normalise >= 0.0f); + if (normalise > 0.0f) + { + normalise = (dist + proj) / normalise; + + normalise *= normalise; + lum *= (((RwReal) 1) - normalise); + + } + /* Introduce the light colours as a + * scaling factor for luminance */ +#undef FALLOFFCALC +#define FALLOFFCALC FALLOFFSOFTSPOT + CAMVERTADDRGBA(light->color.red, + light->color.green, + light->color.blue, 0); + } + } + } + + /* Next */ + OBJCAMVERTINC(); + } + } + + RWRETURNVOID(); +} diff --git a/rwsdk/include/d3d8/errcom.def b/rwsdk/include/d3d8/errcom.def new file mode 100644 index 00000000..25f44e1e --- /dev/null +++ b/rwsdk/include/d3d8/errcom.def @@ -0,0 +1,60 @@ +RWECODE(E_RW_BADENGINESTATE, + "Engine in incorrect state for this operation") +RWECODE(E_RW_BADOPEN, + "Error opening the file %s") +RWECODE(E_RW_BADPARAM, + "Invalid Parameter passed. %s") +RWECODE(E_RW_BADVERSION, + "The binary file format version is incompatible with this library") +RWECODE(E_RW_DEBUGSTACK, + "Debug Library has Stack Depth mismatch") +RWECODE(E_RW_DEFAULTPIPELINECREATION, + "Creation of a default pipeline (%s) failed") +RWECODE(E_RW_FRAMENOMATRIX, + "The frame does not have an associated matrix") +RWECODE(E_RW_INVIMAGEDEPTH, + "Invalid Image Depth") +RWECODE(E_RW_INVIMAGEFORMAT, + "Image has no pixel memory allocated") +RWECODE(E_RW_INVIMAGEMASK, + "The mask and image are not the same size") +RWECODE(E_RW_INVIMAGESIZE, + "Destination and source images are of differing sizes") +RWECODE(E_RW_INVRASTERDEPTH, + "Invalid Raster depth") +RWECODE(E_RW_INVRASTERFORMAT, + "Unrecognized raster format") +RWECODE(E_RW_INVRASTERLOCKREQ, + "Invalid Raster lock request") +RWECODE(E_RW_INVRASTERMIPLEVEL, + "Invalid Raster mipmap level") +RWECODE(E_RW_INVRASTERSIZE, + "Invalid Raster size") +RWECODE(E_RW_INVRASTERUNLOCKREQ, + "Invalid Raster unlock request") +RWECODE(E_RW_NOFRAME, + "Unable to find Frame") +RWECODE(E_RW_NOMEM, + "Unable to allocate %d bytes of memory") +RWECODE(E_RW_NOMIPMAPGENERATIONCALLBACK, + "No Mipmap generation callback set - use RtMipmapUseDefaultMipmapGenerationCallback") +RWECODE(E_RW_NOTSSEENABLEDCPU, + "Not SSE enabled CPU") +RWECODE(E_RW_NULLP, + "NULL pointer passed to library routine") +RWECODE(E_RW_PLUGININIT, + "Plugin has already been initialized") +RWECODE(E_RW_PLUGINNOTINIT, + "Plugin not initialized") +RWECODE(E_RW_RANGE, + "A supplied parameter was outside the expected range") +RWECODE(E_RW_READ, + "Read error on stream") +RWECODE(E_RW_REDUNDANT_FUNCTION, + "Call to redundant function - scheduled to be dropped from future releases") +RWECODE(E_RW_WRITE, + "Write error on stream") +RWECODE(E_RX_MESHES_RANGES_OVERLAP, + "\n Geometry is in an invalid format for RxPipeline rendering.\n There may be visible artifacts and/or decreased performance.\n Use RpGeometrySortByMaterial.\n [stream %p type %s]") +RWECODE(E_RW_STRING_TRUNCATION, + "strlen(%s) >= %d; truncating at character #%d == %c") diff --git a/rwsdk/include/d3d8/errcore.def b/rwsdk/include/d3d8/errcore.def new file mode 100644 index 00000000..c71eed5a --- /dev/null +++ b/rwsdk/include/d3d8/errcore.def @@ -0,0 +1,117 @@ +RWECODE(E_RW_BADWINDOW, + "Invalid view window dimensions supplied") +RWECODE(E_RW_CHUNKTYPEGET, + "Unable to get a chunk of the given type") +RWECODE(E_RW_DEVICEERROR, + "Device specific error: %s") +RWECODE(E_RW_DEVICEOPEN, + "Request to open device system refused") +RWECODE(E_RW_DEVICESTART, + "Attempt to start Device failed") +RWECODE(E_RW_ENDOFSTREAM, + "At the end of the stream.") +RWECODE(E_RW_FRAMEDESTROYSTATIC, + "RwFrameDestroy called on static frame.") +RWECODE(E_RW_FRAMEBUFFERMISMATCH, + "Resolutions of parent rasters of frame buffer and Z buffer are different") +RWECODE(E_RW_FREELISTFREED, + "Free List value already on the free list") +RWECODE(E_RW_FREELISTINVADDRESS, + "Invalid Free List memory address") +RWECODE(E_RW_FREELISTINVMEMBOUND, + "Invalid Free List memory boundary") +RWECODE(E_RW_FREELISTTRASH, + "An unused Free List entry has been overwritten") +RWECODE(E_RW_INSUFFICIENTRESOURCES, + "Insufficient resources to satisfy the allocation of %d bytes.") +RWECODE(E_RW_INVSTREAMACCESSTYPE, + "Invalid stream access type.") +RWECODE(E_RW_INVSTREAMTYPE, + "Invalid stream type.") +RWECODE(E_RW_NEGCLIPPLANE, + "Negative positioned clip planes are invalid") +RWECODE(E_RW_NOCAMERA, + "Cannot render until a Camera has been created") +RWECODE(E_RW_NOFRAMEBUFFER, + "Camera has no frame buffer raster") +RWECODE(E_RW_NOPARENT, + "The given object has no parent") +RWECODE(E_RW_RASTERRECT, + "Rectangle is not totally within Raster") +RWECODE(E_RW_RASTERSTACK, + "Insufficient Raster stack space available") +RWECODE(E_RW_RASTERSTACKEMPTY, + "No Raster Currently on Stack") +RWECODE(E_RW_READTEXMASK, + "Unable to read Texture %s / Mask %s") +RWECODE(E_RW_STREAMOPEN, + "Unable to open stream : %s") +RWECODE(E_RW_SYSTEMREQUEST, + "A system request call has failed, request code : 0x%x") +RWECODE(E_RW_ZEROLENGTH, + "A Vector of Zero Length was passed for normalizing") +RWECODE(E_RX_CANNOT_TRANSFER_BETWEEN_NODES, + "Node %s cannot output to node %s") +RWECODE(E_RX_CANNOT_TRANSFER_FROM_NODE_TO_PIPELINE, + "Node %s cannot output to specified pipeline") +RWECODE(E_RX_CYCLICPIPELINE, + "Pipeline contains cycles; illegal") +RWECODE(E_RX_DEP_DEPENDENCIESMISMATCH, + "\n" + "*** dependencies cannot be satisfied.\n" + "*** rxCLREQ_REQUIRED on cluster %s, originating\n" + "*** with node %s, not serviced by a rxCLVALID_VALID -\n" + "*** blocked at node %s, output #%ld (\"%s\").") +RWECODE(E_RX_DEP_DUPLICATECLUSTERDEFS, + "\n" + "*** Node %s specifies RxClusterDefinition for cluster %s more than once in\n" + "*** clusters of interest array. Distinct clusters within a pipeline must reference\n" + "*** distinct RxClusterDefinitions, even if the clusters contain the same data type\n") +RWECODE(E_RX_DEP_NULLCLUSTERDEF, + "Node %s specified with RxClusterDefinition pointer NULL for cluster of interest %d\n") +RWECODE(E_RX_DEP_OUTOFMEMORY, + "Dependency chasing; memory alloc failed") +RWECODE(E_RX_EMPTYPIPELINE, + "RwPipeline2Execute cannot execute a pipeline with no nodes :)") +RWECODE(E_RX_FRAGMENTEDPIPELINE, + "Pipeline forms two or more unconnected graphs; illegal") +RWECODE(E_RX_IM3DNOTACTIVE, + "Cannot render Im3D primitives outside of a RwIm3dTransform()/RwIm3dEnd() pair") +RWECODE(E_RX_INVALIDENTRYPOINT, + "Pipeline has an invalid entry point") +RWECODE(E_RX_INVALIDPRIMTYPE, + "Unknown primitive type %d") +RWECODE(E_RX_INVALIDRESUMEPIPELINE, + "RwPipeline2Execute cannot resume a different pipeline to the one previously interrupted") +RWECODE(E_RX_LOCKEDPIPE, + "Illegal operation on a locked pipeline") +RWECODE(E_RX_NODETOOMANYCLUSTERSOFINTEREST, + "Node contains more than RXNODEMAXCLUSTERSOFINTEREST clusters of interest; illegal") +RWECODE(E_RX_NODETOOMANYOUTPUTS, + "Node contains more than RXNODEMAXOUTPUTS outputs; illegal") +RWECODE(E_RX_PIPELINETOOMANYNODES, + "Maximum nodes per pipeline exceeded! You may increase the limit by changing the value of _rxPipelineMaxNodes BEFORE starting RenderWare") +RWECODE(E_RX_NODE_EXECUTION_FAILED, + "Node execution failed - %s") +RWECODE(E_RX_NOVERTS, + "Cannot render Im3D primitive - not enough vertices transformed") +RWECODE(E_RX_PACKETPTRINVALID, + "Value of input/output interruption packets pointer not as expected") +RWECODE(E_RX_PACKETSCOPYFAILED, + "Failed to make copies of packets input to RxPipelineExecute()") +RWECODE(E_RX_RUNFROMNOTVALID, + "RunFrom node not a member of the specified pipeline") +RWECODE(E_RX_RUNTOANDRUNFROM, + "RwPipeline2Execute cannot accept both RunTo *and* RunFrom") +RWECODE(E_RX_RUNTONOTVALID, + "RunTo node not a member of the specified pipeline") +RWECODE(E_RX_TOOMANYVERTS, + "More than 65536 vertices passed to RwIm3DTransform; illegal") +RWECODE(E_RX_UNFINISHEDPIPELINE, + "RwPipeline2Execute must resume and finish an interrupted pipeline") +RWECODE(E_RX_UNLOCKEDPIPE, + "Illegal operation on an unlocked pipeline") +RWECODE(E_RX_UNPROCESSED_PACKETS, + "Unprocessed packets found in finished execution context") +RWECODE(E_RX_UNSATISFIED_REQUIREMENTS, + "Cannot send packet between pipelines, requirements not satisfied. Cluster '%s' is missing") diff --git a/rwsdk/include/d3d8/rpanisot.h b/rwsdk/include/d3d8/rpanisot.h new file mode 100644 index 00000000..4f4445a4 --- /dev/null +++ b/rwsdk/include/d3d8/rpanisot.h @@ -0,0 +1,54 @@ +/** + * Anisotropic Texture Sampling Plugin for RenderWare. + */ + +#ifndef RPANISOTPLUGIN_H +#define RPANISOTPLUGIN_H + +/** + * \defgroup rpanisot RpAnisot + * \ingroup rpplugin + * + * Anisotropic Texture Sampling Plugin for RenderWare Graphics. + */ + +/** + * \ingroup rpanisot + * \page rpanisotoverview RpAnisot Plugin Overview + * + * \par Requirements + * \li \b Headers: rwcore.h, rpworld.h, rpanisot.h + * \li \b Libraries: rwcore, rpworld, rpanisot + * \li \b Plugin \b attachments: \ref RpWorldPluginAttach, \ref RpAnisotPluginAttach + * + * \subsection anisotoverview Overview + * The RpAnisot plugin is used to extend an RwTexture with a maximum + * anisotropy value that will be used when a particular texture is drawn. + * When textured polygons are viewed nearly edge on, for example when looking + * dowm a road or a football pitch, distant pixels are not sampled very well + * by trilinear mipmapping and the texture looks smeary. + * Anisotropic sampling takes additional samples, resulting in sharper looking + * textures. Higher numbers of samples will produce better quality results but + * run slower, so should be used in moderation. + * + */ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern RwInt8 RpAnisotGetMaxSupportedMaxAnisotropy(void); + +extern RwTexture *RpAnisotTextureSetMaxAnisotropy(RwTexture *tex, RwInt8 val); +extern RwInt8 RpAnisotTextureGetMaxAnisotropy(RwTexture *tex); + +extern RwBool RpAnisotPluginAttach(void); + +#ifdef __cplusplus +} +#endif + +#endif /* RPANISOTPLUGIN_H */ diff --git a/rwsdk/include/d3d8/rpanisot.rpe b/rwsdk/include/d3d8/rpanisot.rpe new file mode 100644 index 00000000..5216ec9c --- /dev/null +++ b/rwsdk/include/d3d8/rpanisot.rpe @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLabel +{ + + + + e_rwdb_CriterionLabelLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLabel e_rwdb_CriterionLabel; + + diff --git a/rwsdk/include/d3d8/rpcollis.h b/rwsdk/include/d3d8/rpcollis.h new file mode 100644 index 00000000..908fb68e --- /dev/null +++ b/rwsdk/include/d3d8/rpcollis.h @@ -0,0 +1,372 @@ + +/***************************************************************************** + * + * File : rpcollis.h + * + * Abstract : World collision plugin for Renderware. + * + ***************************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2000 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + *****************************************************************************/ + +#ifndef RPCOLLIS_H +#define RPCOLLIS_H + +/* Doxygen plugin groups. */ + +/** + * \defgroup rpcollis RpCollision + * \ingroup rpplugin + * + * Collision Plugin for RenderWare Graphics. + */ + +/****************************************************************************** + * Include files + */ + +#include +#include + +#include "rpcollis.rpe" /* automatically generated header file */ + +/****************************************************************************** + * Global Types + */ + +/** + * \ingroup rpcollis + * RpIntersectType, this type represents the different types of + * primitives that can be used to intersect with an object (for example, see + * \ref RpCollisionWorldForAllIntersections): + */ +enum RpIntersectType +{ + rpINTERSECTNONE = 0, + rpINTERSECTLINE, /** +#include + +#include +#include + +static const char rcsid[] __RWUNUSED__ = "@@(#)$Id: //RenderWare/RW33Active/dev/rwsdk/src/plcore/rpdbgerr.c#1 $"; + +#ifdef RWDEBUG + +/**************************************************************************** + Defines + */ + + /**************************************************************************** + Local (static) Globals + */ + +/* The strings used in the debug error reporting are derived from the + * .def files + */ + +#define RWECODE(a,b) RWSTRING(b), + +static const RwChar *rw_err_str[] = +{ +#include "rperror.def" + RWSTRING("Last Error") +}; + +#undef RWECODE +#define RWECODE(a,b) RWSTRING(#a), + +static const RwChar *rw_err_cstr[] = +{ +#include "rperror.def" + RWSTRING("E_RW_LAST") +}; + +#undef RWECODE + +static RwChar dberr[512]; + +RwChar * +rwPLUGIN_ERRFUNC(RwInt32 code,...) +{ + va_list ap; + +#if (0) + RWFUNCTION(RWSTRING("rwPLUGIN_ERRFUNC")); +#endif /* (0) */ + + va_start(ap, code); + + rwstrcpy(dberr, rw_err_cstr[code]); + rwstrcat(dberr, RWSTRING(" : ")); + rwvsprintf(&dberr[rwstrlen(dberr)], rw_err_str[code], ap); + va_end(ap); + return dberr; +} + +#endif /* RWDEBUG */ + diff --git a/rwsdk/include/d3d8/rpdbgerr.h b/rwsdk/include/d3d8/rpdbgerr.h new file mode 100644 index 00000000..6918469a --- /dev/null +++ b/rwsdk/include/d3d8/rpdbgerr.h @@ -0,0 +1,278 @@ +/*************************************************************************** + * * + * Module : badebug.h * + * * + * Purpose : Debug handling * + * * + **************************************************************************/ + +#ifndef RWDEBUG_H +#define RWDEBUG_H + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) +#if (defined(_MSC_VER)) +#if (_MSC_VER>=1000) + +/* Pick up _ASSERTE macro */ +#ifdef _XBOX +#include +#else /* _XBOX */ +#include +#endif /* _XBOX */ +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#undef RWASSERTE +#define RWASSERTE(_condition) _ASSERTE(_condition) +#endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#if (!defined(RWASSERTE)) +#define RWASSERTE(_condition) /* No-Op */ +#endif /* (!defined(RWASSERTE)) */ + +#if (!defined(RWPENTER)) +#define RWPENTER(_func) /* No-Op */ +#endif /* (!defined(RWPENTER)) */ + +#if (!defined(RWPEXIT)) +#define RWPEXIT(_func) /* No-Op */ +#endif /* (!defined(RWPEXIT)) */ + +/**************************************************************************** + Includes + */ + +#include + +#include "rpplugin.h" + +/**************************************************************************** + Defines + */ + +#ifdef RWDEBUG + +#if (!(defined(RWDEBUGSTACKDEPTH))) +#define RWDEBUGSTACKDEPTH (RWSRCGLOBAL(debugStackDepth)) +#endif /* (!(defined(RWDEBUGSTACKDEPTH))) */ + +/* Message macros */ + +#ifdef RWTRACE + +/* Note RWTRACE should only be defined for internal builds. It should + * also only be used rarely. It will cause the generation of Trace + * messages for all functions. Not just those directly called from + * the application + */ + +#define RWAPIFUNCTION(function) \ +static const RwChar __dbFunctionName[] = function; \ +const RwInt32 startstackdepth = RWDEBUGSTACKDEPTH++; \ +RWPENTER(__dbFunctionName); \ +if (RWSRCGLOBAL(debugTrace)) \ +{ \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, \ + _rwdbsprintf("Enter %s [Depth %d]", \ + (startstackdepth)?"SPI":"API", \ + (int)startstackdepth)); \ +} + +#define RWFUNCTION(function) RWAPIFUNCTION(function) + +#define RWRETURN(result) \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon(E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return (result); \ +} \ +while (0) + +#define RWRETURNVOID() \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon (E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return; \ +} \ +while(0) + +#else /* RWTRACE */ + +#define RWAPIFUNCTION(function) \ +static const RwChar __dbFunctionName[] = function; \ +const RwInt32 startstackdepth = RWDEBUGSTACKDEPTH++; \ +RWPENTER(__dbFunctionName); \ +if (RWSRCGLOBAL(debugTrace) && !startstackdepth) \ +{ \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Enter")); \ +} + +#define RWFUNCTION(function) RWAPIFUNCTION(function) + +#define RWRETURN(result) \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon(E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace) && (!startstackdepth)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return (result); \ +} \ +while (0) + +#define RWRETURNVOID() \ +do \ +{ \ + RwInt32 _validateStackDepth = --RWDEBUGSTACKDEPTH; \ + if (_validateStackDepth != startstackdepth) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon (E_RW_DEBUGSTACK)); \ + RWDEBUGSTACKDEPTH = startstackdepth; \ + } \ + if (RWSRCGLOBAL(debugTrace) && (!startstackdepth)) \ + { \ + RwDebugSendMessage(rwDEBUGTRACE, \ + __dbFunctionName, RWSTRING("Exit")); \ + } \ + RWASSERTE(_validateStackDepth == startstackdepth); \ + RWPEXIT(__dbFunctionName); \ + return; \ +} \ +while(0) + +#endif /* RWTRACE */ + +#define RWERROR(ecode) \ +do \ +{ \ + RwError _rwErrorCode; \ + \ + _rwErrorCode.pluginID = rwPLUGIN_ID; \ + _rwErrorCode.errorCode = _rwerror ecode; \ + \ + RwErrorSet(&_rwErrorCode); \ + \ + if (_rwErrorCode.errorCode & 0x80000000) \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + _rwdberrcommon ecode); \ + } \ + else \ + { \ + RwDebugSendMessage(rwDEBUGERROR, \ + __dbFunctionName, \ + rwPLUGIN_ERRFUNC ecode); \ + } \ +} \ +while(0); + +#define RWMESSAGE(args) \ +do \ +{ \ + RwDebugSendMessage(rwDEBUGMESSAGE, \ + __dbFunctionName, \ + _rwdbsprintf args); \ +} \ +while (0) + +#define RWASSERT(condition) \ +do \ +{ \ + if (!(condition)) \ + { \ + RwDebugSendMessage(rwDEBUGASSERT, \ + __dbFunctionName, \ + RWSTRING(#condition)); \ + } \ + RWASSERTE(condition); \ +} \ +while (0) + +#else /* RWDEBUG */ + +#define RWRETURN(value) return(value) +#define RWRETURNVOID() return +#define RWERROR(errorcode) \ +do \ +{ \ + RwError _rwErrorCode; \ + \ + _rwErrorCode.pluginID = rwPLUGIN_ID; \ + _rwErrorCode.errorCode = _rwerror errorcode; \ + \ + RwErrorSet(&_rwErrorCode); \ +} \ +while (0) +#define RWFUNCTION(name) +#define RWAPIFUNCTION(name) +#define RWASSERT(condition) +#define RWMESSAGE(args) + +#endif + +#define RWVALIDATEDEBUGSTACKDEPTH() \ + RWASSERT(1 == (RWDEBUGSTACKDEPTH - startstackdepth)) + +/**************************************************************************** + Functions + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +RwChar *rwPLUGIN_ERRFUNC(RwInt32 code, ...); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWDEBUG_H */ diff --git a/rwsdk/include/d3d8/rpdmorph.h b/rwsdk/include/d3d8/rpdmorph.h new file mode 100644 index 00000000..1494bf3d --- /dev/null +++ b/rwsdk/include/d3d8/rpdmorph.h @@ -0,0 +1,311 @@ +/***************************************************************************** + * + * File : rpdmorph.h + * + * Abstract : DeltaMorph plugin for Renderware. + * + ***************************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2000 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + *****************************************************************************/ + +#ifndef RPDMORPH_H +#define RPDMORPH_H + +/** + * \defgroup rpdmorph RpDMorph + * \ingroup rpplugin + * \file rpdmorph.h + * + * Delta Morphing Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ +#include +#include + +#include "rpdmorph.rpe" /* automatically generated header file */ + + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ + +/** + * \ingroup rpdmorph + * \struct RpDMorphTarget + * Delta morph target object for defining a target for + * a base geometry. + * This should be considered an opaque type. + * Use the RpDMorphGeometry and RpDMorphTarget API + * functions to access. + */ +typedef struct RpDMorphTarget RpDMorphTarget; + +/** + * \ingroup rpdmorph + * \struct RpDMorphAnimation + * Contains frame sequences for animating delta + * morph target objects. + * This should be considered an opaque type. + * Use the RpDMorphAnimation API + * functions to access. + */ +typedef struct RpDMorphAnimation RpDMorphAnimation; + +#define rpDMORPHNULLFRAME ((RwUInt32)~0) + +/*===========================================================================* + *--- Global variables ------------------------------------------------------* + *===========================================================================*/ + +extern RwModuleInfo rpDMorphModule; + +/*===========================================================================* + *--- Plugin API Functions --------------------------------------------------* + *===========================================================================*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/*--- DMorphPlugin functions ------------------------------------------------*/ +extern RwBool +RpDMorphPluginAttach( void ); + +/*--- DMorphGeometry functions ---------------------------------------------- + * + * These functios work on the DMorphGeometry level. + * Each DMorphGeometry has a list of DMorphTargets. + */ +extern RpGeometry * +RpDMorphGeometryCreateDMorphTargets( RpGeometry *geometry, + RwUInt32 number ); + +extern RpGeometry * +RpDMorphGeometryDestroyDMorphTargets( RpGeometry *geometry ); + +extern RpGeometry * +RpDMorphGeometryAddDMorphTarget( RpGeometry *geometry, + RwUInt32 index, + RwV3d *vertices, + RwV3d *normals, + RwRGBA *preLightColors, + RwTexCoords *texCoords, + RwUInt32 flags ); + +extern RpGeometry * +RpDMorphGeometryRemoveDMorphTarget( RpGeometry *geometry, + RwUInt32 index ); + +extern RpDMorphTarget * +RpDMorphGeometryGetDMorphTarget( const RpGeometry *geometry, + RwUInt32 index ); + +extern RwUInt32 +RpDMorphGeometryGetNumDMorphTargets( const RpGeometry *geometry ); + +extern RpGeometry * +RpDMorphGeometryTransformDMorphTargets( RpGeometry *geometry, + const RwMatrix *matrix ); + +/*--- DMorphTarget functions ------------------------------------------------ + * + * These functios work on the DMorphGeometry level. + * Each DMorphGeometry has a list of DMorphTargets. + */ + +extern const RwSphere * +RpDMorphTargetGetBoundingSphere( const RpDMorphTarget *dMorphTarget ); + +extern RpDMorphTarget * +RpDMorphTargetSetName( RpDMorphTarget *dMorphTarget, + RwChar *name ); + +extern RwChar * +RpDMorphTargetGetName( RpDMorphTarget *dMorphTarget ); + +extern RpGeometryFlag +RpDMorphTargetGetFlags( RpDMorphTarget *dMorphTarget ); + + +/*--- ANIMATION SYSTEM ------------------------------------------------------ + */ + +/*--- DMorphAtomic functions ------------------------------------------------ + * + * These functions work at the DMorphAtomic level. + */ +extern RpAtomic * +RpDMorphAtomicInitalize( RpAtomic *atomic ); + +extern RwReal * +RpDMorphAtomicGetDMorphValues( RpAtomic *atomic ); + +extern RpAtomic * +RpDMorphAtomicSetAnimation( RpAtomic *atomic, + RpDMorphAnimation *animation ); + +extern RpDMorphAnimation * +RpDMorphAtomicGetAnimation( const RpAtomic *atomic ); + +extern RpAtomic * +RpDMorphAtomicAddTime( RpAtomic *atomic, + RwReal time ); + +extern RwReal +RpDMorphAtomicGetAnimTime( const RpAtomic *atomic ); + +extern RpAtomic * +RpDMorphAtomicSetAnimLoopCallBack( RpAtomic *atomic, + RpAtomicCallBack callBack, + void *data ); + +extern RpAtomicCallBack +RpDMorphAtomicGetAnimLoopCallBack( const RpAtomic *atomic, + void **callBackData ); + +extern RpAtomic * +RpDMorphAtomicSetAnimFrame( RpAtomic *atomic, + RwUInt32 dMorphTargetIndex, + RwUInt32 index ); + +extern RwUInt32 +RpDMorphAtomicGetAnimFrame( const RpAtomic *atomic, + RwUInt32 dMorphTargetIndex ); + + +extern RpAtomic * +RpDMorphAtomicSetAnimFrameTime( RpAtomic *atomic, + RwUInt32 dMorphTargetIndex, + RwReal time ); + +extern RwReal +RpDMorphAtomicGetAnimFrameTime( const RpAtomic *atomic, + RwUInt32 dMorphTargetIndex ); + +/*--- Animation Functions -------------------------------------------------- + */ +extern RpDMorphAnimation * +RpDMorphAnimationCreate(RwUInt32 numDMorphTargets); + +extern RpDMorphAnimation * +RpDMorphAnimationDestroy(RpDMorphAnimation *anim); + +extern RwUInt32 +RpDMorphAnimationGetNumDMorphTargets(RpDMorphAnimation *animation); + +/* Animation Frames */ +extern RpDMorphAnimation * +RpDMorphAnimationCreateFrames(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 numFrames); + +extern RpDMorphAnimation * +RpDMorphAnimationDestroyFrames(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex); + +extern RwUInt32 +RpDMorphAnimationGetNumFrames(RpDMorphAnimation *animation, + RwUInt32 dMorphTargetIndex); + +/* Stream I/O */ +extern RpDMorphAnimation * +RpDMorphAnimationStreamRead(RwStream *stream); + +extern RpDMorphAnimation * +RpDMorphAnimationStreamWrite(RpDMorphAnimation *animation, + RwStream *stream); + +extern RwUInt32 +RpDMorphAnimationStreamGetSize(RpDMorphAnimation *animation); + +extern RpDMorphAnimation * +RpDMorphAnimationRead(const RwChar *filename); + +extern RpDMorphAnimation * +RpDMorphAnimationWrite(RpDMorphAnimation *animation, const RwChar *filename); + +/*--- Animation Frame Functions -------------------------------------------- + * + * These functions work on the DMorphAnimationFrame level. + * Each Frame can have a reference to the next Frame for the + * DMorphTarget. + */ +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetNext(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwUInt32 nextFrame ); + +extern RwUInt32 +RpDMorphAnimationFrameGetNext(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSet(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal startValue, + RwReal endValue, + RwReal duration, + RwUInt32 nextFrame ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetStartValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal startValue ); + +extern RwReal +RpDMorphAnimationFrameGetStartValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetEndValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal endValue ); + +extern RwReal +RpDMorphAnimationFrameGetEndValue(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +extern RpDMorphAnimation * +RpDMorphAnimationFrameSetDuration(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex, + RwReal duration ); + +extern RwReal +RpDMorphAnimationFrameGetDuration(RpDMorphAnimation *anim, + RwUInt32 dMorphTargetIndex, + RwUInt32 frameIndex ); + +/*--------------------------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPDMORPH_H */ + diff --git a/rwsdk/include/d3d8/rpdmorph.rpe b/rwsdk/include/d3d8/rpdmorph.rpe new file mode 100644 index 00000000..a5202425 --- /dev/null +++ b/rwsdk/include/d3d8/rpdmorph.rpe @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionDMorph +{ + + + + e_rwdb_CriterionDMorphLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionDMorph e_rwdb_CriterionDMorph; + + diff --git a/rwsdk/include/d3d8/rperror.h b/rwsdk/include/d3d8/rperror.h new file mode 100644 index 00000000..2a8c5630 --- /dev/null +++ b/rwsdk/include/d3d8/rperror.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * * + * Module : rperror.h * + * * + * Purpose : Used to generate error codes * + * * + **************************************************************************/ + +#ifndef RPERROR_H +#define RPERROR_H + +/**************************************************************************** + Includes + */ + +#include "rpplugin.h" + +/**************************************************************************** + Defines + */ + +#define RWECODE(a,b) a, + +enum rwPLUGIN_ERRENUM +{ +#include "rperror.def" + rwPLUGIN_ERRENUMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum rwPLUGIN_ERRENUM rwPLUGIN_ERRENUM; + +#endif /* RPERROR_H */ diff --git a/rwsdk/include/d3d8/rphanim.h b/rwsdk/include/d3d8/rphanim.h new file mode 100644 index 00000000..a9b0438a --- /dev/null +++ b/rwsdk/include/d3d8/rphanim.h @@ -0,0 +1,873 @@ +/****************************************** + * * + * RenderWare(TM) Graphics Library * + * * + ******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + +/*************************************************************************** + * * + * Module : rpanim.h * + * * + * Purpose : Hierarchical animation * + * * + **************************************************************************/ + +#ifndef RPHANIM_H +#define RPHANIM_H + +/** + * Hierarchal animation plugin + */ + +/* Doxygen plugin groups. */ + +/** + * \defgroup rphanim RpHAnim + * \ingroup rpplugin + * + * Hierarchical Animation Plugin for RenderWare Graphics. + */ + +/** + * \defgroup rphanimchanges RpHAnim Changes + * \ingroup rphanim + * + */ + +/**************************************************************************** + Includes + */ + +#include +#include +#include + +#include +#include + +#include /* Note: each vendor can choose their own method for + * allocation of unique ID's. This file defines + * the ID's used by Criterion. + */ +#include /* automatically generated header file */ +#include + +#define rpHANIMSTREAMCURRENTVERSION 0x100 + +/** + * \ingroup rphanim + * \ref RpHAnimAtomicGlobalVars typedef for struct RpHAnimAtomicGlobalVars + */ +typedef struct RpHAnimAtomicGlobalVars RpHAnimAtomicGlobalVars; + +/** + * \ingroup rphanim + * \struct RpHAnimAtomicGlobalVars + */ +struct RpHAnimAtomicGlobalVars +{ + RwInt32 engineOffset ; /* Offset into global data */ + RwFreeList *HAnimFreeList; + RwFreeList *HAnimAnimationFreeList; +}; + +extern RpHAnimAtomicGlobalVars RpHAnimAtomicGlobals; + +#define rpHANIMSTDKEYFRAMESIZE sizeof(RpHAnimStdKeyFrame) +#define rpHANIMSTDKEYFRAMETYPEID 0x1 + +#define RwAnimMalloc() \ + RwFreeListAlloc(RpHAnimAtomicGlobals.HAnimFreeList) + +#define RwAnimFree(_anim) \ + RwFreeListFree(RpHAnimAtomicGlobals.HAnimFreeList, (_anim)) + +#define RwAnimAnimationMalloc() \ + RwFreeListAlloc(RpHAnimAtomicGlobals.HAnimAnimationFreeList) + +#define RwAnimAnimationFree(_animAnimation) \ + RwFreeListFree(RpHAnimAtomicGlobals.HAnimAnimationFreeList, \ + (_animAnimation)) + +#define RpV3dInterpolate(o, a, s, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ((s)) * (((b)->x) - ((a)->x))); \ + (o)->y = (((a)->y) + ((s)) * (((b)->y) - ((a)->y))); \ + (o)->z = (((a)->z) + ((s)) * (((b)->z) - ((a)->z))); \ +} \ +MACRO_STOP + +/** + * \ingroup rphanim + * \ref RpHAnimHierarchy typedef for struct RpHAnimHierarchy + */ +typedef struct RpHAnimHierarchy RpHAnimHierarchy; + +/** + * \ingroup rphanim + * \ref RpHAnimAnimation typedef for struct RpHAnimAnimation + */ +typedef struct RpHAnimAnimation RpHAnimAnimation; + +/** + * \ingroup rphanim + * \ref RpHAnimHierarchyCallBack + * This typedef defines a callback function for use with the + * \ref RpHAnimHierarchySetAnimCallBack and + * \ref RpHAnimHierarchySetAnimLoopCallBack functions. + * + * \param hierarchy + * A pointer to the AnimHierarchy structure. + * + * \param data User-defined data. + * You can use this to pass your own data + * structure(s) to the callback function. + * + * \see RpHAnimHierarchySetAnimCallBack + * \see RpHAnimHierarchySetAnimLoopCallBack + * + */ + +typedef RpHAnimHierarchy * (*RpHAnimHierarchyCallBack) (RpHAnimHierarchy *hierarchy, + void *data); + +/* + * The following CallBacks are needed for each overloaded interpolation + * scheme. See RpHAnimInterpolatorInfo. + */ + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameToMatrixCallBack + * This typedef defines a callback function for converting + * an animation keyframe into a modeling matrix. The output matrix will be + * used to construct the array of world or local space matrices for the + * hierarchy as obtained with \ref RpHAnimHierarchyGetMatrixArray, and + * possibly used for updating an external \ref RwFrame hierarchy. + * + * \param matrix This is the matrix to store the output of the conversion + * \param voidIFrame This is a void pointer to the keyframe and should be cast + * to the keyframe type this callback is for. + */ +typedef void (*RpHAnimKeyFrameToMatrixCallBack) (RwMatrix *matrix, void *voidIFrame); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameBlendCallBack + * This typedef defines a callback function for blending between two animation + * keyframes by the given blend factor. + * + * \param voidOut This is the void pointer for the output of the blend + * \param voidIn1 First input keyframe + * \param voidIn2 Second input keyframe + * \param alpha Blend factor + */ +typedef void (*RpHAnimKeyFrameBlendCallBack) (void *voidOut, void *voidIn1, + void *voidIn2, RwReal alpha); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameInterpolateCallBack + * This typedef defines a callback function for interpolating between two + * animation keyframes according to the given time. + * + * \param voidOut This is the void pointer for the output of the + * interpolation + * \param voidIn1 First input keyframe + * \param voidIn2 Second input keyframe + * \param time Time at which to interpolate + */ +typedef void (*RpHAnimKeyFrameInterpolateCallBack) (void *voidOut, void *voidIn1, + void *voidIn2, RwReal time); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameAddCallBack + * This typedef defines a callback function for adding together two animation + * keyframes. One of the keyframes would usually be a delta. + * + * \param voidOut This is the void pointer for the output summed keyframe + * \param voidIn1 First input keyframe + * \param voidIn2 Second input keyframe + */ +typedef void (*RpHAnimKeyFrameAddCallBack) (void *voidOut, void *voidIn1, + void *voidIn2); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameMulRecipCallBack + * This typedef defines a callback function for multiplying a keyframe + * by the inverse of another keyframe + * + * \param voidFrame This is the void pointer for the keyframe to be modified + * \param voidStart First start keyframe to take the reciprocal of. + */ +typedef void (*RpHAnimKeyFrameMulRecipCallBack) (void *voidFrame, void *voidStart); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameStreamReadCallBack + * This typedef defines a callback function for reading in keyframes + * from an \ref RwStream for the given animation. + * + * \param stream The stream to read the keyframes from + * \param animation The animation to read the keyframes into + * + * \return Pointer to the animation. + */ +typedef RpHAnimAnimation * (*RpHAnimKeyFrameStreamReadCallBack) (RwStream *stream, RpHAnimAnimation *animation); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameStreamWriteCallBack + * This typedef defines a callback function for writing keyframes from the + * given animation to an \ref RwStream. + * + * \param animation The animation to write out from + * \param stream The stream to write the keyframes to + * + * \return TRUE if successful. + */ +typedef RwBool (*RpHAnimKeyFrameStreamWriteCallBack) (RpHAnimAnimation *animation, RwStream *stream); + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameStreamGetSizeCallBack + * This typedef defines a callback function for calculating the binary stream + * size of keyframe data within an animation. + * + * \param animation The animation to calculate sizes of + * + * \return Size in bytes of the keyframe data. + */ +typedef RwInt32 (*RpHAnimKeyFrameStreamGetSizeCallBack) (RpHAnimAnimation *animation); + +/** + * \ingroup rphanim + * \ref RpHAnimInterpolatorInfo + * typedef for struct \ref RpHAnimInterpolatorInfo + */ +typedef struct RpHAnimInterpolatorInfo RpHAnimInterpolatorInfo; + +/** + * \ingroup rphanim + * \struct RpHAnimInterpolatorInfo + * This is used to hold information for a keyframe interpolation scheme. + * + * \see RpHAnimRegisterInterpolationScheme + * \see RpHAnimGetInterpolatorInfo + */ +struct RpHAnimInterpolatorInfo +{ + RwInt32 typeID; /**< The ID of the interpolation scheme */ + RwInt32 keyFrameSize; /**< Size in bytes of the keyframe structure */ + RpHAnimKeyFrameToMatrixCallBack keyFrameToMatrixCB; /**< Pointer to a function that converts a keyframe to a matrix */ + RpHAnimKeyFrameBlendCallBack keyFrameBlendCB; /**< Pointer to a function that blends between a pair of keyframes for a given delta value */ + RpHAnimKeyFrameInterpolateCallBack keyFrameInterpolateCB; /**< Pointer to a function that interpolates between two keyframes for a given time in between */ + RpHAnimKeyFrameAddCallBack keyFrameAddCB; /**< Pointer to a function that adds two keyframes (one of which may be a delta) */ + RpHAnimKeyFrameMulRecipCallBack keyFrameMulRecipCB; /**< Pointer to a function that multiplies a keyframe by the reciprocal of another */ + RpHAnimKeyFrameStreamReadCallBack keyFrameStreamReadCB; /**< Pointer to a function that reads the keyframes from a stream for a given animation */ + RpHAnimKeyFrameStreamWriteCallBack keyFrameStreamWriteCB; /**< Pointer to a function that writes the keyframes to a stream for a given animation */ + RpHAnimKeyFrameStreamGetSizeCallBack keyFrameStreamGetSizeCB; /**< Pointer to a function that returns the binary stream size of the keyframes for a given animation */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimKeyFrameHeader + * typedef for struct RpHAnimKeyFrameHeader + */ +typedef struct RpHAnimKeyFrameHeader RpHAnimKeyFrameHeader; + +/** + * \ingroup rphanim + * \struct RpHAnimKeyFrameHeader + * Holds header information for a keyframe. All keyframe structures used with + * the overloadable interpolation system should start with this data. + * + * \see RpHAnimStdKeyFrame + * \see RpHAnimRegisterInterpolationScheme + */ +struct RpHAnimKeyFrameHeader +{ + void *prevFrame; /**< Previous keyframe for particular hierarchy node */ + RwReal time; /**< Time at keyframe */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimStdKeyFrame + * typedef for struct RpHAnimStdKeyFrame + */ +typedef struct RpHAnimStdKeyFrame RpHAnimStdKeyFrame; + +/** + * \ingroup rphanim + * \struct RpHAnimStdKeyFrame + * A structure representing the standard keyframe data. Sequences of + * such keyframes in an \ref RpHAnimAnimation defines the animation of each + * node in a hierarchy. + */ +struct RpHAnimStdKeyFrame +{ + RpHAnimStdKeyFrame *prevFrame; /**< Previous keyframe for particular hierarchy node */ + RwReal time; /**< Time at keyframe */ + RtQuat q; /**< Quaternion rotation at keyframe */ + RwV3d t; /**< Translation at keyframe */ +}; + +/* Flags for FrameInfos */ + +#define rpHANIMPOPPARENTMATRIX 0x01 +#define rpHANIMPUSHPARENTMATRIX 0x02 + +/** + * \ingroup rphanim + * \ref RpHAnimNodeInfo + * typedef for struct RpHAnimNodeInfo + */ +typedef struct RpHAnimNodeInfo RpHAnimNodeInfo; + +/** + * \ingroup rphanim + * \struct RpHAnimNodeInfo + * + */ +struct RpHAnimNodeInfo +{ + RwInt32 nodeID; /**< User defined ID for this node */ + RwInt32 nodeIndex; /**< Array index of node */ + RwInt32 flags; /**< Matrix push/pop flags */ + RwFrame * pFrame; /**< Pointer to an attached RwFrame (see \ref RpHAnimHierarchyAttach) */ +}; + +/** + * \ingroup rphanim + * \struct RpHAnimAnimation + * A hierarchical animation consists of an array of keyframe structures, + * along with some flags and a duration. + * + * The keyframes should be presented in the order they are needed + * to animate forwards through time. Pointers link all of the keyframes + * for a particular node backwards through time in a list. + * + * For example, a 3 node animation, with keyframes at the following times: + * + * Node 1: 0.0, 1.0, 2.0, 3.0 + * Node 2: 0.0, 3.0 + * Node 3: 0.0, 2.0, 2.5, 3.0 + * + * should be formatted in an RpHAnimAnimation animation like this: + * + * B1,0.0 B2,0.0 B3,0.0 B1,1.0, B2,3.0, B3,2.0, B1,2.0, B1,3.0, B3,2.5 B3,3.0 + * + * Each node MUST start at time = 0.0, and each node must terminate with a keyframe + * at time = duration of animation. + * + * \see RpHAnimAnimationCreate + */ +struct RpHAnimAnimation +{ + RpHAnimInterpolatorInfo *interpInfo; /**< Pointer to interpolation scheme information */ + RwInt32 numFrames; /**< Number of keyframes in the animation */ + RwInt32 flags; /**< Specifies details about animation, relative translation modes etc */ + RwReal duration; /**< Duration of animation in seconds */ + void *pFrames; /**< Pointer to the animation keyframes */ +}; + +/** + * \ingroup rphanim + * \ref RpHAnimHierarchyFlag defines type and update modes in HAnimHierarchies + * + * \see RpAnimHierarchyFlag + */ +enum RpHAnimHierarchyFlag +{ + /* creation flags */ + rpHANIMHIERARCHYSUBHIERARCHY = 0x01, /**< This hierarchy is a sub-hierarchy */ + rpHANIMHIERARCHYNOMATRICES = 0x02, /**< This hierarchy has no local matrices */ + + /* update flags */ + rpHANIMHIERARCHYUPDATEMODELLINGMATRICES = 0x1000, /**< This hierarchy updates modeling matrices */ + rpHANIMHIERARCHYUPDATELTMS = 0x2000, /**< This hierarchy updates LTMs */ + rpHANIMHIERARCHYLOCALSPACEMATRICES = 0x4000, /**< This hierarchy calculates matrices in a space + relative to its root */ + + rpHANIMHIERARCHYFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/** + * \ingroup rphanim + * \typedef RpHAnimHierarchyFlag + * These flags are used to control the creation and + * update status of the hierarchy + */ +typedef enum RpHAnimHierarchyFlag RpHAnimHierarchyFlag; + +/** + * \ingroup rphanim + * \struct RpHAnimHierarchy + * An RpHAnimHierarchy is used to "play back" an animation - it holds the + * interpolated keyframe data for the current state of an animation + * concatenated on the end of the structure. + * + * The rpHANIMHIERARCHYGETINTERPFRAME() macro can be used to access the current + * interpolated data, for the current time or to write to this data to override + * it with procedural animation. + * + * The structure of a hierarchy is defined by an array + * of \ref RpHAnimNodeInfo structures. + * + * The hierarchy is defined by running through the node array in order, + * pushing the parent-node's matrix whenever a child is reached that has + * more than one sibling, and popping the parent matrix when a "leaf" + * node is encountered. + * + */ +struct RpHAnimHierarchy +{ + RwInt32 flags; /**< Flags for the hierarchy */ + RwInt32 numNodes; /**< Number of nodes in the hierarchy */ + RpHAnimAnimation *pCurrentAnim; /**< Current animation applied to hierarchy */ + RwReal currentTime; /**< Current animation time */ + void *pNextFrame; /**< Next animation keyframe to be played */ + RpHAnimHierarchyCallBack pAnimCallBack; /**< Animation callback function pointer */ + void *pAnimCallBackData; /**< Animation callback function user data */ + RwReal animCallBackTime; /**< Trigger time for callback function */ + RpHAnimHierarchyCallBack pAnimLoopCallBack; /**< Animation loop callback function pointer */ + void *pAnimLoopCallBackData; /**< Animation loop callback function data */ + RwMatrix *pMatrixArray; /**< Pointer to node matrices*/ + void *pMatrixArrayUnaligned; /**< Pointer to memory used for node matrices + * from which the aligned pMatrixArray is allocated */ + RpHAnimNodeInfo *pNodeInfo; /**< Array of node information (push/pop flags etc) */ + RwFrame *parentFrame; /**< Pointer to the Root RwFrame of the hierarchy this + * RpHAnimHierarchy represents */ + RwInt32 maxKeyFrameSize; /**< Maximum size of keyframes usable on this hierarhcy + * (set at creation time) */ + RwInt32 currentKeyFrameSize; /**< Size of keyframes in the current animation */ + RpHAnimKeyFrameToMatrixCallBack keyFrameToMatrixCB; /**< Internal use */ + RpHAnimKeyFrameBlendCallBack keyFrameBlendCB; /**< Internal use */ + RpHAnimKeyFrameInterpolateCallBack keyFrameInterpolateCB; /**< Internal use */ + RpHAnimKeyFrameAddCallBack keyFrameAddCB; /**< Internal use */ + RpHAnimHierarchy *parentHierarchy; /**< Internal use */ + RwInt32 offsetInParent; /**< Internal use */ + RwInt32 rootParentOffset; /**< Internal use */ +}; + +#define rpHANIMHIERARCHYGETINTERPFRAME( hierarchy, nodeIndex ) \ + ( (void *)( ( (RwUInt8 *)&(hierarchy[1]) + \ + ((nodeIndex) * \ + hierarchy->currentKeyFrameSize) ) ) ) + +#define rpHANIMHIERARCHYGETINTERPFRAME1( hierarchy, nodeIndex ) \ + ( (void *)( ( (RwUInt8 *)&(hierarchy[1]) + \ + ((hierarchy->numNodes + \ + (nodeIndex)) * \ + hierarchy->currentKeyFrameSize) ) ) ) + +#define rpHANIMHIERARCHYGETINTERPFRAME2( hierarchy, nodeIndex ) \ + ( (void *)( ( (RwUInt8 *)&(hierarchy[1]) + \ + ((hierarchy->numNodes * 2 + \ + (nodeIndex)) * \ + hierarchy->currentKeyFrameSize) ) ) ) + +/** + * \ingroup rphanim + * \ref RpHAnimFrameExtension typedef for struct RpHAnimFrameExtension + */ + +typedef struct RpHAnimFrameExtension RpHAnimFrameExtension; + +/** + * \ingroup rphanim + * \struct RpHAnimFrameExtension + */ +struct RpHAnimFrameExtension +{ + RwInt32 id; /**< ID given to this RwFrame (default of -1) */ + RpHAnimHierarchy *hierarchy; /**< Pointer to Animation hierarchy attached to this RwFrame */ +}; + +/*--- Plugin API Functions ---*/ + +#define RpHAnimHierarchySetFlagsMacro(hierarchy, _flags) \ +MACRO_START \ +{ \ + (hierarchy)->flags = _flags; \ +} \ +MACRO_STOP + +#define RpHAnimHierarchyGetFlagsMacro(hierarchy) \ + ((hierarchy)->flags) + +#define RpHAnimStdKeyFrameToMatrixMacro(_matrix, _voidIFrame) \ +MACRO_START \ +{ \ + RpHAnimStdKeyFrame * iFrame = (RpHAnimStdKeyFrame *)(_voidIFrame); \ + \ + /* \ + * RpHAnim uses the same types of quaternion as RtQuat \ + * hence no conjugate call as in RpSkin \ + */ \ + \ + RtQuatUnitConvertToMatrix(&iFrame->q, (_matrix)); \ + \ + (_matrix)->pos.x = iFrame->t.x; \ + (_matrix)->pos.y = iFrame->t.y; \ + (_matrix)->pos.z = iFrame->t.z; \ +} \ +MACRO_STOP + + +#if (! defined(RWDEBUG)) + +#define RpHAnimHierarchySetFlags(hierarchy, _flags) \ + RpHAnimHierarchySetFlagsMacro(hierarchy, _flags) + +#define RpHAnimHierarchyGetFlags(hierarchy) \ + (RpHAnimHierarchyFlag)RpHAnimHierarchyGetFlagsMacro(hierarchy) + +#endif /* (! defined(RWDEBUG)) */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#if (defined(RWDEBUG)) + +extern RpHAnimHierarchy * +RpHAnimHierarchySetFlags(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyFlag flags); + +extern RpHAnimHierarchyFlag +RpHAnimHierarchyGetFlags(RpHAnimHierarchy *hierarchy); + +#endif /* (defined(RWDEBUG)) */ + +/* Keyframe Interpolator Types */ + +extern RwBool +RpHAnimRegisterInterpolationScheme(RpHAnimInterpolatorInfo *interpolatorInfo); + +extern RpHAnimInterpolatorInfo * +RpHAnimGetInterpolatorInfo(RwInt32 typeID); + +/* Animation hierarchy creation */ + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreate(RwInt32 numNodes, + RwUInt32 *nodeFlags, + RwInt32 *nodeIDs, + RpHAnimHierarchyFlag flags, + RwInt32 maxKeyFrameSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreateFromHierarchy(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyFlag flags, + RwInt32 maxKeyFrameSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDestroy(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyCreateSubHierarchy(RpHAnimHierarchy *parentHierarchy, + RwInt32 startNode, + RpHAnimHierarchyFlag flags, + RwInt32 maxKeyFrameSize); + +extern RpHAnimHierarchy * +RpHAnimHierarchyAttach(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDetach(RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimHierarchyAttachFrameIndex(RpHAnimHierarchy *hierarchy, + RwInt32 nodeIndex); + +extern RpHAnimHierarchy * +RpHAnimHierarchyDetachFrameIndex(RpHAnimHierarchy *hierarchy, + RwInt32 nodeIndex); + +extern RwBool +RpHAnimFrameSetHierarchy(RwFrame *frame, + RpHAnimHierarchy *hierarchy); + +extern RpHAnimHierarchy * +RpHAnimFrameGetHierarchy(RwFrame *frame); + +/* Macros for legacy support of old function names */ +#define RpHAnimSetHierarchy(frame, hierarchy) \ + RpHAnimFrameSetHierarchy(frame, hierarchy) +#define RpHAnimGetHierarchy(frame) RpHAnimFrameGetHierarchy(frame) + +extern RwBool +RpHAnimHierarchySetKeyFrameCallBacks(RpHAnimHierarchy *hierarchy, + RwInt32 keyFrameTypeID); + +extern RwBool +RpHAnimHierarchySetCurrentAnim(RpHAnimHierarchy *hierarchy, + RpHAnimAnimation *anim); + +extern RwBool +RpHAnimHierarchySetCurrentAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchySubAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchyStdKeyFrameAddAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RwBool +RpHAnimHierarchyAddAnimTime(RpHAnimHierarchy *hierarchy, + RwReal time); + +extern RpHAnimHierarchy * +RpHAnimHierarchySetAnimCallBack(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyCallBack callBack, + RwReal time, + void *data ); + +extern RpHAnimHierarchy * +RpHAnimHierarchySetAnimLoopCallBack(RpHAnimHierarchy *hierarchy, + RpHAnimHierarchyCallBack callBack, + void *data ); + +extern RwMatrix * +RpHAnimHierarchyGetMatrixArray(RpHAnimHierarchy *hierarchy); + +extern RwBool +RpHAnimHierarchyUpdateMatrices(RpHAnimHierarchy *hierarchy); + +/* Macro for legacy support of old function name */ +#define RpHAnimUpdateHierarchyMatrices RpHAnimHierarchyUpdateMatrices + +extern RwInt32 +RpHAnimIDGetIndex(RpHAnimHierarchy *hierarchy, + RwInt32 ID); + +/* Animations */ + +extern RpHAnimAnimation * +RpHAnimAnimationCreate(RwInt32 typeID, + RwInt32 numFrames, + RwInt32 flags, + RwReal duration); + +extern RpHAnimAnimation * +RpHAnimAnimationDestroy(RpHAnimAnimation *animation); + +#ifdef RWDEBUG + +extern RwInt32 +RpHAnimAnimationGetTypeID(RpHAnimAnimation *animation); + +#else /* RWDEBUG */ + +#define RpHAnimAnimationGetTypeID(animation) \ + (animation->interpInfo->typeID) + +#endif /* RWDEBUG */ + +extern RpHAnimAnimation * +RpHAnimAnimationRead(const RwChar * filename); + +extern RwBool +RpHAnimAnimationWrite(RpHAnimAnimation *animation, + const RwChar * filename); + +extern RpHAnimAnimation * +RpHAnimAnimationStreamRead(RwStream *stream); + +extern RwBool +RpHAnimAnimationStreamWrite(RpHAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RpHAnimAnimationStreamGetSize(RpHAnimAnimation *animation); + +extern RwBool +RpHAnimAnimationMakeDelta(RpHAnimAnimation *animation, + RwInt32 numNodes, + RwReal time); + +/* Plugin support */ + +extern RwBool +RpHAnimPluginAttach(void); + +/* Overloadable keyframe functions */ + +#define RpHAnimFrameToMatrixMacro(hierarchy, matrix, iFrame) \ +MACRO_START \ +{ \ + const RpHAnimKeyFrameToMatrixCallBack keyFrameToMatrixCB = \ + (hierarchy)->keyFrameToMatrixCB; \ + \ + if (RpHAnimStdKeyFrameToMatrix == keyFrameToMatrixCB) \ + { \ + RpHAnimStdKeyFrameToMatrixMacro((matrix), (iFrame)); \ + } \ + else \ + { \ + keyFrameToMatrixCB((matrix), (iFrame)); \ + } \ +} \ +MACRO_STOP + +#define RpHAnimFrameInterpolateMacro(hierarchy, out, in1, in2, time) \ +MACRO_START \ +{ \ + (hierarchy)->keyFrameInterpolateCB((out), (in1), (in2), (time)); \ +} \ +MACRO_STOP + +#define RpHAnimFrameBlendMacro(hierarchy, out, in1, in2, fAlpha) \ +MACRO_START \ +{ \ + (hierarchy)->keyFrameBlendCB((out), (in1), (in2), (fAlpha)); \ +} \ +MACRO_STOP + +#define RpHAnimFrameAddTogetherMacro(hierarchy, out, in1, in2) \ +MACRO_START \ +{ \ + (hierarchy)->keyFrameAddCB((out), (in1), (in2)); \ +} \ +MACRO_STOP + +#ifdef RWDEBUG +void +RpHAnimFrameInterpolate(RpHAnimHierarchy *hierarchy, + void *out, void *in1, + void *in2, RwReal time); + +void +RpHAnimFrameBlend(RpHAnimHierarchy *hierarchy, + void *out, + void *in1, + void *in2, + RwReal alpha); + +void +RpHAnimFrameToMatrix(RpHAnimHierarchy *hierarchy, + RwMatrix *matrix, void *iFrame); + +void +RpHAnimFrameAddTogether(RpHAnimHierarchy *hierarchy, + void *out, void *in1, void *in2); + +#else /* RWDEBUG */ + +#define RpHAnimFrameToMatrix(hierarchy, matrix, iFrame) \ + RpHAnimFrameToMatrixMacro(hierarchy, matrix, iFrame) + +#define RpHAnimFrameInterpolate(hierarchy, out, in1, in2, time) \ + RpHAnimFrameInterpolateMacro(hierarchy, out, in1, in2, time) + +#define RpHAnimFrameBlend(hierarchy, out, in1, in2, alpha) \ + RpHAnimFrameBlendMacro(hierarchy, out, in1, in2, alpha) + +#define RpHAnimFrameAddTogether(hierarchy, out, in1, in2) \ + RpHAnimFrameAddTogetherMacro(hierarchy, out, in1, in2) + +#endif /* RWDEBUG */ + +/* Standard keyframe functions */ + +extern void +RpHAnimStdKeyFrameToMatrix(RwMatrix *matrix, + void * voidIFrame); + +extern void +RpHAnimStdKeyFrameBlend(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal alpha); + +extern void +RpHAnimStdKeyFrameInterpolate(void *voidOut, + void *voidIn1, + void *voidIn2, + RwReal time); + +extern void +RpHAnimStdKeyFrameAdd(void *voidOut, + void *voidIn1, + void *voidIn2); + +extern void +RpHAnimStdKeyFrameMulRecip(void *voidFrame, + void *voidStart); + +extern RpHAnimAnimation * +RpHAnimStdKeyFrameStreamRead(RwStream *stream, + RpHAnimAnimation *animation); + +extern RwBool +RpHAnimStdKeyFrameStreamWrite(RpHAnimAnimation *animation, + RwStream *stream); + +extern RwInt32 +RpHAnimStdKeyFrameStreamGetSize(RpHAnimAnimation *animation); + +/* Hierarchy blending/combination functions */ + +extern RwBool +RpHAnimHierarchyBlend(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2, + RwReal alpha); +extern RwBool +RpHAnimHierarchyAddTogether(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2); + +extern RwBool +RpHAnimHierarchyBlendSubHierarchy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy1, + RpHAnimHierarchy *inHierarchy2, + RwReal alpha); +extern RwBool +RpHAnimHierarchyAddSubHierarchy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *mainHierarchy, + RpHAnimHierarchy *subHierarchy); + +extern RwBool +RpHAnimHierarchyCopy(RpHAnimHierarchy *outHierarchy, + RpHAnimHierarchy *inHierarchy); + +/* Access to RwFrame ID's */ + +extern RwBool +RpHAnimFrameSetID(RwFrame *frame, + RwInt32 id); + +extern RwInt32 +RpHAnimFrameGetID(RwFrame *frame); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* RPHANIM_H */ diff --git a/rwsdk/include/d3d8/rphanim.rpe b/rwsdk/include/d3d8/rphanim.rpe new file mode 100644 index 00000000..c60f8591 --- /dev/null +++ b/rwsdk/include/d3d8/rphanim.rpe @@ -0,0 +1,644 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionHANIM +{ + + +E_RP_HANIM_INTERP_IDINUSE, + +E_RP_HANIM_INTERP_BLOCKFULL, + +E_RP_HANIM_INTERP_IDUNKNOWN, + + e_rwdb_CriterionHANIMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionHANIM e_rwdb_CriterionHANIM; + + diff --git a/rwsdk/include/d3d8/rplodatm.h b/rwsdk/include/d3d8/rplodatm.h new file mode 100644 index 00000000..d4583338 --- /dev/null +++ b/rwsdk/include/d3d8/rplodatm.h @@ -0,0 +1,131 @@ + +/****************************************** + * * + * RenderWare(TM) Graphics Library * + * * + ******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + +/*************************************************************************** + * * + * Module : rplodatm.h * + * * + * Purpose : LODATM Geometry * + * * + **************************************************************************/ + +#ifndef RPLODATM_H +#define RPLODATM_H + + +/** + * \defgroup rplodatm RpLODAtomic + * \ingroup rpplugin + * + * Level of Detail Management Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpcriter.h" /* Note: each vendor can choose their own method for + * allocation of unique ID's. This file defines + * the ID's used by Criterion. + */ +#include "rplodatm.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ +#define RPLODATOMICMAXLOD 10 + + +/**************************************************************************** + Type defs + */ +typedef RwInt32 (*RpLODAtomicLODCallBack)( RpAtomic *atomic ); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + extern RwBool + RpLODAtomicPluginAttach( void ); + + extern RpAtomic * + RpLODAtomicSetGeometry( + RpAtomic *atomic, RwInt32 lodIdx, RpGeometry *geometry ); + + extern RpGeometry * + RpLODAtomicGetGeometry( + RpAtomic *atomic, RwInt32 lodIdx ); + + extern RpAtomic * + RpLODAtomicSetCurrentLOD( + RpAtomic *atomic, RwInt32 lodIdx ); + + extern RwInt32 + RpLODAtomicGetCurrentLOD( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicSetRange( + RpAtomic *atomic, RwReal farRange ); + + extern RwReal + RpLODAtomicGetRange( + RpAtomic *atomic ); + + extern void + RpLODAtomicSetCamera( + RwCamera *camera ); + + extern RpAtomic * + RpLODAtomicSetLODCallBack( + RpAtomic *atomic, RpLODAtomicLODCallBack callback ); + + extern RpAtomic * + RpLODAtomicSelectLOD( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicForAllLODGeometries( + RpAtomic *atomic, RpGeometryCallBack callback, void *pData ); + + extern RpAtomic * + RpLODAtomicHookRender( + RpAtomic *atomic ); + + extern RpAtomic * + RpLODAtomicUnHookRender( + RpAtomic *atomic ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLODATM_H */ + diff --git a/rwsdk/include/d3d8/rplodatm.rpe b/rwsdk/include/d3d8/rplodatm.rpe new file mode 100644 index 00000000..649bc3bc --- /dev/null +++ b/rwsdk/include/d3d8/rplodatm.rpe @@ -0,0 +1,642 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLODATM +{ + + + + e_rwdb_CriterionLODATMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLODATM e_rwdb_CriterionLODATM; + + diff --git a/rwsdk/include/d3d8/rplogo.h b/rwsdk/include/d3d8/rplogo.h new file mode 100644 index 00000000..ed527a29 --- /dev/null +++ b/rwsdk/include/d3d8/rplogo.h @@ -0,0 +1,83 @@ +/** + * Logo plugin + */ + + +/********************************************************************** + * + * File : rplogo.h + * + * Abstract : Add CSL Logo + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 1998 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef RPLOGO_H +#define RPLOGO_H + +/** + * \defgroup rplogo RpLogo + * \ingroup rpplugin + * + * Logo Plugin for RenderWare Graphics. + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rplogo.rpe" /* automatically generated header file */ + +/*--- Global Structures ---*/ + +enum RpLogoPosition +{ + rpNALOGOPOSITION = 0, + rpLOGOTOP, + rpLOGOCENTER, + rpLOGOBOTTOM, + rpLOGOLEFT, + rpLOGORIGHT, + rpLOGOTOPLEFT, + rpLOGOTOPRIGHT, + rpLOGOBOTTOMLEFT, + rpLOGOBOTTOMRIGHT, + rpLOGOPOSITIONFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpLogoPosition RpLogoPosition; + +/*--- Plugin API Functions ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + RwBool RpLogoPluginAttach(void); + RwBool RpLogoSetPosition(RpLogoPosition pos); + RpLogoPosition RpLogoGetPosition(void); + RwBool RpLogoSetState(RwCamera * cam, RwBool state); + RwBool RpLogoGetState(RwCamera * cam); + RwRect *RpLogoGetRenderingRect(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLOGO_H */ + diff --git a/rwsdk/include/d3d8/rplogo.rpe b/rwsdk/include/d3d8/rplogo.rpe new file mode 100644 index 00000000..f37b6920 --- /dev/null +++ b/rwsdk/include/d3d8/rplogo.rpe @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLogo +{ + + + + e_rwdb_CriterionLogoLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLogo e_rwdb_CriterionLogo; + + diff --git a/rwsdk/include/d3d8/rpltmap.h b/rwsdk/include/d3d8/rpltmap.h new file mode 100644 index 00000000..5add9a26 --- /dev/null +++ b/rwsdk/include/d3d8/rpltmap.h @@ -0,0 +1,90 @@ + +/** + * \defgroup rpltmap RpLtMap + * \ingroup rpplugin + * + * Lightmap Plugin for RenderWare Graphics. + */ + +#ifndef RPLTMAP_H +#define RPLTMAP_H + +/*===========================================================================* + *--- Includes --------------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + + +#define rpLTMAPDEFAULTLIGHTMAPSIZE 128 +#define rpLTMAPMINLIGHTMAPSIZE 16 +#define rpLTMAPMAXLIGHTMAPSIZE 512/*?? any better way of determining this ??*/ + +#define rpLTMAPMAXPREFIXSTRINGLENGTH 4 + +#define rpLTMAPDEFAULTMAXAREALIGHTSAMPLESPERMESH 256 +/* The default tolerance for errors induced by area light ROIs is 1 + * (being the smallest difference in lightmap colour values) */ +#define rpLTMAPDEFAULTAREALIGHTROICUTOFF (1.0f) + + +/** + * \ingroup rpltmap + * \ref RpLtMapStyle + * Flags specifying the rendering style of the lightmap plugin. + * + * \see RpLtMapGetRenderStyle + * \see RpLtMapSetRenderStyle + */ +enum RpLtMapStyle +{ + rpLTMAPSTYLENASTYLE = 0x0, + + rpLTMAPSTYLERENDERBASE = 0x1, /**< The base texture should be rendered */ + rpLTMAPSTYLERENDERLIGHTMAP = 0x2, /**< The lightmap should be rendered */ + rpLTMAPSTYLEPOINTSAMPLE = 0x4, /**< The lightmap should be point-sampled */ + + rpLTMAPSTYLEFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RpLtMapStyle RpLtMapStyle; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern RwBool +RpLtMapPluginAttach(void); + +extern RxPipeline * +RpLtMapGetPlatformAtomicPipeline(void); +extern RxPipeline * +RpLtMapGetPlatformWorldSectorPipeline(void); + +extern RwBool +RpLtMapSetRenderStyle(RpLtMapStyle style, RpWorld *world); +extern RpLtMapStyle +RpLtMapGetRenderStyle(void); + +extern RwUInt32 +RpLtMapWorldLightMapsQuery(RpWorld *world); + +extern RwTexture * +RpLtMapWorldSectorGetLightMap(RpWorldSector *sector); +extern RpWorldSector * +RpLtMapWorldSectorSetLightMap(RpWorldSector *sector, RwTexture *lightMap); +extern RwTexture * +RpLtMapAtomicGetLightMap(RpAtomic *atomic); +extern RpAtomic * +RpLtMapAtomicSetLightMap(RpAtomic *atomic, RwTexture *lightMap); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPLTMAP_H */ + + diff --git a/rwsdk/include/d3d8/rpltmap.rpe b/rwsdk/include/d3d8/rpltmap.rpe new file mode 100644 index 00000000..413caf4c --- /dev/null +++ b/rwsdk/include/d3d8/rpltmap.rpe @@ -0,0 +1,638 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLTMAP +{ + + + + e_rwdb_CriterionLTMAPLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLTMAP e_rwdb_CriterionLTMAP; + + diff --git a/rwsdk/include/d3d8/rpmatfx.h b/rwsdk/include/d3d8/rpmatfx.h new file mode 100644 index 00000000..9b091dd8 --- /dev/null +++ b/rwsdk/include/d3d8/rpmatfx.h @@ -0,0 +1,237 @@ + +#ifndef RPMATFX_H +#define RPMATFX_H + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + +/*---- start: ./matfx.h----*/ + +#ifndef RPMATFX_MATFX_H +#define RPMATFX_MATFX_H + + +/** + * \defgroup rpmatfx RpMatFX + * \ingroup rpplugin + * + * Material Effects Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ + +/** + * \ingroup rpmatfx + * RpMatFXMaterialFlags, this type represents the different types of + * material effects that can be used on a material. The effects are + * initialized with \ref RpMatFXMaterialSetEffects: + */ +enum RpMatFXMaterialFlags +{ + rpMATFXEFFECTNULL = 0, + rpMATFXEFFECTBUMPMAP = 1, /** + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern RwReal RpMipmapKLTextureSetDefaultK(RwReal val); +extern RwUInt32 RpMipmapKLTextureSetDefaultL(RwUInt32 val); +extern RwReal RpMipmapKLTextureGetDefaultK(void); +extern RwUInt32 RpMipmapKLTextureGetDefaultL(void); + +extern RwTexture *RpMipmapKLTextureSetK(RwTexture *tex, RwReal val); +extern RwTexture *RpMipmapKLTextureSetL(RwTexture *tex, RwUInt32 val); +extern RwReal RpMipmapKLTextureGetK(RwTexture *tex); +extern RwUInt32 RpMipmapKLTextureGetL(RwTexture *tex); + +extern RwBool RpMipmapKLPluginAttach(void); + +#ifdef __cplusplus +} +#endif + +#endif /* RPMIPMAPKLPLUGIN_H */ diff --git a/rwsdk/include/d3d8/rpmipkl.rpe b/rwsdk/include/d3d8/rpmipkl.rpe new file mode 100644 index 00000000..5216ec9c --- /dev/null +++ b/rwsdk/include/d3d8/rpmipkl.rpe @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLabel +{ + + + + e_rwdb_CriterionLabelLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLabel e_rwdb_CriterionLabel; + + diff --git a/rwsdk/include/d3d8/rpmorph.h b/rwsdk/include/d3d8/rpmorph.h new file mode 100644 index 00000000..4177fba8 --- /dev/null +++ b/rwsdk/include/d3d8/rpmorph.h @@ -0,0 +1,138 @@ + +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1998. Criterion Software Ltd. + * All Rights Reserved. + */ + + +/**************************************************************************** + * + * Morph animation controller + * Copyright (C) 1998 Criterion Technologies + * + * Module : rpmorph.h + * + * Purpose : Functions for controlling morph target animation + * + ****************************************************************************/ + +#ifndef RPMORPH_H +#define RPMORPH_H + + +/** + * \defgroup rpmorph RpMorph + * \ingroup rpplugin + * + * Morphing Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpmorph.rpe" /* automatically generated header file */ + +/**************************************************************************** + Global Types + */ +typedef struct RpMorphInterpolator RpMorphInterpolator; + +/** + * \ingroup rpmorph + * \struct RpMorphInterpolator + * structure describing morph interpolator + */ +struct RpMorphInterpolator +{ + RwInt32 flags; /**< flags */ + RwInt16 startMorphTarget; /**< startMorphTarget */ + RwInt16 endMorphTarget; /**< endMorphTarget */ + RwReal time; /**< time */ + RwReal recipTime; /**< recipTime */ + RpMorphInterpolator *next; /**< next */ +}; + +/* Morph Animation */ + +/** + * \ingroup rpmorph + * \typedef RpMorphGeometryCallBack + * This is the callback function supplied to \ref RpMorphGeometrySetCallBack + * and returned from \ref RpMorphGeometryGetCallBack. + * The supplied function will be passed a pointer to the geometry's parent atomic, + * and the position of the current interpolator. + * The function will only be called when the position of the geometry's current + * interpolator moves out of the current range. + * + * \param atomic Pointer to the geometry's parent atomic. + * \param position Value of the current interpolator. + * + * \return + * + * \see RpMorphGeometrySetCallBack + * \see RpMorphGeometryGetCallBack + */ +typedef RwReal (*RpMorphGeometryCallBack)(RpAtomic *atomic, RwReal position); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool RpMorphPluginAttach(void); + +/* Morph Animation */ +extern RpGeometry *RpMorphGeometryCreateInterpolators(RpGeometry *geometry, RwInt32 numInterps); +extern RpGeometry *RpMorphGeometrySetInterpolator(RpGeometry *geometry, + RwInt32 interpNum, + RwInt32 startKey, RwInt32 endKey, RwReal time); +extern RpGeometry *RpMorphGeometrySetNextInterpolator(RpGeometry *geometry, + RwInt32 interpNum, RwInt32 interpNumNext); +extern RpGeometry *RpMorphGeometrySetCallBack(RpGeometry *geometry, RpMorphGeometryCallBack animCB); +extern RpMorphGeometryCallBack RpMorphGeometryGetCallBack(const RpGeometry *geometry); + +extern RpAtomic *RpMorphAtomicSetCurrentInterpolator(RpAtomic *atomic, RwInt32 interpNum); +extern RwInt32 RpMorphAtomicGetCurrentInterpolator(RpAtomic *atomic); + +extern RpMorphInterpolator *RpMorphGeometryGetInterpolator(RpGeometry *geometry, RwInt32 interpNum); + +extern RpAtomic *RpMorphAtomicSetTime(RpAtomic *atomic, RwReal time); +extern RpAtomic *RpMorphAtomicAddTime(RpAtomic *atomic, RwReal time); + + +/* LEGACY-SUPPORT version: */ +extern RpMorphInterpolator *_rpMorphAtomicGetInterpolator(RpAtomic *atomic, RwInt32 interpNum); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpMorphAtomicGetInterpolator(_atomic, _interpNum) \ + _rpMorphAtomicGetInterpolator(_atomic, _interpNum) + +#endif /* RPMORPH_H */ + diff --git a/rwsdk/include/d3d8/rpmorph.rpe b/rwsdk/include/d3d8/rpmorph.rpe new file mode 100644 index 00000000..14b13076 --- /dev/null +++ b/rwsdk/include/d3d8/rpmorph.rpe @@ -0,0 +1,641 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionMorph +{ + + +E_RP_MORPH_INVALIDINTERP, + +E_RP_MORPH_NOGEOMETRY, + + e_rwdb_CriterionMorphLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionMorph e_rwdb_CriterionMorph; + + diff --git a/rwsdk/include/d3d8/rppatch.h b/rwsdk/include/d3d8/rppatch.h new file mode 100644 index 00000000..eb80663f --- /dev/null +++ b/rwsdk/include/d3d8/rppatch.h @@ -0,0 +1,683 @@ + +#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, /** + +#include "rwcore.h" + +#include "rpptank.rpe" /* automatically generated header file */ + +/****************************************************************************** + * Global Types + */ + +/** + * \ingroup rpptank + * Passed to \ref RpPTankAtomicCreate, these flags specify + * the type and properties held by the particles. + * Some flags are mutually exclusive and should not be mixed. + * The debug version of the library will assert and signal these problems. + */ +enum RpPTankDataFlags +{ + rpPTANKDFLAGNONE = ((int)0x00000000), + rpPTANKDFLAGPOSITION = ((int)0x00000001), /**actPCount) + +#define RpPTankAtomicGetMaximumParticlesCountMacro(_atm)\ + (RPATOMICPTANKPLUGINDATA(_atm)->maxPCount) + +#define RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGACTNUMCHG;\ + RPATOMICPTANKPLUGINDATA(atm_)->actPCount = cnt_;\ +}\ +MACRO_STOP + +#define RpPTankAtomicSetTextureMacro(atm_, tex_)\ +MACRO_START\ +{\ +RpMaterialSetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0), tex_);\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetTextureMacro(atm_)\ + (RpMaterialGetTexture(RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0))) + +#define RpPTankAtomicGetMaterialMacro(atm_)\ + (RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0)) + +#define RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend = src_;\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend = dst_;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_)\ +MACRO_START\ +{\ + *src_ =\ + (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.srcBlend);\ + *dst_ =\ + (RwBlendFunction)(RPATOMICPTANKPLUGINDATA(atm_)->publicData.dstBlend);\ +}\ +MACRO_STOP + +#define RpPTankAtomicSetVertexAlphaMacro(atm_, vas_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend = vas_;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetVertexAlphaMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.vertexAlphaBlend) + +#define RpPTankAtomicSetConstantCenterMacro(atm_, ctr_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter = *ctr_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCENTER;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantCenterMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cCenter)) + + +#define RpPTankAtomicSetConstantSizeMacro(atm_, size_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize = *size_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSSIZE;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantSizeMacro(atm_)\ + (&RPATOMICPTANKPLUGINDATA(atm_)->publicData.cSize) + +#define RpPTankAtomicSetConstantRotateMacro(atm_, rot_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate = rot_;\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNS2DROTATE;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantRotateMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cRotate) + +#define RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_)\ +MACRO_START\ +{\ + RwMatrixCopy(&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix),mtx_);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSMATRIX;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantMatrixMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cMatrix)) + +#define RpPTankAtomicSetConstantColorMacro(atm_, col_)\ +MACRO_START\ +{\ + RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor = *col_;\ + if( RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0) )\ + {\ + RpMaterialSetColor(\ + RpGeometryGetMaterial(RpAtomicGetGeometry(atm_),0),\ + &RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor);\ + }\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSCOLOR;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantColorMacro(atm_)\ + (&(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cColor)) + +#define RpPTankAtomicSetConstantVtxColorMacro(atm_, col_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor,\ + col_,\ + sizeof(RwRGBA)*4);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTXCOLOR;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtxColorMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cVtxColor) + +#define RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\ + uv_,\ + sizeof(RwTexCoords)*2);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX2TEXCOORDS;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV) + +#define RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_)\ +MACRO_START\ +{\ + memcpy(RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV,\ + uv_,\ + sizeof(RwTexCoords)*4);\ + RPATOMICPTANKPLUGINDATA(atm_)->instFlags |= rpPTANKIFLAGCNSVTX4TEXCOORDS;\ +}\ +MACRO_STOP + +#define RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_)\ + (RPATOMICPTANKPLUGINDATA(atm_)->publicData.cUV) + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpPTankAtomicGetActiveParticlesCount(RpAtomic *atomic); + +extern RwInt32 +RpPTankAtomicGetMaximumParticlesCount(RpAtomic *atomic); + +extern void +RpPTankAtomicSetActiveParticlesCount(RpAtomic *atomic, RwInt32 count); + +extern void +RpPTankAtomicSetTexture(RpAtomic *atomic, RwTexture *texture); + +extern RwTexture * +RpPTankAtomicGetTexture(RpAtomic *atomic); + +extern RpAtomic * +RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material); + +extern RpMaterial * +RpPTankAtomicGetMaterial(RpAtomic *atomic); + +extern void +RpPTankAtomicSetBlendModes(RpAtomic *atomic, + RwBlendFunction srcBlendMode, + RwBlendFunction dstBlendMode ); + +extern void +RpPTankAtomicGetBlendModes(RpAtomic *atomic, + RwBlendFunction *srcBlendMode, + RwBlendFunction *dstBlendMode ); + +extern void +RpPTankAtomicSetVertexAlpha(RpAtomic *atomic, RwBool vtxAlphaState); + +extern RwBool +RpPTankAtomicGetVertexAlpha(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantCenter(RpAtomic *atomic, RwV2d *center); + +const RwV2d * +RpPTankAtomicGetConstantCenter(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantSize(RpAtomic *atomic, RwV2d *size); + +extern const RwV2d * +RpPTankAtomicGetConstantSize(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantRotate(RpAtomic *atomic, RwReal rotate); + +extern RwReal +RpPTankAtomicGetConstantRotate(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantMatrix(RpAtomic *atomic, RwMatrix *matrix); + +extern const RwMatrix * +RpPTankAtomicGetConstantMatrix(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantColor(RpAtomic *atomic, RwRGBA *color); + +extern const RwRGBA * +RpPTankAtomicGetConstantColor(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtxColor(RpAtomic *atomic, RwRGBA *color); + +extern const RwRGBA * +RpPTankAtomicGetConstantVtxColor(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtx2TexCoords(RpAtomic *atomic, RwTexCoords *UVs); + +extern const RwTexCoords * +RpPTankAtomicGetConstantVtx2TexCoords(RpAtomic *atomic); + +extern void +RpPTankAtomicSetConstantVtx4TexCoords(RpAtomic *atomic, RwTexCoords *UVs); + +extern const RwTexCoords * +RpPTankAtomicGetConstantVtx4TexCoords(RpAtomic *atomic); +#else + +#define RpPTankAtomicGetActiveParticlesCount(atm_)\ + RpPTankAtomicGetActiveParticlesCountMacro(atm_) + +#define RpPTankAtomicGetMaximumParticlesCount(atm_)\ + RpPTankAtomicGetMaximumParticlesCountMacro(atm_) + +#define RpPTankAtomicSetActiveParticlesCount(atm_,cnt_)\ + RpPTankAtomicSetActiveParticlesCountMacro(atm_,cnt_) + + +#define RpPTankAtomicSetTexture(atm_,tex_)\ + RpPTankAtomicSetTextureMacro(atm_,tex_) + +#define RpPTankAtomicGetTexture(atm_)\ + RpPTankAtomicGetTextureMacro(atm_) + +extern RpAtomic * +RpPTankAtomicSetMaterial(RpAtomic *atomic, RpMaterial *material); + +#define RpPTankAtomicGetMaterial(atm_)\ + RpPTankAtomicGetMaterialMacro(atm_) + +#define RpPTankAtomicSetBlendModes(atm_,src_,dst_)\ + RpPTankAtomicSetBlendModesMacro(atm_,src_,dst_) + +#define RpPTankAtomicGetBlendModes(atm_,src_,dst_)\ + RpPTankAtomicGetBlendModesMacro(atm_,src_,dst_) + +#define RpPTankAtomicSetVertexAlpha(atm_, vas_)\ + RpPTankAtomicSetVertexAlphaMacro(atm_, vas_) + +#define RpPTankAtomicGetVertexAlpha(atm_)\ + RpPTankAtomicGetVertexAlphaMacro(atm_) + +#define RpPTankAtomicSetConstantCenter(atm_, ctr_)\ + RpPTankAtomicSetConstantCenterMacro(atm_, ctr_) + +#define RpPTankAtomicGetConstantCenter(atm_)\ + RpPTankAtomicGetConstantCenterMacro(atm_) + +#define RpPTankAtomicSetConstantSize(atm_, size_)\ + RpPTankAtomicSetConstantSizeMacro(atm_, size_) + +#define RpPTankAtomicGetConstantSize(atm_)\ + RpPTankAtomicGetConstantSizeMacro(atm_) + +#define RpPTankAtomicSetConstantRotate(atm_, rot_)\ + RpPTankAtomicSetConstantRotateMacro(atm_, rot_) + +#define RpPTankAtomicGetConstantRotate(atm_)\ + RpPTankAtomicGetConstantRotateMacro(atm_) + +#define RpPTankAtomicSetConstantMatrix(atm_, mtx_)\ + RpPTankAtomicSetConstantMatrixMacro(atm_, mtx_) + +#define RpPTankAtomicGetConstantMatrix(atm_)\ + RpPTankAtomicGetConstantMatrixMacro(atm_) + +#define RpPTankAtomicSetConstantColor(atm_, col_)\ + RpPTankAtomicSetConstantColorMacro(atm_, col_) + +#define RpPTankAtomicGetConstantColor(atm_)\ + RpPTankAtomicGetConstantColorMacro(atm_) + +#define RpPTankAtomicSetConstantVtxColor(atm_, _col)\ + RpPTankAtomicSetConstantVtxColorMacro(atm_, _col) + +#define RpPTankAtomicGetConstantVtxColor(atm_)\ + RpPTankAtomicGetConstantVtxColorMacro(atm_) + +#define RpPTankAtomicSetConstantVtx2TexCoords(atm_, uv_)\ + RpPTankAtomicSetConstantVtx2TexCoordsMacro(atm_, uv_) + +#define RpPTankAtomicGetConstantVtx2TexCoords(atm_)\ + RpPTankAtomicGetConstantVtx2TexCoordsMacro(atm_)\ + +#define RpPTankAtomicSetConstantVtx4TexCoords(atm_, uv_)\ + RpPTankAtomicSetConstantVtx4TexCoordsMacro(atm_, uv_) + +#define RpPTankAtomicGetConstantVtx4TexCoords(atm_)\ + RpPTankAtomicGetConstantVtx4TexCoordsMacro(atm_) + +#endif + +/* + * Data access API *********************************************************** + */ + +extern RwBool +RpPTankAtomicLock(RpAtomic *atomic, RpPTankLockStruct *dst, + RwUInt32 dataFlags, RpPTankLockFlags lockFlag); + +extern void * +RpPTankAtomicLockByIndex(RpAtomic *atomic, RwInt32 idx, RwUInt32 dataFlags, RpPTankLockFlags lockFlag); + +extern RpAtomic * +RpPTankAtomicUnlock(RpAtomic *atomic); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*---- end: ./ptank.h----*/ + +/*---- start: c:/daily/rwsdk/plugin/ptank/d3d8/ptankplatform.h----*/ + +enum RpPTankD3D8Flags +{ + rpPTANKD3D8FLAGSUSEPOINTSPRITES = 0x00000001, + + rpPTANKD3D8FLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/*---- end: c:/daily/rwsdk/plugin/ptank/d3d8/ptankplatform.h----*/ + +#endif /* RPPTANK_H */ + + diff --git a/rwsdk/include/d3d8/rpptank.rpe b/rwsdk/include/d3d8/rpptank.rpe new file mode 100644 index 00000000..485b5dd8 --- /dev/null +++ b/rwsdk/include/d3d8/rpptank.rpe @@ -0,0 +1,643 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPTank +{ + + + + e_rwdb_CriterionPTankLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPTank e_rwdb_CriterionPTank; + + diff --git a/rwsdk/include/d3d8/rppvs.h b/rwsdk/include/d3d8/rppvs.h new file mode 100644 index 00000000..29fc2343 --- /dev/null +++ b/rwsdk/include/d3d8/rppvs.h @@ -0,0 +1,395 @@ +/* + * Potentially Visible Set plug-in + */ + +/********************************************************************** + * + * file : rppvs.h + * + * abstract : handle culling of worldsectors in RenderWare + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 2001 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef _RPPVS_H +#define _RPPVS_H + +/** + * \defgroup rppvs RpPVS + * \ingroup rpplugin + * + * Geometric Potentially Visible Set Plugin for RenderWare Graphics. + */ + +/**************************************************************************** + Defines + */ + +typedef RwUInt8 RpPVSVisMap; + +#define PVSFROMWORLDSECTOR(sector) \ + ((RpPVS *)(((char *)(sector))+rpPVSGlobals.sectorOffset)) + +#define WORLDSECTORFROMPVS(pvs) \ + ((RpWorldSector *)(((char *)(pvs))-rpPVSGlobals.sectorOffset)) + +#define PVSFROMCONSTWORLDSECTOR(sector) \ + ((const RpPVS *)(((const char *)(sector))+rpPVSGlobals.sectorOffset)) + + +#define PVSCACHEFROMWORLD(world) \ + ((RpPVSCache *)(((char *)(world))+rpPVSGlobals.worldOffset)) +#define PVSCACHEFROMCONSTWORLD(world) \ + ((const RpPVSCache *)(((const char *)(world))+rpPVSGlobals.worldOffset)) + +#define PVSVISMAPSETSECTOR(_vismap, _id) \ + (_vismap)[(_id) >> 3] |= (1 << ((_id) & 7)) + +#define PVSVISMAPUNSETSECTOR(_vismap, _id) \ + (_vismap)[(_id) >> 3] ^= (1 << ((_id) & 7)) + +#define PVSVISMAPGETSECTOR(_vismap, _id) \ + ((_vismap)[(_id) >> 3] & (1 << ((_id) & 7))) + +#define PVSVISMAPLENGTH(_vismaplength, _nosectors) \ + (_vismaplength) = ((_nosectors + 7) >> 3) + + +/* Progress callback message types */ +#define rpPVSPROGRESSSTART 20 +#define rpPVSPROGRESSUPDATE 12 +#define rpPVSPROGRESSEND 22 + +/** + * \ingroup rppvs + * \ref RpPVSProgressCallBack + * This typedef sets the callback function for sampling within a world sector. + * + * \param value A value between 0.0 and 100.0 to represent the percentage completion. + * \param msg The message may take one of the following: + * + * \li rpPVSPROGRESSSTART + * The PVS creation process is about to start. The argument value is equal to 0.0. + * + * \li rpPVSPROGRESSUPDATE + * The PVS 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 rpPVSPROGRESSEND + * The PVS creation process has ended. All world sectors have been processed. + * The argument value is equal to 100.0. + * + * The progress callback may return FALSE to indicate that the generation of PVS data + * should terminate. Otherwise, return TRUE to continue. + * + * The PVS plugin must be attached before using this function. + * + * + */ +typedef RwBool(*RpPVSProgressCallBack) (RwInt32 msg, + RwReal value); + + +/** + * \ingroup rppvs + * \ref RpPVSCallBack + * This typedef sets the callback function for sampling within a world sector. + * + * \param worldSector A pointer to the \ref RpWorldSector being sampled. + * \param box The bounding box of the region being sampled. + * \param pData A pointer to private data for the sampling function. + */ +typedef RpWorldSector *(*RpPVSCallBack) (RpWorldSector * worldSector, + const RwBBox * box, + void *pData); + +#define RpPVSCallback RpPVSCallBack + +typedef struct _RpPVSCallBack _RpPVSCallBack; +struct _RpPVSCallBack +{ + RpPVSCallBack callback; + void *data; +}; + +enum _rpPVSPartitionId +{ + rpNAPVSPARTITIONID = 0, + rpPVSFRONT, + rpPVSBACK, + rpPVSSPLIT, + rpPVSCOPLANAR, + rpPVSPARTITIONIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum _rpPVSPartitionId _rpPVSPartitionId; + +typedef struct _rpPVSPolyList _rpPVSPolyList; +typedef struct _rpPVSPolyList *_rpPVSPolyListPtr; + +typedef struct _rpPVSPoly _rpPVSPoly; +typedef struct _rpPVSPoly *_rpPVSPolyPtr; + +typedef struct _rpPVSPlaneEq _rpPVSPlaneEq; +struct _rpPVSPlaneEq +{ + RwReal x; + RwReal y; + RwReal z; + RwReal w; + + RwReal l; /* recip of length of the normal */ + + _rpPVSPartitionId lastresult; /* temp: stores result of last polygon wrt this plane */ +}; + +typedef struct +{ + RwInt32 x; + RwInt32 y; + RwInt32 z; +}RwV3i; + +typedef struct _rpPVSPolyRecord _rpPVSPolyRecord; +struct _rpPVSPolyRecord +{ + RwBool original; /* True if not a fragment */ + RwReal priority; /* Used for sorting, lower values higher priority */ + _rpPVSPolyListPtr parent; /* Unique pointer to original parent */ + _rpPVSPolyPtr geom; /* corners of the poly */ + _rpPVSPlaneEq plane; /* plane equation of the poly */ + RwInt32 home; /* world sector id in range 0..numsectors */ + RpWorldSector *homeaddr; /* world sector pointer */ + RwBool translucent; + + RwBool hasbeenclipper; /* Used during WA creation */ + + /* used by proximity culling, calculated once */ + RwV3d centroid; + RwReal radius; + RwV3d extreme; /* the vertex furthest away from the centroid */ + + RwReal coneRadius; /* Used during clipping only */ + +}; + +struct _rpPVSPoly +{ + RwV3d v; + _rpPVSPoly *next; + + RwInt32 pscalar; /* Used during clipping only */ + RwReal scalar; /* Used during clipping only */ + _rpPVSPlaneEq shadowPlane; /* Used during clipping only */ +}; + +struct _rpPVSPolyList +{ + _rpPVSPolyRecord data; + _rpPVSPolyList *next; +}; + +typedef struct RpPVS RpPVS; +struct RpPVS +{ + RwInt32 sectorID; /* Id of the sector */ + RwInt32 vismaplength; /* Length of vismap */ + RwInt32 sampleKey; /* Currently unused, for future use */ + + RpPVSVisMap *vismap; + + _rpPVSPolyListPtr sectailpoly; /* Pointer to last polygon in polygons list that is in this sector */ + + _rpPVSPartitionId potential; /* temp: is sector in out or split from current shadow volume - for heirarchical clip */ + RwUInt32 numpols; + RwBBox sbox; /* Bounding box of the sector */ + RwBBox gbox; /* Bounding box of the geometry of the sector */ + RwReal diagonal; /* Diagonal size of bounding box of the sector */ + RwV3d centre; /* Centre of the sector */ + RwInt32 axessig[3]; /* sampling significance of the axes of the gbox */ +}; + +typedef struct RpPVSCache RpPVSCache; +struct RpPVSCache +{ + RwBool processed; /* flag to indicate exisiting PVS data for the world */ + RwBool formatted; /* flag to indicate exisiting intermediate polygonal data for PVS generation */ + + /* stats collection */ + RwInt32 ptotal; + RwInt32 paccept; + + /* pipeline hooking */ + RwBool hooked; + + /* used during vismap allocation */ + RwUInt32 nextID; + + RwInt32 viscount; + + /* Used during construction */ + RpPVSProgressCallBack progressCallBack; + + _rpPVSPolyListPtr polygons; /* A copy of the input data set of all world polygons */ + + RpWorldSectorCallBackRender renderCallBack; +}; + +typedef struct RpPVSGlobalVars RpPVSGlobalVars; +struct RpPVSGlobalVars +{ + RpWorld *World; + + RwInt32 worldOffset; /* Offset into global data */ + RwInt32 sectorOffset; /* Offset into global data */ + + RwBool collis; /* Collision detection */ + RwBool bfc; /* Backface culling */ + + RwInt32 NumWorldSectors; + + RwInt32 progress_count; + RwReal diagonal; + + RwReal gran; + + RwInt32 InSector; /* Current sector id */ + RwV3d ViewPos; /* Current view pos */ + RpPVS *CurrPVS; /* Current PVS sector */ +}; + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpPVSGlobalVars rpPVSGlobals; + +extern RpWorld * +RpPVSSetProgressCallBack(RpWorld * wpWorld, + RpPVSProgressCallBack + callback); + +extern RpWorldSector * +RpPVSSetViewPosition(RpWorld * wpWorld, + RwV3d * pos); + +extern RpWorldSector * +RpPVSSetViewSector(RpWorld * wpWorld, RpWorldSector * spSect); + +extern RpWorldSector * +RpPVSSetWorldSectorPairedVisibility(RpWorldSector * spSectA, + RpWorldSector * spSectB, + RwBool visible, + RwBool mutual); + +extern RpWorld * +RpPVSDestroy(RpWorld * wpWorld); + +extern RwBool +RpPVSWorldSectorVisible(RpWorldSector * spSect); + +extern RwBool +RpPVSPluginAttach(void); + +extern RwBool +RpPVSQuery(RpWorld * wpWorld); + +extern RwBool +RpPVSAtomicVisible(RpAtomic * atom); + +extern RpWorld * +RpPVSStatisticsGet(RpWorld * wpWorld, + RwInt32 * ptotal, + RwInt32 * paccept); + +extern RpPVSProgressCallBack +RpPVSGetProgressCallBack(RpWorld * + wpWorld); + +extern RpWorld * +RpPVSConstruct(RpWorld * wpWorld, + RpPVSCallBack callback, + void *pData); + +extern RpWorld* +RpPVSConstructSector(RpWorld * wpWorld, + RpWorldSector * spSector, + RpPVSCallBack callback, + void *pData); + + +extern RpWorldSector * +RpPVSGeneric(RpWorldSector * spSect, + const RwBBox __RWUNUSED__ * box, + void *data); + +extern RwBool +RpPVSSetCollisionDetection(RwBool collis); + +extern RwBool +RpPVSSetBackFaceCulling(RwBool bfc); + +extern RpWorld * +RpPVSUnhook(RpWorld * wpWorld); + +extern RpWorld * +RpPVSHook(RpWorld * wpWorld); + +extern RpWorldSector * +RpPVSSetWorldSectorVisibility(RpWorldSector * spSect, + RwBool visible); + +extern RwBool +RpPVSSamplePOV(RwV3d * pos, + RwBool colltest); + +extern RxNodeDefinition * +RxNodeDefinitionGetPVSWorldSectorCSL(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* These functions are added for backwards compatibility... */ +#define RpPVSCreate(_wpWorld, \ + _raster, _zraster, _mindist, \ + _maxdist, _maxdepth, _callback, _pData) \ + RpPVSConstruct(_wpWorld, _callback, _pData) + +#define RpPVSAddPOV(_pos) \ + RpPVSSamplePOV(_pos, FALSE) + +#define RpPVSAddWorldSector(_sector) \ + RpPVSSetWorldSectorVisibility(_sector, TRUE) + +#define RpPVSAddExtraPOV(_world, _raster, _zraster, _mindist, _mazdist, _matrix) \ +MACRO_START \ +{ \ + rpPVSGlobals.World = (_world); \ + RpPVSSamplePOV(&((_matrix)->pos), TRUE); \ +} \ +MACRO_STOP + + +#endif /* _RPPVS_H */ diff --git a/rwsdk/include/d3d8/rppvs.rpe b/rwsdk/include/d3d8/rppvs.rpe new file mode 100644 index 00000000..dc060cff --- /dev/null +++ b/rwsdk/include/d3d8/rppvs.rpe @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionGPVS +{ + + + + e_rwdb_CriterionGPVSLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionGPVS e_rwdb_CriterionGPVS; + + diff --git a/rwsdk/include/d3d8/rprandom.h b/rwsdk/include/d3d8/rprandom.h new file mode 100644 index 00000000..8690c69a --- /dev/null +++ b/rwsdk/include/d3d8/rprandom.h @@ -0,0 +1,65 @@ +/********************************************************************** + * + * File : rprandom.h + * + * Abstract : Random Number Generator + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 1998 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef RPRANDOM_H +#define RPRANDOM_H + +/** + * \defgroup rprandom RpRandom + * \ingroup rpplugin + * + * Random Number Generation Plugin for RenderWare Graphics. + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rprandom.rpe" /* automatically generated header file */ + +/*--- Plugin API Functions ---*/ + +#define RPRANDMAX (~((~0)<<31)) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +RwBool RpRandomPluginAttach(void); + +/* Getting values */ + +extern RwUInt32 RpRandom(void); +extern void RpRandomSeed(RwUInt32 seed); + +extern RwUInt32 RpRandomMT(void); +extern void RpRandomSeedMT(RwUInt32 seed); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPRANDOM_H */ + diff --git a/rwsdk/include/d3d8/rprandom.rpe b/rwsdk/include/d3d8/rprandom.rpe new file mode 100644 index 00000000..8e267eee --- /dev/null +++ b/rwsdk/include/d3d8/rprandom.rpe @@ -0,0 +1,638 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRandom +{ + + + + e_rwdb_CriterionRandomLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRandom e_rwdb_CriterionRandom; + + diff --git a/rwsdk/include/d3d8/rpskin.h b/rwsdk/include/d3d8/rpskin.h new file mode 100644 index 00000000..df446c1b --- /dev/null +++ b/rwsdk/include/d3d8/rpskin.h @@ -0,0 +1,222 @@ + +#ifndef RPSKIN_H +#define RPSKIN_H + +/** + * \defgroup rpskin RpSkin + * \ingroup rpplugin + * + * Skin Plugin for RenderWare Graphics. + */ + +/*===========================================================================* + *--- Include files ---------------------------------------------------------* + *===========================================================================*/ +#include "rwcore.h" +#include "rpworld.h" + +#include "rpcriter.h" +#include "rpskin.rpe" + +#include "rphanim.h" + +/*===========================================================================* + *--- Global Types ----------------------------------------------------------* + *===========================================================================*/ +typedef struct RwMatrixWeights RwMatrixWeights; + +/** + * \ingroup rpskin + * \struct RwMatrixWeights + * A structure for defining up to four matrix weights per vertex. + * Not all entries need to be used. + * + * \note + * Values should be sorted, such that any zero 0.0f entries appear + * after the valid weights. Any weights that appear after a zero + * entry will be ignored. + * + * \see RpSkinCreate + */ +struct RwMatrixWeights +{ + RwReal w0; /**< The first matrix weight. */ + RwReal w1; /**< The second matrix weight. */ + RwReal w2; /**< The third matrix weight. */ + RwReal w3; /**< The fourth matrix weight. */ +}; + +/** + * \ingroup rpskin + * \typedef RpSkin + * + * Skin object. This should be considered an opaque type. + * Use the RpSkin API functions to access. + * + * \see RpSkinCreate + * \see RpSkinDestroy + */ +typedef struct RpSkin RpSkin; + +/*===========================================================================* + *--- Plugin API Functions --------------------------------------------------* + *===========================================================================*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/*---------------------------------------------------------------------------* + *- Plugin functions -* + *---------------------------------------------------------------------------*/ +extern RwBool +RpSkinPluginAttach(void); + +/*---------------------------------------------------------------------------* + *- Skin Atomic functions -* + *---------------------------------------------------------------------------*/ +extern RpAtomic * +RpSkinAtomicSetHAnimHierarchy( RpAtomic *atomic, + RpHAnimHierarchy *hierarchy ); + +extern RpHAnimHierarchy * +RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ); + +/*---------------------------------------------------------------------------* + *- Skin Geometry functions -* + *---------------------------------------------------------------------------*/ +extern RpGeometry * +RpSkinGeometrySetSkin( RpGeometry *geometry, + RpSkin *skin ); + +extern RpSkin * +RpSkinGeometryGetSkin( RpGeometry *geometry ); + +extern RpSkin * +RpSkinCreate( RwUInt32 numVertices, + RwUInt32 numBones, + RwMatrixWeights *vertexWeights, + RwUInt32 *vertexIndices, + RwMatrix *inverseMatrices ); + +extern RpSkin * +RpSkinDestroy( RpSkin *skin ); + +extern RwUInt32 +RpSkinGetNumBones( RpSkin *skin ); + +extern const RwMatrixWeights * +RpSkinGetVertexBoneWeights( RpSkin *skin ); + +extern const RwUInt32 * +RpSkinGetVertexBoneIndices( RpSkin *skin ); + +extern const RwMatrix * +RpSkinGetSkinToBoneMatrices( RpSkin *skin ); + +/*---------------------------------------------------------------------------* + *- Skin pipeline -* + *---------------------------------------------------------------------------*/ + +/** + * \ingroup rpskin + * \ref RpSkinType defines the different ways a skinned atomic can + * be rendered. Once a skinned \ref RpGeometry has been attached to + * an \ref RpAtomic the atomic must be setup with the correct skin + * rendering pipeline with \ref RpSkinAtomicSetType. + */ +enum RpSkinType +{ + rpNASKINTYPE = 0, /** +#include + +#include "rpstereo.rpe" /* automatically generated header file */ + +/*--- Global Structures ---*/ + +/* Supported Stereo Modes */ + +/** + * \ingroup rpstereo + * \ref RpStereoCameraMode + * Stereo camera mode enumeration. + */ +enum RpStereoCameraMode +{ + rpNASTEREOMODE = 0, + rpSTEREOMONO, /**< Render as Mono camera - single + * image + */ + rpSTEREOLEFTRIGHT, /**< Vertical split screen. Left eye + * image on left of screen. Right eye + * image on right of screen. + */ + rpSTEREORIGHTLEFT, /**< Vertical split screen. Right eye + * image on left of screen. Left eye image + * on right of screen. + */ + + rpSTEREOROTATE90, /**< As for rpSTEREOLEFTRIGHT - with + * the images rotated inwards by 90 degrees + */ + rpSTEREOINTERLACEDLEFTRIGHT, /**< Left and right eye images on + * alternate scanlines. The left eye image + * on the topmost line of the display. + */ + + rpSTEREOINTERLACEDRIGHTLEFT, /**< Left and right eye images on + * alternate scanlines. The right eye + * image is on the topmost line of the + * display. + */ + rpSTEREOLASTMODE, + rpSTEREOCAMERAMODEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/* + * typedef for stereo camera mode enumeration. + */ +typedef enum RpStereoCameraMode RpStereoCameraMode; + +/*--- Constants ---*/ + +/* These may be used to quickly adapt an existing application to a + * stereo version. + */ + +#ifdef RPSTEREO_OVERLOAD +#define RwCameraBeginUpdate RpStereoCameraBeginUpdate +#define RwCameraEndUpdate RpStereoCameraEndUpdate +#undef RpWorldRender +#define RpWorldRender RpStereoWorldRender +#undef RpClumpRender +#define RpClumpRender RpStereoClumpRender +#undef RpAtomicRender +#define RpAtomicRender RpStereoAtomicRender +#undef RpWorldSectorRender +#define RpWorldSectorRender RpStereoWorldSectorRender +#endif + +/*--- Plugin API Functions ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +RwBool RpStereoPluginAttach(void); + +RpWorld *RpStereoWorldRender(RpWorld *world); +RpClump *RpStereoClumpRender(RpClump *clump); +RpAtomic *RpStereoAtomicRender(RpAtomic *atomic); +RpWorldSector *RpStereoWorldSectorRender(RpWorldSector *sector); + +RwCamera *RpStereoCameraBeginUpdate(RwCamera *camera); +RwCamera *RpStereoCameraEndUpdate(RwCamera *stereoCam); + +RwReal RpStereoCameraGetSeparation(RwCamera *stereoCam); +RwReal RpStereoCameraGetFocal(RwCamera *stereoCam); +RpStereoCameraMode RpStereoCameraGetMode(RwCamera *stereoCam); + +RwCamera *RpStereoCameraSetSeparation(RwCamera *stereoCam, RwReal dist); +RwCamera *RpStereoCameraSetFocal(RwCamera *stereoCam, RwReal focal); +RwCamera *RpStereoCameraSetMode(RwCamera *stereoCam, RpStereoCameraMode newMode); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RPSTEREO_H */ + diff --git a/rwsdk/include/d3d8/rpstereo.rpe b/rwsdk/include/d3d8/rpstereo.rpe new file mode 100644 index 00000000..b89dde2e --- /dev/null +++ b/rwsdk/include/d3d8/rpstereo.rpe @@ -0,0 +1,641 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionStereo +{ + + +E_RP_STEREO_INVMODE, + +E_RP_STEREO_INVFOCAL, + + e_rwdb_CriterionStereoLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionStereo e_rwdb_CriterionStereo; + + diff --git a/rwsdk/include/d3d8/rpusrdat.h b/rwsdk/include/d3d8/rpusrdat.h new file mode 100644 index 00000000..3665e064 --- /dev/null +++ b/rwsdk/include/d3d8/rpusrdat.h @@ -0,0 +1,124 @@ +#ifndef RPUSERDATAPLUGIN_H +#define RPUSERDATAPLUGIN_H + +/** + * \defgroup rpuserdata RpUserData + * \ingroup rpplugin + * + * User Data Plugin for RenderWare Graphics. + */ + +/* + * UserData plugin + */ + +#include +#include + +/** + * \ingroup rpuserdata + * User data formats + */ +enum RpUserDataFormat +{ + rpNAUSERDATAFORMAT = 0, + rpINTUSERDATA, /**< 32 bit int data */ + rpREALUSERDATA, /**< 32 bit float data */ + rpSTRINGUSERDATA, /**< unsigned byte pointer data */ + rpUSERDATAFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpUserDataFormat RpUserDataFormat; + +typedef struct RpUserDataArray RpUserDataArray; + +/** + * \ingroup rpuserdata + * \struct RpUserDataArray + * A structure representing an array of user data values + */ + +struct RpUserDataArray +{ + RwChar *name; /**< Identifier for this data array */ + RpUserDataFormat format; /**< Data format of this array */ + RwInt32 numElements; /**< Number of elements in this array */ + void *data; /**< Pointer to the array data */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Plugin API */ +extern RwBool RpUserDataPluginAttach(void); + +/* Geometry API */ +extern RwInt32 RpGeometryAddUserDataArray(RpGeometry *geometry, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpGeometry *RpGeometryRemoveUserDataArray(RpGeometry *geometry, RwInt32 index); +extern RpUserDataArray *RpGeometryGetUserDataArray(const RpGeometry *geometry, RwInt32 data); +extern RwInt32 RpGeometryGetUserDataArrayCount(const RpGeometry *geometry); + +/* World Sector API */ +extern RwInt32 RpWorldSectorAddUserDataArray(RpWorldSector *sector, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpWorldSector *RpWorldSectorRemoveUserDataArray(RpWorldSector *sector, RwInt32 index); +extern RpUserDataArray *RpWorldSectorGetUserDataArray(const RpWorldSector *sector, RwInt32 data); +extern RwInt32 RpWorldSectorGetUserDataArrayCount(const RpWorldSector *sector); + +/* RwFrame API */ +extern RwInt32 RwFrameAddUserDataArray(RwFrame *frame, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwFrame *RwFrameRemoveUserDataArray(RwFrame *frame, RwInt32 index); +extern RpUserDataArray *RwFrameGetUserDataArray(const RwFrame *frame, RwInt32 data); +extern RwInt32 RwFrameGetUserDataArrayCount(const RwFrame *frame); + +/* RwCamera API */ +extern RwInt32 RwCameraAddUserDataArray(RwCamera *camera, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwCamera *RwCameraRemoveUserDataArray(RwCamera *camera, RwInt32 index); +extern RpUserDataArray *RwCameraGetUserDataArray(const RwCamera *camera, RwInt32 data); +extern RwInt32 RwCameraGetUserDataArrayCount(const RwCamera *camera); + +/* RpLight API */ +extern RwInt32 RpLightAddUserDataArray(RpLight *light, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpLight *RpLightRemoveUserDataArray(RpLight *light, RwInt32 index); +extern RpUserDataArray *RpLightGetUserDataArray(const RpLight *light, RwInt32 data); +extern RwInt32 RpLightGetUserDataArrayCount(const RpLight *light); + +/* RpMaterial API */ +extern RwInt32 RpMaterialAddUserDataArray(RpMaterial *material, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RpMaterial *RpMaterialRemoveUserDataArray(RpMaterial *material, RwInt32 index); +extern RpUserDataArray *RpMaterialGetUserDataArray(const RpMaterial *material, RwInt32 data); +extern RwInt32 RpMaterialGetUserDataArrayCount(const RpMaterial *material); + +/* RwTexture API */ +extern RwInt32 RwTextureAddUserDataArray(RwTexture *texture, RwChar *name, + RpUserDataFormat format, RwInt32 numElements); +extern RwTexture *RwTextureRemoveUserDataArray(RwTexture *texture, RwInt32 index); +extern RpUserDataArray *RwTextureGetUserDataArray(const RwTexture *texture, RwInt32 data); +extern RwInt32 RwTextureGetUserDataArrayCount(const RwTexture *texture); + +/* User Data Array API */ +extern RwChar *RpUserDataArrayGetName(RpUserDataArray *userData); +extern RpUserDataFormat RpUserDataArrayGetFormat(RpUserDataArray *userData); +extern RwInt32 RpUserDataArrayGetNumElements(RpUserDataArray *userData); + +extern RwInt32 RpUserDataArrayGetInt(RpUserDataArray *userData, RwInt32 index); +extern RwReal RpUserDataArrayGetReal(RpUserDataArray *userData, RwInt32 index); +extern RwChar *RpUserDataArrayGetString(RpUserDataArray *userData, RwInt32 index); + +extern void RpUserDataArraySetInt(RpUserDataArray *userData, RwInt32 index, RwInt32 value); +extern void RpUserDataArraySetReal(RpUserDataArray *userData, RwInt32 index, RwReal value); +extern void RpUserDataArraySetString(RpUserDataArray *userData, RwInt32 index, RwChar *value); + +extern RwInt32 RpUserDataGetFormatSize(RpUserDataFormat format); + +#ifdef __cplusplus +} +#endif + +#endif /* RPUSERDATAPLUGIN_H */ diff --git a/rwsdk/include/d3d8/rpusrdat.rpe b/rwsdk/include/d3d8/rpusrdat.rpe new file mode 100644 index 00000000..31c37fd1 --- /dev/null +++ b/rwsdk/include/d3d8/rpusrdat.rpe @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionUserData +{ + + + + e_rwdb_CriterionUserDataLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionUserData e_rwdb_CriterionUserData; + + diff --git a/rwsdk/include/d3d8/rpworld.h b/rwsdk/include/d3d8/rpworld.h new file mode 100644 index 00000000..21fdc31b --- /dev/null +++ b/rwsdk/include/d3d8/rpworld.h @@ -0,0 +1,3735 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Wed Jul 10 10:45:01 2002 + * + ************************************************************************/ + +#ifndef RPWORLD_H +#define RPWORLD_H + +/*--- Check For Previous Required Includes ---*/ +#ifndef RWCORE_H +#error "Include RWCORE.H before including this file" +#endif /* RWCORE_H */ + +/*--- System Header Files ---*/ +#include +#include + +/*--- Error enumerations ---*/ +#include "rpworld.rpe" + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/native.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/wrldpipe.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/nodeD3D8WorldSectorAllInOne.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetD3D8WorldSectorAllInOne(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/nodeD3D8AtomicAllInOne.h ---*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetD3D8AtomicAllInOne(void); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/D3D8VertexBufferManager.h ---*/ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeWorldSectorInstance.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetWorldSectorInstance(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeWorldSectorEnumerateLights.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetWorldSectorEnumerateLights(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodePreLight.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetPreLight(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodePostLight.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetPostLight(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeMaterialScatter.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetMaterialScatter(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeLight.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetLight(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeFastPathSplitter.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetFastPathSplitter(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeAtomicInstance.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetAtomicInstance(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/nodeAtomicEnumerateLights.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetAtomicEnumerateLights(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: c:/daily/rwsdk/world/bamateri.h ---*/ + +/* + * Handling surface materials + * Materials describe how things are to appear when rendered + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + +/**************************************************************************** + Global Types + */ + + +typedef struct RpMaterialChunkInfo RpMaterialChunkInfo; +typedef struct RpMaterialChunkInfo _rpMaterial; + +struct RpMaterialChunkInfo +{ + RwInt32 flags; /**< Material flags - unused currently - + for future expansion */ + RwRGBA color; /**< Colour of material. */ + RwInt32 unused; /**< Not used */ + RwBool textured; /**< Are we textured? */ + RwSurfaceProperties surfaceProps; /**< Surface properties */ +}; + +#if (!defined(RwMaterialAssign)) +#define RwMaterialAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwMaterialAssign)) */ + +/** + * \ingroup rpworlddatatypes + * \typedef RpMaterial + * Material object. This should be + * considered an opaque type. Use the RpMaterial API functions to access. + */ +typedef struct RpMaterial RpMaterial; + +#if (!defined(DOXYGEN)) +struct RpMaterial +{ + RwTexture *texture; /**< texture */ + RwRGBA color; /**< color */ + RxPipeline *pipeline; /**< pipeline */ + RwSurfaceProperties surfaceProps; /**< surfaceProps */ + RwInt16 refCount; /* C.f. rwsdk/world/bageomet.h:RpGeometry */ + RwInt16 pad; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpworlddatatypes + * \typedef RpMaterialCallBack + \ref RpMaterialCallBack + * represents the function called from \ref RpGeometryForAllMaterials and + * \ref RpWorldForAllMaterials for all materials referenced by polygons in a + * given geometry. This function should return a pointer to the current + * material to indicate success. The callback may return NULL to terminate + * further callbacks on the materials. + * + * \param material Pointer to the current material + * \param data Pointer to developer-defined data structure. + * + * \return Pointer to the current material. + */ +typedef RpMaterial *(*RpMaterialCallBack)(RpMaterial *material, void *data); + +/**************************************************************************** + refCount++), (_material)) + +#define RpMaterialAddRefVoidMacro(_material) \ +MACRO_START \ +{ \ + (_material)->refCount++; \ +} \ +MACRO_STOP + + +#define RpMaterialSetColorMacro(_material, _color) \ + (RwRGBAAssign(&((_material)->color), (_color)), (_material)) + +#define RpMaterialGetColorMacro(_material) \ + (&((_material)->color)) + +#define RpMaterialSetSurfacePropertiesMacro(_material, _surfProps) \ + (RwSurfacePropertiesAssign(&((_material)->surfaceProps), \ + (_surfProps)), (_material)) + +#define RpMaterialSetSurfacePropertiesVoidMacro(_material, _surfProps) \ +MACRO_START \ +{ \ + RwSurfacePropertiesAssign(&((_material)->surfaceProps), \ + (_surfProps)); \ +} \ +MACRO_STOP + +#define RpMaterialGetSurfacePropertiesMacro(_material) \ + (&((_material)->surfaceProps)) + +#define RpMaterialGetTextureMacro(_material) \ + ((_material)->texture) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMaterialAddRef(_material) \ + RpMaterialAddRefMacro(_material) + +#define RpMaterialSetColor(_material, _color) \ + RpMaterialSetColorMacro(_material, _color) + +#define RpMaterialGetColor(_material) \ + RpMaterialGetColorMacro(_material) + +#define RpMaterialSetSurfaceProperties(_material, _surfProps) \ + RpMaterialSetSurfacePropertiesMacro(_material, _surfProps) + +#define RpMaterialGetSurfaceProperties(_material) \ + RpMaterialGetSurfacePropertiesMacro(_material) + +#define RpMaterialGetTexture(_material) \ + RpMaterialGetTextureMacro(_material) + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Creating, destroying and referencing materials */ +extern RpMaterial *RpMaterialCreate(void); +extern RwBool RpMaterialDestroy(RpMaterial *material); +extern RpMaterial *RpMaterialClone(RpMaterial *material); + +/* Textures */ +extern RpMaterial *RpMaterialSetTexture(RpMaterial *material, RwTexture *texture); + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RpMaterial *RpMaterialAddRef(RpMaterial *material); + +/* Textures */ +extern RwTexture *RpMaterialGetTexture(const RpMaterial *material); + +/* Setting and getting colors */ +extern RpMaterial *RpMaterialSetColor(RpMaterial *material, const RwRGBA *color); +extern const RwRGBA *RpMaterialGetColor(const RpMaterial *material); + +/* Setting and getting surface properties */ +extern RpMaterial * +RpMaterialSetSurfaceProperties(RpMaterial *material, + const RwSurfaceProperties *surfaceProperties); + +extern const RwSurfaceProperties * +RpMaterialGetSurfaceProperties(const RpMaterial *material); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/* Attaching toolkits */ +extern RwInt32 RpMaterialRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpMaterialRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpMaterialSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpMaterialGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpMaterialValidatePlugins(const RpMaterial *material); + +/* Binary format */ +extern RwUInt32 RpMaterialStreamGetSize(const RpMaterial *material); +extern RpMaterial *RpMaterialStreamRead(RwStream *stream); +extern const RpMaterial *RpMaterialStreamWrite(const RpMaterial *material, RwStream *stream); +extern RpMaterialChunkInfo * +_rpMaterialChunkInfoRead(RwStream *stream, + RpMaterialChunkInfo *materialChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpMaterialChunkInfoRead(stream, materialChunkInfo, bytesRead) \ + _rpMaterialChunkInfoRead(stream, materialChunkInfo, bytesRead) + + +/*--- Automatically derived from: c:/daily/rwsdk/world/bamatlst.h ---*/ +/**************************************************************************** + Global Types + */ + +typedef struct RpMaterialList RpMaterialList; +struct RpMaterialList +{ + RpMaterial **materials; + RwInt32 numMaterials; + RwInt32 space; +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define rpMaterialListGetNumMaterials(mlist) ((mlist)->numMaterials) + +/* Setting up and destroying material lists */ +extern RpMaterialList *_rpMaterialListInitialize(RpMaterialList *matList); +extern RpMaterialList *_rpMaterialListDeinitialize(RpMaterialList *matList); + +/* Accessing material lists */ +extern RpMaterial ** _rpMaterialListAlloc(RwUInt32 count); +extern RpMaterial *_rpMaterialListGetMaterial(const RpMaterialList *matList, + RwInt32 matIndex); +extern RpMaterialList * _rpMaterialListSetSize(RpMaterialList * matList, + RwInt32 size); +extern RpMaterialList *_rpMaterialListCopy(RpMaterialList *matListOut, + const RpMaterialList *matListIn); +extern RwInt32 _rpMaterialListAppendMaterial(RpMaterialList *matList, + RpMaterial *material); +extern RwInt32 _rpMaterialListFindMaterialIndex(const RpMaterialList *matList, + const RpMaterial *material); + +/* Binary format */ +extern RwUInt32 _rpMaterialListStreamGetSize(const RpMaterialList *matList); +extern RpMaterialList *_rpMaterialListStreamRead(RwStream *stream, + RpMaterialList *matList); +extern const RpMaterialList *_rpMaterialListStreamWrite(const RpMaterialList *matList, + RwStream *stream); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define rpMaterialListInitialize(_matList) \ + _rpMaterialListInitialize(_matList) + +#define rpMaterialListDeinitialize(_matList) \ + _rpMaterialListDeinitialize(_matList) + +#define rpMaterialListGetMaterial(_matList, _matIndex) \ + _rpMaterialListGetMaterial(_matList, _matIndex) + +#define rpMaterialListCopy(_matListOut, _matListIn) \ + _rpMaterialListCopy(_matListOut, _matListIn) + +#define rpMaterialListAppendMaterial(_matList, _material) \ + _rpMaterialListAppendMaterial(_matList, _material) + +#define rpMaterialListStreamRead(_stream, _matList) \ + _rpMaterialListStreamRead(_stream, _matList) + +#define rpMaterialListStreamWrite(_matList, _stream) \ + _rpMaterialListStreamWrite(_matList, _stream) + + +/*--- Automatically derived from: c:/daily/rwsdk/world/bamesh.h ---*/ + +/* + * + * Purpose: Provide construction and enumeration facilities for meshes. + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + +#define RPMESHGLOBAL(var) \ + (RWPLUGINOFFSET(rpMeshGlobals, \ + RwEngineInstance, \ + meshModule.globalsOffset)->var) + +#define rwPRIMTYPEOR \ + (rwPRIMTYPELINELIST | \ + rwPRIMTYPEPOLYLINE | \ + rwPRIMTYPETRILIST | \ + rwPRIMTYPETRISTRIP | \ + rwPRIMTYPETRIFAN | \ + rwPRIMTYPEPOINTLIST) + +#define rpMESHHEADERPRIMTYPEOR \ + (0 /* rpMESHHEADERTRILIST*/ | \ + rpMESHHEADERTRISTRIP | \ + rpMESHHEADERTRIFAN | \ + rpMESHHEADERLINELIST | \ + rpMESHHEADERPOLYLINE | \ + rpMESHHEADERPOINTLIST) + +/**************************************************************************** + Global variables + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwModuleInfo meshModule; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/**************************************************************************** + Global types + */ + +/** + * \ingroup rpworlddatatypes + * \typedef RpMeshHeader + * typedef for header structure listing all meshes + * constituting a single RpGeometry or RpWorldSector + */ +typedef struct RpMeshHeader RpMeshHeader; + +/** + * \ingroup rpworlddatatypes + * \ref RpMeshHeaderFlags + * represents the different types of mesh. + * \see RpMeshHeader + */ +enum RpMeshHeaderFlags +{ + /* NOTE: trilists are denoted by absence of any other + * primtype flags, so be careful that you test: + * (triListFlag == flags&triListFlag) + * or: + * (0 == flags&rpMESHHEADERPRIMMASK) + * and not: + * (flags&triListFlag) + */ + rpMESHHEADERTRISTRIP = 0x0001, /**< Render as tristrips */ + rpMESHHEADERTRIFAN = 0x0002, /**< On PS2 these will be converted to trilists */ + rpMESHHEADERLINELIST = 0x0004, /**< Render as linelists */ + rpMESHHEADERPOLYLINE = 0x0008, /**< On PS2 these will be converted to linelists */ + rpMESHHEADERPOINTLIST = 0x0010, /**< Pointlists are supported only if rendered by + * custom pipelines; there is no default RenderWare + * way to render pointlists. */ + + rpMESHHEADERPRIMMASK = 0x00FF, /**< All bits reserved for specifying primitive type */ + rpMESHHEADERUNINDEXED = 0x0100, /**< Topology is defined implicitly by vertex + * order, ergo the mesh contains no indices */ + rpMESHHEADERFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +/* + * Typedef for RpMeshHeaderFlags enumeration + * representing the different types of mesh + */ +typedef enum RpMeshHeaderFlags RpMeshHeaderFlags; + +typedef struct rpMeshGlobals rpMeshGlobals; +struct rpMeshGlobals +{ + RwInt16 nextSerialNum; + RwFreeList *triStripListEntryFreeList; + RwUInt8 meshFlagsToPrimType[rpMESHHEADERPRIMTYPEOR]; + RwUInt8 primTypeToMeshFlags[rwPRIMTYPEOR]; +}; + +typedef struct RpBuildMeshTriangle RpBuildMeshTriangle; + +/** + * \ingroup rpworlddatatypes + * \struct RpBuildMeshTriangle + * This type represents an array of indices into + * the object vertex array. Used during the construction + * of tristrips. + * + * See API functions + * \see RpBuildMeshGeneratePreprocessTriStrip + * \see RpBuildMeshGenerateExhaustiveTriStrip + * \see RpBuildMeshGenerateTrivialTriStrip + * \see RpBuildMeshGenerateDefaultTriStrip + * and + * \see RpMeshSetTriStripMethod + * \see RpMeshGetTriStripMethod + */ +struct RpBuildMeshTriangle +{ + RwUInt16 vertIndex[3]; /**< indices into object vertex + * array. */ + RpMaterial *material; /**< pointer to material used to + * render the mesh. */ +}; + +typedef struct RpBuildMesh RpBuildMesh; + +/** + * \ingroup rpworlddatatypes + * \struct RpBuildMesh + * This type represents a mesh ready for tri stripping. + * + * See API functions + * \see RpBuildMeshGeneratePreprocessTriStrip + * \see RpBuildMeshGenerateExhaustiveTriStrip + * \see RpBuildMeshGenerateTrivialTriStrip + * \see RpBuildMeshGenerateDefaultTriStrip + * and + * \see RpMeshSetTriStripMethod + * \see RpMeshGetTriStripMethod + */ +struct RpBuildMesh +{ + RwUInt32 triangleBufferSize; /**< number of triangles + * space has been allocated + * for. */ + RwUInt32 numTriangles; /**< number of triangles to be + * tristripped. */ + RpBuildMeshTriangle *meshTriangles; /**< pointer to build mesh + * triangles. */ +}; + +typedef struct RpMesh RpMesh; + +/** + * \ingroup rpworlddatatypes + * \struct RpMesh + * This type represents a single polygon mesh. + * A mesh is defined as a collection of triangles derived from an RpGeometry + * or RpWorldSector which have a common material. + * + * See API functions \see RpGeometryForAllMeshes and + * \see RpWorldSectorForAllMeshes and + * the corresponding function callback types: + */ +struct RpMesh +{ + RxVertexIndex *indices; /**< vertex indices defining the mesh */ + RwUInt32 numIndices; /**< number of vertices in mesh */ + RpMaterial *material; /**< pointer to material used to + * render the mesh. */ +}; + +/** + * \ingroup rpworlddatatypes + * \struct RpMeshHeader + * Header for all meshes that constitute a single RpGeometry or RpWorldSector + */ +struct RpMeshHeader +{ + RwUInt32 flags; /**< \see RpMeshHeaderFlags */ + RwUInt16 numMeshes; /**< Number of meshes in object */ + RwUInt16 serialNum; /**< Determine if mesh has changed + * since last instance */ + RwUInt32 totalIndicesInMesh; /**< Total triangle index + * count in all meshes + */ + RwUInt32 firstMeshOffset; /**< Offset in bytes from end this + * structure RpMeshHeader + * to the first mesh + */ +}; + +/** + * \ingroup rpworlddatatypes + * \typedef RpMeshCallBack + * \ref RpMeshCallBack is the callback + * function supplied to \ref RpGeometryForAllMeshes and + * \ref RpWorldSectorForAllMeshes for all meshes in a given geometry. + * + * This function should return a pointer to the current mesh to indicate + * success. The callback may return NULL to terminate further callbacks + * on the meshes. + * + * \param mesh Pointer to the current mesh, supplied by + * iterator. + * \param meshHeader Pointer to the meshes header + * \param data Pointer to developer-defined data structure. + * + * \return + * Returns a pointer to the current mesh if successful or NULL if an error + * occurred. + */ +typedef RpMesh *(*RpMeshCallBack) (RpMesh * mesh, + RpMeshHeader * meshHeader, + void *pData); + +/**************************************************************************** + Function prototypes + */ + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMeshHeaderGetPrimType(_mshHdr) \ + ( (RwPrimitiveType)RPMESHGLOBAL(meshFlagsToPrimType)[(_mshHdr)->flags & \ + rpMESHHEADERPRIMMASK] ) + +#define RpMeshHeaderSetPrimType(_mshHdr, _prmTyp) \ + ( (_mshHdr)->flags = \ + ((_mshHdr)->flags & ~rpMESHHEADERPRIMMASK) | \ + (rpMESHHEADERPRIMMASK & \ + RPMESHGLOBAL(primTypeToMeshFlags)[(_prmTyp) & \ + rpMESHHEADERPRIMMASK]), \ + (_mshHdr) ) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Opening and closing module */ +extern void *_rpMeshOpen(void *instance, RwInt32 offset, + RwInt32 size); +extern void *_rpMeshClose(void *instance, RwInt32 offset, + RwInt32 size); + +extern RwInt16 _rpMeshGetNextSerialNumber(void); + +/* Create a build mesh with nothing in */ +extern RpBuildMesh *_rpBuildMeshCreate(RwUInt32 bufferSize); + +/* Destroy a build mesh */ +extern RwBool _rpBuildMeshDestroy(RpBuildMesh * mesh); + +/* Destroy a build mesh */ +extern RwBool _rpMeshDestroy(RpMeshHeader * mesh); + +/* Add a triangle to a mesh */ +extern RpBuildMesh *_rpBuildMeshAddTriangle(RpBuildMesh * mesh, + RpMaterial * material, + RwInt32 vert1, + RwInt32 vert2, + RwInt32 vert3); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +/* Get primtype from a mesh header */ +extern RwPrimitiveType RpMeshHeaderGetPrimType(RpMeshHeader * + meshHeader); + +/* Set primtype for a mesh header */ +extern RpMeshHeader *RpMeshHeaderSetPrimType(RpMeshHeader * + meshHeader, + RwPrimitiveType + primType); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* Enumerate meshes within a mesh header */ +extern RpMeshHeader *_rpMeshHeaderForAllMeshes(RpMeshHeader * + meshHeader, + RpMeshCallBack + fpCallBack, + void *pData); + +/* Mesh serialisation functions */ +extern RwStream *_rpMeshWrite(const RpMeshHeader * meshHeader, + const void *object, + RwStream * stream, + const RpMaterialList * matList); +extern RpMeshHeader *_rpMeshRead(RwStream * stream, + const void *object, + const RpMaterialList * matList); +extern RwInt32 _rpMeshSize(const RpMeshHeader *meshHeader, + const void *object); +/* Mesh header create/destroy functions */ +extern void _rpMeshHeaderDestroy(RpMeshHeader * meshHeader); +extern RpMeshHeader * _rpMeshHeaderCreate(RwUInt32 size); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: c:/daily/rwsdk/world/basector.h ---*/ + +/* + * Handling atomic sectors + * Atomic sectors are use to divide up the world into manageable portions + * + * Copyright (c) 1998 Criterion Software Ltd. +*/ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpWorldSector 0xff /* Not a true 'type'! */ + +#define rpMINDISTANCEBETWEENVERTICES (RwReal)(0.0001) + +#define RPV3DFROMVERTEXNORMAL(v, n) \ + (v).x = (((RwReal)((n).x)) * ( (RwReal)(1.0/128))); \ + (v).y = (((RwReal)((n).y)) * ( (RwReal)(1.0/128))); \ + (v).z = (((RwReal)((n).z)) * ( (RwReal)(1.0/128))) + +#define RPVERTEXNORMALFROMRWV3D(n, v) \ + { \ + RwFixed naTmp[3]; \ + \ + naTmp[0] = RwRealToFixed((v).x); \ + naTmp[1] = RwRealToFixed((v).y); \ + naTmp[2] = RwRealToFixed((v).z); \ + \ + if (naTmp[0] >= RwFixedCast(1)) \ + { \ + naTmp[0] = RwFixedCast(1)-1; \ + } \ + if (naTmp[0] <= RwFixedCast(-1)) \ + { \ + naTmp[0] = RwFixedCast(-1)+1; \ + } \ + if (naTmp[1] >= RwFixedCast(1)) \ + { \ + naTmp[1] = RwFixedCast(1)-1; \ + } \ + if (naTmp[1] <= RwFixedCast(-1)) \ + { \ + naTmp[1] = RwFixedCast(-1)+1; \ + } \ + if (naTmp[2] >= RwFixedCast(1)) \ + { \ + naTmp[2] = RwFixedCast(1)-1; \ + } \ + if (naTmp[2] <= RwFixedCast(-1)) \ + { \ + naTmp[2] = RwFixedCast(-1)+1; \ + } \ + \ + (n).x = (RwInt8)(naTmp[0]>>9); \ + (n).y = (RwInt8)(naTmp[1]>>9); \ + (n).z = (RwInt8)(naTmp[2]>>9); \ + } + +/* RpCollSector access macros - for pre v304 data */ +#define RWCOLLSECTORGETTYPE(sect) \ + ((sect).cType&0x80) + +#define RWCOLLSECTORGETPLANE(sect) \ + ((((sect).cType)>>3)&0xc) + +#define RWCOLLSECTORGETON(sect) \ + (((sect).cType)&0x1f) + +#define RWCOLLSECTORGETVERTEX(sect) \ + (sect).vertex + +#define RWCOLLSECTORGETSTART(sect) \ + (sect).start + +#define RWCOLLSECTORGETNOPOLYS(sect) \ + (sect).cType + +#define RWCOLLSECTORSETPOLYGONS(sect,no,st) \ + (sect).cType = (RwUInt8)(no); \ + (sect).start = (RwUInt8)(st) + +#define rwMAXCOLLISIONCUTS 7 + +/**************************************************************************** + Global types + */ + +typedef struct RpVertexNormal RpVertexNormal; + +struct RpVertexNormal +{ + RwInt8 x; + RwInt8 y; + RwInt8 z; + RwUInt8 pad; /* pad character to force alignment */ +}; + +typedef struct RpPolygon RpPolygon; + +struct RpPolygon +{ + RwUInt16 matIndex; + RwUInt16 vertIndex[3]; +}; + +/* RpCollSector - for pre v304 data */ +#define RWCOLLSECTORSETPLANE(sect,plane,vert,no,st) \ + (sect).cType = (RwUInt8)(0x80|((plane)<<3)|(no)); \ + (sect).vertex = (RwUInt8)(vert); \ + (sect).start = (RwUInt8)(st) + +typedef struct RpCollSector RpCollSector; + +struct RpCollSector +{ + RwUInt8 cType; /* Bit 7 - 1 plane */ + /* 0 polygons */ + /* Bit 6-5 - plane */ + /* Bit 4-0 - amount ON plane */ + RwUInt8 vertex; /* Vertex index used for the split */ + RwUInt8 start; /* Starting polygon */ +}; + +/** + * \ingroup rpworlddatatypes + * \typedef RpWorldSector + * World Sector object. This should be + * considered an opaque type. Use the RpWorldSector API functions to access. + */ +typedef struct RpWorldSector RpWorldSector; + +#if (!defined(DOXYGEN)) +struct RpWorldSector +{ + RwInt32 type; + + RpPolygon *polygons; /* Polygons themselves */ + + RwV3d *vertices; /* Vertex positions */ + RpVertexNormal *normals; /* Vertex normals */ + + RwTexCoords *texCoords[rwMAXTEXTURECOORDS]; /* Texture coordinates */ + + RwRGBA *preLitLum; /* Pre lit luminances */ + + /* Pointer to memory allocated for vertex and poly pointers */ + RwResEntry *repEntry; + + /* Atomics in this sectors */ + /* The pointers are frigged so they look like they are pointing to + Atomics when they are pointing to here */ + RwLinkList collAtomicsInWorldSector; /* Coll priority */ + RwLinkList noCollAtomicsInWorldSector; /* No Coll priority */ + + /* Lights in an atomic sector */ + RwLinkList lightsInWorldSector; + + /* Outer bounding box of sector based on BSP planes */ + RwBBox boundingBox; + + /* Bounding box tightly enclosing geometry */ + RwBBox tightBoundingBox; + + /* The root of the bsp collision tree for pre v304 data */ + RpCollSector *colSectorRoot; + + /* The mesh which groups same material polygons together */ + RpMeshHeader *mesh; + + /* The WorldSector object pipeline for this WorldSector */ + RxPipeline *pipeline; + + /* Material list window base + * (triangles in a given sector can "see" + * the 256 materials from + * MatList[matListWindowBase] -> MatList[matListWindowBase + 255]) + */ + RwUInt16 matListWindowBase; + + RwUInt16 numVertices; /* Num vertices */ + RwUInt16 numPolygons; /* Num polygons */ + RwUInt16 pad; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup rpworlddatatypes + * \typedef RpWorldSectorCallBack + \ref RpWorldSectorCallBack + * represents the function called from \ref RpWorldForAllWorldSectors, + * \ref RpAtomicForAllWorldSectors and \ref RpLightForAllWorldSectors for all + * world sectors in a given world or world sectors a given atomic or light lies + * in. This function should return a pointer to the current world sector to + * indicate success. The callback may return NULL to terminate further + * callbacks on the atomic or light. + * + * \return Pointer to the current world sector. + * + * \param sector Pointer to the current world sector + * \param data Pointer to developer-defined data structure. + */ +typedef RpWorldSector *(*RpWorldSectorCallBack)(RpWorldSector *worldSector, void *data); + +typedef struct RpSector RpSector; + +struct RpSector +{ + RwInt32 type; +}; + +/* NOTE: The left and right pointers can point to an RpPlaneSector or + * an RpWorldSector + * This is determined what the type is via the type value + */ + +typedef struct RpPlaneSector RpPlaneSector; + +struct RpPlaneSector +{ + RwInt32 type; + + RwReal value; + RpSector *leftSubTree; /* Sector 'left' (less) of the plane */ + RpSector *rightSubTree; /* Sector 'right' (more) of the plane */ + RwReal leftValue; + RwReal rightValue; +}; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwPluginRegistry sectorTKList; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpWorldSectorGetBBoxMacro(_sctr) (&((_sctr)->boundingBox)) +#define RpWorldSectorGetTightBBoxMacro(_sctr) (&((_sctr)->tightBoundingBox)) + +#if ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) + +#define RpWorldSectorGetBBox RpWorldSectorGetBBoxMacro +#define RpWorldSectorGetTightBBox RpWorldSectorGetTightBBoxMacro + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Get info from atomic sectors */ +extern RwInt32 RpWorldSectorGetNumPolygons(const RpWorldSector *Sector); +extern RwInt32 RpWorldSectorGetNumVertices(const RpWorldSector *Sector); + +/* Instancing and deinstancing sectors */ +extern RpWorldSector * RpWorldSectorRender(RpWorldSector *worldSector); + +extern const RpWorldSector *RpWorldSectorForAllMeshes(const RpWorldSector *sector, + RpMeshCallBack fpCallBack, + void *pData); + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern const RwBBox *RpWorldSectorGetBBox(const RpWorldSector *sector); +extern const RwBBox *RpWorldSectorGetTightBBox(const RpWorldSector *sector); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* Plugins */ +extern RwInt32 RpWorldSectorRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpWorldSectorRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpWorldSectorSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpWorldSectorSetStreamRightsCallBack(RwUInt32 pluginID, + RwPluginDataChunkRightsCallBack rightsCB); +extern RwInt32 RpWorldSectorGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpWorldSectorValidatePlugins(const RpWorldSector *sector); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: c:/daily/rwsdk/world/bameshop.h ---*/ + +/**************************************************************************** + Defines + */ + +/** + * \ingroup rpworlddatatypes + * \typedef RpTriStripMeshCallBack + * \ref RpTriStripMeshCallBack is the callback to generate triangle strips + * when the triangle stripped geometries or world sectors are unlocked. + * + * \param buildMesh pointer to the mesh which the triangle strip will be + * generated from. + * \param data pointer to user-supplied data to pass to the callback + * function. + * + * \return a pointer to the constructed mesh header. + * + */ +typedef RpMeshHeader * +(*RpTriStripMeshCallBack) (RpBuildMesh *buildMesh, void *data); + + +/**************************************************************************** + Global types + */ + + +/**************************************************************************** + Global Variables + */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Callback mesh generating functions */ +extern RpMeshHeader * +RpBuildMeshGenerateTrivialTriStrip(RpBuildMesh *buildMesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateDefaultTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGeneratePreprocessTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateExhaustiveTriStrip(RpBuildMesh *buildmesh, void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateDefaultIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +extern RpMeshHeader * +RpBuildMeshGeneratePreprocessIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +extern RpMeshHeader * +RpBuildMeshGenerateExhaustiveIgnoreWindingTriStrip(RpBuildMesh *buildmesh, + void *data); + +/* Functions to set and get the global mesh tristrip algorithm */ +extern RwBool +RpMeshSetTriStripMethod(RpTriStripMeshCallBack callback, void *data); + +extern RwBool +RpMeshGetTriStripMethod(RpTriStripMeshCallBack *callback, void **data); + + +extern RpMeshHeader * +_rpTriListMeshGenerate(RpBuildMesh *buildMesh, void *data); + +/* + * Optimise the mesh ordering + * (sort on material and place transparent materials last) + */ +extern RpMeshHeader * +_rpMeshOptimise(RpBuildMesh *buildmesh, RwUInt32 flags); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#define _rpTriStripMeshTrivialGenerate(_buildMesh, _data) \ + RpBuildMeshGenerateTrivialTriStrip(_buildMesh, _data) + +#define _rpTriStripMeshDefaultGenerate(_buildmesh, _data) \ + RpBuildMeshGenerateDefaultTriStrip(_buildmesh, _data) + +#define _rpTriStripMeshPreprocessGenerate(_buildmesh, _data) \ + RpBuildMeshGeneratePreprocessTriStrip(_buildmesh, _data) + +#define _rpTriStripMeshExhaustiveGenerate(_buildmesh, _data) \ + RpBuildMeshGenerateExhaustiveTriStrip(_buildmesh, _data) + +#define _rpMeshSetTristripMethod(_callback, _data) \ + RpMeshSetTriStripMethod(_callback, _data) + +#define _rpMeshGetTristripMethod(_callback, _data) \ + RpMeshGetTriStripMethod(_callback, _data) + + + +/*--- Automatically derived from: c:/daily/rwsdk/world/balight.h ---*/ + +/* + * Lighting 3D objects. + * Lights are used to illuminate atomics and worlds + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + + +/**************************************************************************** + Defines + */ + +/* Binary Light */ +typedef struct RpLightChunkInfo RpLightChunkInfo; +typedef struct RpLightChunkInfo _rpLight; + +struct RpLightChunkInfo +{ + RwReal radius; /**< radius */ + RwReal red; /**< red */ + RwReal green; /**< green */ + RwReal blue; /**< blue */ + RwReal minusCosAngle; /**< minusCosAngle */ + RwUInt32 typeAndFlags; /**< typeAndFlags */ +}; + +/* Type ID */ +#define rpLIGHT 3 + +/* Beyond this the lights must be positioned */ +#define rpLIGHTPOSITIONINGSTART 0x80 + +/** + * \ingroup rpworlddatatypes + * \ref RpLightType are + * light sub types. This type represents the different + * types of light source that can be created using the API function \ref RpLightCreate. + * Note that lights of types rpLIGHTPOINT, rpLIGHTSPOT and rpLIGHTSPOTSOFT have linear + * intensity fall-off with distance from the source, reducing to zero at the light's radius:*/ +enum RpLightType +{ + rpNALIGHTTYPE = 0, + + /* These don't take part in the tie mechanism (no position) */ + rpLIGHTDIRECTIONAL, /**radius) + +#define RpLightGetColorMacro(_light) \ + (&((_light)->color)) + +#define RpLightSetFrameMacro(_light, _frame) \ + (rwObjectHasFrameSetFrame((_light), (_frame)), (_light)) + +#define RpLightGetFrameMacro(_light) \ + ((RwFrame *)rwObjectGetParent((_light))) + +#define RpLightGetTypeMacro(_light) \ + ((RpLightType)rwObjectGetSubType((_light))) + +#define RpLightSetFlagsMacro(_light, _flags) \ + ((rwObjectSetFlags((_light), (_flags))), (_light)) + +#define RpLightGetFlagsMacro(_light) \ + (rwObjectGetFlags((_light))) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpLightGetRadius(_light) \ + RpLightGetRadiusMacro(_light) + +#define RpLightGetColor(_light) \ + RpLightGetColorMacro(_light) + +#define RpLightSetFrame(_light, _frame) \ + RpLightSetFrameMacro(_light, _frame) + +#define RpLightGetFrame(_light) \ + RpLightGetFrameMacro(_light) + +#define RpLightGetType(_light) \ + RpLightGetTypeMacro(_light) + +#define RpLightSetFlags(_light, _flags) \ + RpLightSetFlagsMacro(_light, _flags) + +#define RpLightGetFlags(_light) \ + RpLightGetFlagsMacro(_light) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwReal RpLightGetRadius(const RpLight *light); +extern const RwRGBAReal *RpLightGetColor(const RpLight *light); +extern RpLight *RpLightSetFrame(RpLight *light, RwFrame *frame); +extern RwFrame *RpLightGetFrame(const RpLight *light); +extern RpLightType RpLightGetType(const RpLight *light); +extern RpLight *RpLightSetFlags(RpLight *light, RwUInt32 flags); +extern RwUInt32 RpLightGetFlags(const RpLight *light); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* API Functions */ +extern RpLight *RpLightCreate(RwInt32 type); +extern RwBool RpLightDestroy(RpLight *light); +extern RpLight *RpLightSetRadius(RpLight *light, RwReal radius); +extern RpLight *RpLightSetColor(RpLight *light, const RwRGBAReal *color); +extern RwReal RpLightGetConeAngle(const RpLight *light); +extern RpLight *RpLightSetConeAngle(RpLight * ight, RwReal angle); +extern RwUInt32 RpLightStreamGetSize(const RpLight *light); +extern RpLight *RpLightStreamRead(RwStream *stream); +extern const RpLight *RpLightStreamWrite(const RpLight *light, + RwStream *stream); +extern RpLightChunkInfo *_rpLightChunkInfoRead(RwStream *stream, + RpLightChunkInfo *lightChunkInfo, + RwInt32 *bytesRead); + +/* Attaching toolkits */ +extern RwInt32 RpLightRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RpLightRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RpLightSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwInt32 RpLightGetPluginOffset(RwUInt32 pluginID); +extern RwBool RpLightValidatePlugins(const RpLight * light); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpLightChunkInfoRead(stream, lightChunkInfo, bytesRead) \ + _rpLightChunkInfoRead(stream, lightChunkInfo, bytesRead) + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/d3d8/D3D8lights.h ---*/ +/** + * \ingroup rplightd3d8 + * \typedef RpD3D8AttenuationParams + * typedef for struct RpD3D8AttenuationParams + */ +typedef struct RpD3D8AttenuationParams RpD3D8AttenuationParams; +/** + * \ingroup rplightd3d8 + * \struct RpD3D8AttenuationParams + * This type represents the attenuation model of a spot or point light. + */ +struct RpD3D8AttenuationParams +{ + RwReal constant; /**< Constant attenuation coefficient */ + RwReal linear; /**< Linear attenuation coefficient */ + RwReal quadratic; /**< Quadratic attenuation coefficient */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void +RpD3D8LightSetAttenuationParams(RpLight *light, + const RpD3D8AttenuationParams *params); + +extern void +RpD3D8LightGetAttenuationParams(const RpLight *light, + RpD3D8AttenuationParams *params); + +extern RwBool +_rwD3D8LightsOpen(void); + +extern RwBool +_rwD3D8LightsGlobalEnable(RpLightFlag flags); + +extern RwBool +_rwD3D8LightDirectionalEnable(RpLight *light); + +extern RwBool +_rwD3D8LightLocalEnable(RpLight *light); + +extern void +_rwD3D8LightsEnable(RwBool enable, RwUInt32 type); + +extern void +_rwD3D8LightsClose(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/world/pipe/p2/p2stdclsw.h ---*/ +typedef RpLight *RxLight; +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxClusterDefinition RxClLights; /* Uses the RxLight type (see above) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + + +/*--- Automatically derived from: c:/daily/rwsdk/world/bageomet.h ---*/ + +/* + * Handling atomic's geometry + * Geometry describe objects, and are the building blocks for atomics + * + * Copyright (c) 1998 Criterion Software Ltd. +*/ + + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpGEOMETRY 8 + +/** + * \ingroup rpworlddatatypes + * RpGeometryFlag + * Geometry type flags + * + * When creating a geometry, these flags can be OR'ed together to + * specify the format along with the rpGEOMETRYTEXCOORDSETS(n) macro if more + * than two sets of texture coordinates are required. See \ref RpGeometryCreate + * for more details. + * + * \see RpGeometryCreate(). + */ +enum RpGeometryFlag +{ + rpGEOMETRYTRISTRIP = 0x00000001, /**boundingSphere), (_sphere)), (_mt)) + +#define RpMorphTargetGetBoundingSphereMacro(_mt) \ + (&((_mt)->boundingSphere)) + +#define RpGeometryGetNumMorphTargetsMacro(_geometry) \ + ((_geometry)->numMorphTargets) + +#define RpGeometryGetMorphTargetMacro(_geometry, _index) \ + (&((_geometry)->morphTarget[(_index)])) + +#define RpGeometryGetPreLightColorsMacro(_geometry) \ + ((_geometry)->preLitLum) + +#define RpGeometryGetVertexTexCoordsMacro(_geometry, _uvIndex) \ + ((_geometry)->texCoords[(_uvIndex) - 1]) + +#define RpGeometryGetNumTexCoordSetsMacro(_geometry) \ + ((_geometry)->numTexCoordSets) + +#define RpGeometryGetNumVerticesMacro(_geometry) \ + ((_geometry)->numVertices) + +#define RpMorphTargetGetVerticesMacro(_mt) \ + ((_mt)->verts) + +#define RpMorphTargetGetVertexNormalsMacro(_mt) \ + ((_mt)->normals) + +#define RpGeometryGetTrianglesMacro(_geometry) \ + ((_geometry)->triangles) + +#define RpGeometryGetNumTrianglesMacro(_geometry) \ + ((_geometry)->numTriangles) + +#define RpGeometryGetMaterialMacro(_geometry, _num) \ + (((_geometry)->matList.materials)[(_num)]) + +#define RpGeometryGetNumMaterialsMacro(_geometry) \ + ((_geometry)->matList.numMaterials) + +#define RpGeometryGetFlagsMacro(_geometry) \ + ((_geometry)->flags) + +#define RpGeometrySetFlagsMacro(_geometry, _flags) \ + (((_geometry)->flags = (_flags)), (_geometry)) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpMorphTargetSetBoundingSphere(_geometry, _sphere) \ + RpMorphTargetSetBoundingSphereMacro(_geometry, _sphere) + +#define RpMorphTargetGetBoundingSphere(_geometry) \ + RpMorphTargetGetBoundingSphereMacro(_geometry) + +#define RpGeometryGetNumMorphTargets(_geometry) \ + RpGeometryGetNumMorphTargetsMacro(_geometry) + +#define RpGeometryGetMorphTarget(_geometry, _index) \ + RpGeometryGetMorphTargetMacro(_geometry, _index) + +#define RpGeometryGetPreLightColors(_geometry) \ + RpGeometryGetPreLightColorsMacro(_geometry) + +#define RpGeometryGetVertexTexCoords(_geometry, _uvIndex) \ + RpGeometryGetVertexTexCoordsMacro(_geometry, _uvIndex) + +#define RpGeometryGetNumTexCoordSets(_geometry) \ + RpGeometryGetNumTexCoordSetsMacro(_geometry) + +#define RpGeometryGetNumVertices(_geometry) \ + RpGeometryGetNumVerticesMacro(_geometry) + +#define RpMorphTargetGetVertices(_mt) \ + RpMorphTargetGetVerticesMacro(_mt) + +#define RpMorphTargetGetVertexNormals(_mt) \ + RpMorphTargetGetVertexNormalsMacro(_mt) + +#define RpGeometryGetTriangles(_geometry) \ + RpGeometryGetTrianglesMacro(_geometry) + +#define RpGeometryGetNumTriangles(_geometry) \ + RpGeometryGetNumTrianglesMacro(_geometry) + +#define RpGeometryGetMaterial(_geometry, _num) \ + RpGeometryGetMaterialMacro(_geometry, _num) + +#define RpGeometryGetNumMaterials(_geometry) \ + RpGeometryGetNumMaterialsMacro(_geometry) + +#define RpGeometryGetFlags(_geometry) \ + RpGeometryGetFlagsMacro(_geometry) + +#define RpGeometrySetFlags(_geometry, _flags) \ + RpGeometrySetFlagsMacro(_geometry, _flags) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Transforms geometry morph target vertices */ + +extern RpGeometry * +RpGeometryTransform(RpGeometry *geometry, + const RwMatrix *matrix); + +/* Create geometry for a 'space' marker */ + +extern RpGeometry * +RpGeometryCreateSpace(RwReal radius); + +/* Morph targets - Accessing geometry contents */ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RpMorphTarget * +RpMorphTargetSetBoundingSphere(RpMorphTarget *morphTarget, + const RwSphere *boundingSphere); + +extern RwSphere * +RpMorphTargetGetBoundingSphere(RpMorphTarget *morphTarget); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpMorphTarget * +RpMorphTargetCalcBoundingSphere(const RpMorphTarget *morphTarget, + RwSphere *boundingSphere); + +extern RwInt32 +RpGeometryAddMorphTargets(RpGeometry *geometry, + RwInt32 mtcount); + +extern RwInt32 +RpGeometryAddMorphTarget(RpGeometry *geometry); + +extern RpGeometry * +RpGeometryRemoveMorphTarget(RpGeometry *geometry, + RwInt32 morphTarget); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpGeometryGetNumMorphTargets(const RpGeometry *geometry); + +extern RpMorphTarget * +RpGeometryGetMorphTarget(const RpGeometry *geometry, + RwInt32 morphTarget); + +extern RwRGBA * +RpGeometryGetPreLightColors(const RpGeometry *geometry); + +extern RwTexCoords * +RpGeometryGetVertexTexCoords(const RpGeometry *geometry, + RwTextureCoordinateIndex uvIndex); + +extern RwInt32 +RpGeometryGetNumTexCoordSets(const RpGeometry *geometry); + +extern RwInt32 +RpGeometryGetNumVertices (const RpGeometry *geometry); + +extern RwV3d * +RpMorphTargetGetVertices(const RpMorphTarget *morphTarget); + +extern RwV3d * +RpMorphTargetGetVertexNormals(const RpMorphTarget *morphTarget); + +extern RpTriangle * +RpGeometryGetTriangles(const RpGeometry *geometry); + +extern RwInt32 +RpGeometryGetNumTriangles(const RpGeometry *geometry); + +extern RpMaterial * +RpGeometryGetMaterial(const RpGeometry *geometry, + RwInt32 matNum); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpGeometry * +RpGeometryTriangleSetVertexIndices(const RpGeometry *geometry, + RpTriangle *triangle, + RwUInt16 vert1, + RwUInt16 vert2, + RwUInt16 vert3); + +extern RpGeometry * +RpGeometryTriangleSetMaterial(RpGeometry *geometry, + RpTriangle *triangle, + RpMaterial *material); + +extern const RpGeometry * +RpGeometryTriangleGetVertexIndices(const RpGeometry *geometry, + const RpTriangle *triangle, + RwUInt16 *vert1, + RwUInt16 *vert2, + RwUInt16 *vert3); + +extern RpMaterial * +RpGeometryTriangleGetMaterial(const RpGeometry *geometry, + const RpTriangle *triangle); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 +RpGeometryGetNumMaterials(const RpGeometry *geometry); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RpGeometry * +RpGeometryForAllMaterials(RpGeometry *geometry, + RpMaterialCallBack fpCallBack, + void *pData); + +/* Accessing the inards of geometry */ +extern RpGeometry * +RpGeometryLock(RpGeometry *geometry, + RwInt32 lockMode); + +extern RpGeometry * +RpGeometryUnlock(RpGeometry *geometry); + +extern const RpGeometry * +RpGeometryForAllMeshes(const RpGeometry *geometry, + RpMeshCallBack fpCallBack, + void *pData); + +/* Creation and destruction */ +extern RpGeometry * +RpGeometryCreate(RwInt32 numVert, + RwInt32 numTriangles, + RwUInt32 format); + +extern RwBool +RpGeometryDestroy(RpGeometry *geometry); + +extern RpGeometry * +_rpGeometryAddRef(RpGeometry *geometry); + +/* Attaching toolkits */ +extern RwInt32 +RpGeometryRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpGeometryRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RpGeometrySetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpGeometryGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RpGeometryValidatePlugins(const RpGeometry *geometry); + +/* Binary format */ +extern RwUInt32 +RpGeometryStreamGetSize(const RpGeometry *geometry); + +extern const RpGeometry * +RpGeometryStreamWrite(const RpGeometry *geometry, + RwStream *stream); + +extern RpGeometry * +RpGeometryStreamRead(RwStream *stream); + +extern RpGeometryChunkInfo * +_rpGeometryChunkInfoRead(RwStream *stream, + RpGeometryChunkInfo *geometryChunkInfo, + RwInt32 *bytesRead); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +/* Flags */ +extern RwUInt32 +RpGeometryGetFlags(const RpGeometry *geometry); + +extern RpGeometry * +RpGeometrySetFlags(RpGeometry *geometry, + RwUInt32 flags); + +#endif + +/* Lighting characteristics */ + +extern const RwSurfaceProperties * +_rpGeometryGetSurfaceProperties(const RpGeometry *geometry); + +extern RpGeometry * +_rpGeometrySetSurfaceProperties(RpGeometry *geometry, + const RwSurfaceProperties *surfaceProperties); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpGeometryGetSurfaceProperties(_geometry) \ + _rpGeometryGetSurfaceProperties(_geometry) + +#define RpGeometrySetSurfaceProperties(_geometry, _surfaceProperties) \ + _rpGeometrySetSurfaceProperties(_geometry, _surfaceProperties) + +#define rpGeometryAddRef(_geometry) \ + _rpGeometryAddRef(_geometry) + +#define RpGeometryChunkInfoRead(stream, geometryChunkInfo, bytesRead) \ + _rpGeometryChunkInfoRead(stream, geometryChunkInfo, bytesRead) + + +/*--- Automatically derived from: c:/daily/rwsdk/world/baclump.h ---*/ + +/* + * Clump and atomic handling. + * Clumps and atomics are the movable rendered objects in the world + * + * Copyright (c) 1998 Criterion Software Ltd. + */ + + +/**************************************************************************** + Defines + */ + +/****************************** Object type ID ******************************/ + +/* Type IDs */ + +#define rpATOMIC 1 +#define rpCLUMP 2 + +/* Interpolator flags */ +enum RpInterpolatorFlag +{ + rpINTERPOLATORDIRTYINSTANCE = 0x01, + rpINTERPOLATORDIRTYSPHERE = 0x02, + rpINTERPOLATORNOFRAMEDIRTY = 0x04, + rpINTERPOLATORFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpInterpolatorFlag rpInterpolatorFlag; + +/** + * \ingroup rpworlddatatypes + * The bit-field type RpAtomicFlag specifies the options available for + * controlling the behavior of atomics. See API function \ref RpAtomicSetFlags. + * + * \see RpAtomicSetFlags + * \see RpAtomicGetFlags + * \see RpWorldSectorForAllCollisionAtomics + */ + +enum RpAtomicFlag +{ + rpATOMICCOLLISIONTEST = 0x01, /**renderCallBack(_atomic)) + +#define RpAtomicGetGeometryMacro(_atomic) \ + ((_atomic)->geometry) + +#if (!defined(RpAtomicSetRenderCallBackMacro)) + +/* NB "RpAtomicSetRenderCallBack(atom++, callback)" will break it */ +#define RpAtomicSetRenderCallBackMacro(_atomic, _callback) \ +MACRO_START \ +{ \ + (_atomic)->renderCallBack = (_callback); \ + if (!(_atomic)->renderCallBack) \ + { \ + (_atomic)->renderCallBack = AtomicDefaultRenderCallBack; \ + } \ +} \ +MACRO_STOP + +#endif /* (!defined(RpAtomicSetRenderCallBackMacro)) */ + +#define RpAtomicGetRenderCallBackMacro(_atomic) \ + ((_atomic)->renderCallBack) + +#define RpAtomicGetInterpolatorMacro(_atomic) \ + (&((_atomic)->interpolator)) + +#define RpInterpolatorGetStartMorphTargetMacro(_intrp) \ + ((_intrp)->startMorphTarget) + +#define RpInterpolatorGetEndMorphTargetMacro(_intrp) \ + ((_intrp)->endMorphTarget) + +#define RpInterpolatorGetValueMacro(_intrp) \ + ((_intrp)->position) + +#define RpInterpolatorGetScaleMacro(_intrp) \ + ((_intrp)->time) + +/* NB "RpInterpolatorSetStartMorphTarget(interp++, target)" will break it */ +#define RpInterpolatorSetStartMorphTargetMacro(_intrp, _target, _atomic)\ + ((_intrp)->startMorphTarget = (RwInt16) (_target), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetEndMorphTarget(interp++, target)" will break it */ +#define RpInterpolatorSetEndMorphTargetMacro(_intrp, _target, _atomic) \ + ((_intrp)->endMorphTarget = (RwInt16) (_target), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetValue(interp++, value)" will break it */ +#define RpInterpolatorSetValueMacro(_intrp, _value, _atomic) \ + ((_intrp)->position = (_value), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +/* NB "RpInterpolatorSetScale(interp++, *(scale++))" will break it */ +#define RpInterpolatorSetScaleMacro(_intrp, _scale, _atomic) \ + ((_intrp)->time = (_scale), \ + (_intrp)->recipTime = (RwReal) (1.0) / (_scale), \ + (_intrp)->flags |= (RwInt32)(rpINTERPOLATORDIRTYINSTANCE | \ + rpINTERPOLATORDIRTYSPHERE ), \ + ((!((_intrp)->flags & rpINTERPOLATORNOFRAMEDIRTY))? \ + ((RpAtomicGetFrame(_atomic))? \ + (RwFrameUpdateObjects(RpAtomicGetFrame(_atomic))): \ + (0)): \ + (0)), \ + (_intrp)) + +#define RpAtomicGetClumpMacro(_atomic) \ + ((_atomic)->clump) + +/* NB "RpAtomicGetBoundingSphere(atomic++)" will break it */ +#define RpAtomicGetBoundingSphereMacro(_atomic) \ + ((((_atomic)->interpolator.flags & rpINTERPOLATORDIRTYSPHERE)? \ + _rpAtomicResyncInterpolatedSphere(_atomic), 0: 0), \ + &((_atomic)->boundingSphere)) +#define RpAtomicGetFrameMacro(_atomic) \ + ((RwFrame *) rwObjectGetParent(_atomic)) + +/* NB "RpClumpSetFrame(clump++, frame)" will break it */ +#if (!defined(RpClumpSetFrameMacro)) +#define RpClumpSetFrameMacro(_clump, _frame) \ + (rwObjectSetParent(_clump, _frame), \ + (_clump)) +#endif /* (!defined(RpClumpSetFrameMacro)) */ + +#if (!defined(RpClumpSetFrameVoidMacro)) +#define RpClumpSetFrameVoidMacro(_clump, _frame) \ +MACRO_START \ +{ \ + rwObjectSetParent(_clump, _frame); \ +} \ +MACRO_STOP +#endif /* (!defined(RpClumpSetFrameVoidMacro)) */ + +#define RpClumpGetFrameMacro(_clump) \ + ((RwFrame *) rwObjectGetParent(_clump)) + +/* NB "RpAtomicSetFlags(atomic++, flags)" will break it */ +#if (!defined(RpAtomicSetFlagsMacro)) +#define RpAtomicSetFlagsMacro(_atomic, _flags) \ + (rwObjectSetFlags(_atomic, _flags), \ + (_atomic)) +#endif /* (!defined(RpAtomicSetFlagsMacro)) */ + +#define RpAtomicGetFlagsMacro(_atomic) \ + (rwObjectGetFlags(_atomic)) + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RpAtomicRender(_atomic) \ + RpAtomicRenderMacro(_atomic) + +#define RpAtomicGetGeometry(_atomic) \ + RpAtomicGetGeometryMacro(_atomic) + +#define RpAtomicSetRenderCallBack(_atomic, _callback) \ + RpAtomicSetRenderCallBackMacro(_atomic, _callback) + +#define RpAtomicGetRenderCallBack(_atomic) \ + RpAtomicGetRenderCallBackMacro(_atomic) + +#define RpAtomicGetInterpolator(_atomic) \ + RpAtomicGetInterpolatorMacro(_atomic) + +#define RpInterpolatorGetStartMorphTarget(_intrp) \ + RpInterpolatorGetStartMorphTargetMacro(_intrp) + +#define RpInterpolatorGetEndMorphTarget(_intrp) \ + RpInterpolatorGetEndMorphTargetMacro(_intrp) + +#define RpInterpolatorGetValue(_intrp) \ + RpInterpolatorGetValueMacro(_intrp) + +#define RpInterpolatorGetScale(_intrp) \ + RpInterpolatorGetScaleMacro(_intrp) + +#define RpInterpolatorSetStartMorphTarget(_intrp, _target, _atomic) \ + RpInterpolatorSetStartMorphTargetMacro(_intrp, _target, _atomic) + +#define RpInterpolatorSetEndMorphTarget(_intrp, _target, _atomic) \ + RpInterpolatorSetEndMorphTargetMacro(_intrp, _target, _atomic) + +#define RpInterpolatorSetValue(_intrp, _value, _atomic) \ + RpInterpolatorSetValueMacro(_intrp, _value, _atomic) + +#define RpInterpolatorSetScale(_intrp, _scale, _atomic) \ + RpInterpolatorSetScaleMacro(_intrp, _scale, _atomic) + +#define RpAtomicGetClump(_atomic) \ + RpAtomicGetClumpMacro(_atomic) + +#define RpAtomicGetBoundingSphere(_atomic) \ + RpAtomicGetBoundingSphereMacro(_atomic) + +#define RpAtomicGetFrame(_atomic) \ + RpAtomicGetFrameMacro(_atomic) + +#define RpClumpSetFrame(_clump, _frame) \ + RpClumpSetFrameMacro(_clump, _frame) + +#define RpClumpGetFrame(_clump) \ + RpClumpGetFrameMacro(_clump) + +#define RpAtomicSetFlags(_atomic, _flags) \ + RpAtomicSetFlagsMacro(_atomic, _flags) + +#define RpAtomicGetFlags(_atomic) \ + RpAtomicGetFlagsMacro(_atomic) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Macro version of RpAtomicSetRenderCallBack needs this */ +extern RpAtomic * +AtomicDefaultRenderCallBack(RpAtomic * atomic); + +extern void +_rpAtomicResyncInterpolatedSphere(RpAtomic * atomic); + +extern const RwSphere * +RpAtomicGetWorldBoundingSphere(RpAtomic * atomic); + +/* Enumeration */ +extern RpClump * +RpClumpForAllAtomics(RpClump * clump, + RpAtomicCallBack callback, + void *pData); + +extern RpClump * +RpClumpForAllLights(RpClump * clump, + RpLightCallBack callback, + void *pData); + +extern RpClump * +RpClumpForAllCameras(RpClump * clump, + RwCameraCallBack callback, + void *pData); + +/* Frames */ +extern RpAtomic * +RpAtomicSetFrame(RpAtomic * atomic, + RwFrame * frame); + +/* Create a space marking clump */ +extern RpClump * +RpClumpCreateSpace(const RwV3d * position, + RwReal radius); + +/* Instancing and rendering */ +extern RpClump * +RpClumpRender(RpClump * clump); + +extern RpClump * +RpClumpRemoveAtomic(RpClump * clump, + RpAtomic * atomic); + +extern RpClump * +RpClumpAddAtomic(RpClump * clump, + RpAtomic * atomic); + +extern RpClump * +RpClumpRemoveLight(RpClump * clump, + RpLight * light); + +extern RpClump * +RpClumpAddLight(RpClump * clump, + RpLight * light); + +extern RpClump * +RpClumpRemoveCamera(RpClump * clump, + RwCamera * camera); + +extern RpClump * +RpClumpAddCamera(RpClump * clump, + RwCamera * camera); + +/* Creation and destruction of clumps */ +extern RwBool +RpClumpDestroy(RpClump * clump); + +extern RpClump * +RpClumpCreate(void); + +extern RpClump * +RpClumpClone(RpClump * clump); + +/* Creation and destruction of atomics*/ +extern RwBool +RpAtomicDestroy(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicClone(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicCreate(void); + +/* Setting and getting geometry for an atomic */ +extern RpAtomic * +RpAtomicSetGeometry(RpAtomic * atomic, + RpGeometry * geometry, + RwUInt32 flags); + +/* Frustum callbacks */ +extern RpClump * +RpClumpSetCallBack(RpClump * clump, + RpClumpCallBack callback); + +extern RpClumpCallBack +RpClumpGetCallBack(const RpClump * clump); + +/* The number of atomics in a clump */ +extern RwInt32 +RpClumpGetNumAtomics(RpClump * clump); + +extern RwInt32 +RpClumpGetNumLights(RpClump * clump); + +extern RwInt32 +RpClumpGetNumCameras(RpClump * clump); + +/* Light and camera extensions */ +extern RpClump * +RpLightGetClump(const RpLight *light); + +extern RpClump * +RwCameraGetClump(const RwCamera *camera); + +/* Binary format */ +extern RwUInt32 +RpAtomicStreamGetSize(RpAtomic * atomic); + +extern RpAtomic * +RpAtomicStreamRead(RwStream * stream); + +extern RpAtomic * +RpAtomicStreamWrite(RpAtomic * atomic, + RwStream * stream); + +extern RwUInt32 +RpClumpStreamGetSize(RpClump * clump); + +extern RpClump * +RpClumpStreamRead(RwStream * stream); + +extern RpClump * +RpClumpStreamWrite(RpClump * clump, + RwStream * stream); + +extern RpClumpChunkInfo * +_rpClumpChunkInfoRead(RwStream * stream, + RpClumpChunkInfo * clumpChunkInfo, + RwInt32 * bytesRead); + +/* Attaching toolkits */ +extern RwInt32 +RpAtomicRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpClumpRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RpAtomicRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack + readCB, + RwPluginDataChunkWriteCallBack + writeCB, + RwPluginDataChunkGetSizeCallBack + getSizeCB); + +extern RwInt32 +RpAtomicSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpAtomicSetStreamRightsCallBack(RwUInt32 pluginID, + RwPluginDataChunkRightsCallBack rightsCB); + +extern RwInt32 +RpClumpRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RpClumpSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwInt32 +RpAtomicGetPluginOffset(RwUInt32 pluginID); + +extern RwInt32 +RpClumpGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RpAtomicValidatePlugins(const RpAtomic * atomic); + +extern RwBool +RpClumpValidatePlugins(const RpClump * clump); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwFrame * +RpAtomicGetFrame(const RpAtomic * atomic); + +extern RwFrame * +RpClumpGetFrame(const RpClump * clump); + +extern RpClump * +RpClumpSetFrame(RpClump * clump, + RwFrame * frame); + +/* Flags */ +extern RpAtomic * +RpAtomicSetFlags(RpAtomic * atomic, + RwUInt32 flags); + +extern RwUInt32 +RpAtomicGetFlags(const RpAtomic * atomic); + +extern RwSphere * +RpAtomicGetBoundingSphere(RpAtomic * atomic); + +extern RwInt32 +RpInterpolatorGetEndMorphTarget(const RpInterpolator * interpolator); + +extern RwInt32 +RpInterpolatorGetStartMorphTarget(const RpInterpolator * interpolator); + +extern RwReal +RpInterpolatorGetValue(const RpInterpolator * interpolator); + +extern RwReal +RpInterpolatorGetScale(const RpInterpolator * interpolator); + +extern RpInterpolator * +RpInterpolatorSetEndMorphTarget(RpInterpolator * interpolator, + RwInt32 morphTarget, + RpAtomic * atomic); + +extern RpInterpolator * +RpInterpolatorSetStartMorphTarget(RpInterpolator * interpolator, + RwInt32 morphTarget, + RpAtomic * atomic); + +extern RpInterpolator * +RpInterpolatorSetValue(RpInterpolator * interpolator, + RwReal value, + RpAtomic *atomic); + +extern RpInterpolator * +RpInterpolatorSetScale(RpInterpolator * interpolator, + RwReal scale, + RpAtomic *atomic); + +extern RpAtomic * +RpAtomicRender(RpAtomic * atomic); + +/* Building clumps */ +extern RpClump * +RpAtomicGetClump(const RpAtomic * atomic); + +extern RpInterpolator * +RpAtomicGetInterpolator(RpAtomic * atomic); + +extern RpGeometry * +RpAtomicGetGeometry(const RpAtomic * atomic); + +extern void +RpAtomicSetRenderCallBack(RpAtomic * atomic, + RpAtomicCallBackRender callback); + +extern RpAtomicCallBackRender +RpAtomicGetRenderCallBack(const RpAtomic * atomic); + +#endif + +/* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +extern RwBool RpAtomicInstance(RpAtomic *atomic); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpClumpChunkInfoRead(stream, clumpChunkInfo, bytesRead) \ + _rpClumpChunkInfoRead(stream, clumpChunkInfo, bytesRead) + + +/*--- Automatically derived from: c:/daily/rwsdk/world/baworld.h ---*/ + +/* + * World handling. + * World give objects scope, and provide a mechanism for + * efficiency static object rendering. + * + * Copyright (c) 1998 Criterion Software Ltd. + * + */ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rpWORLD 7 + +/* RpWorld private flags (in RwObject) */ +enum RpWorldPrivateFlag +{ + rpWORLDSINGLEMALLOC = 0x01, + rpWORLDPRIVATEFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RpWorldPrivateFlag RpWorldPrivateFlag; + +/** + * \ingroup rpworlddatatypes + * The bit-field type \ref RpWorldFlag specifies the options available + * for creating the static geometry component of a world (see API function \ref RpWorldSetFlags): + */ +enum RpWorldFlag +{ + rpWORLDTRISTRIP = 0x01, /**boundingBox)) + +#define RpWorldGetOriginMacro(_world) \ + (&((_world)->worldOrigin)) + +#define RpWorldGetNumMaterialsMacro(_world) \ + ((_world)->matList.numMaterials) + +#define RpWorldGetMaterialMacro(_world, _num) \ + (((_world)->matList.materials)[(_num)]) + +#define RpWorldGetNumClumpsMacro(_world) \ + ((_world)->numClumpsInWorld) + +#define RpWorldSetRenderOrderMacro(_world, _renderOrder) \ + (((_world)->renderOrder = _renderOrder), (_world)) + +#define RpWorldGetRenderOrderMacro(_world) \ + ((_world)->renderOrder) + +#define RpWorldSetFlagsMacro(_world, _flags) \ + (((_world)->flags = (_flags)), (_world)) + +#define RpWorldGetFlagsMacro(_world) \ + ((_world)->flags) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpWorldGetBBox(_world) \ + RpWorldGetBBoxMacro(_world) + +#define RpWorldGetOrigin(_world) \ + RpWorldGetOriginMacro(_world) + +#define RpWorldGetNumMaterials(_world) \ + RpWorldGetNumMaterialsMacro(_world) + +#define RpWorldGetMaterial(_world, _num) \ + RpWorldGetMaterialMacro(_world, _num) + +#define RpWorldGetNumClumps(_world) \ + RpWorldGetNumClumpsMacro(_world) + +#define RpWorldSetRenderOrder(_world, _renderOrder) \ + RpWorldSetRenderOrderMacro(_world, _renderOrder) + +#define RpWorldGetRenderOrder(_world) \ + RpWorldGetRenderOrderMacro(_world) + +#define RpWorldSetFlags(_world, _flags) \ + RpWorldSetFlagsMacro(_world, _flags) + +#define RpWorldGetFlags(_world) \ + RpWorldGetFlagsMacro(_world) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Global types + */ + + +/** + * \ingroup rpworlddatatypes + * \ref RpWorldRenderOrder + * represents the options available for + * the rendering order of world sectors in the camera's view frustum (see + * API function \ref RpWorldSetRenderOrder). + */ +enum RpWorldRenderOrder +{ + rpWORLDRENDERNARENDERORDER = 0, + rpWORLDRENDERFRONT2BACK, /**pipeline = _pipeline), _world ) + +#define RpWorldGetSectorPipelineMacro(_world, _pipeline) \ + ( (*(_pipeline) = (_world)->pipeline), _world ) + +#define RpWorldSectorSetPipelineMacro(_sector, _pipeline) \ + ( ((_sector)->pipeline = _pipeline), _sector ) + +#define RpWorldSectorGetPipelineMacro(_sector, _pipeline) \ + ( (*(_pipeline) = (_sector)->pipeline), _sector ) + +#define RpAtomicGetGenericPipelineMacro() \ + (RXPIPELINEGLOBAL(genericAtomicPipeline)) + +#define RpAtomicGetDefaultPipelineMacro() \ + (RXPIPELINEGLOBAL(currentAtomicPipeline)) + +#define RpAtomicSetPipelineMacro(_atomic, _pipeline) \ + ( ((_atomic)->pipeline = _pipeline), _atomic ) + +#define RpAtomicGetPipelineMacro(_atomic, _pipeline) \ + ( (*(_pipeline) = (_atomic)->pipeline), _atomic ) + +#define RpMaterialGetGenericPipelineMacro() \ + (RXPIPELINEGLOBAL(genericMaterialPipeline)) + +#define RpMaterialGetDefaultPipelineMacro() \ + (RXPIPELINEGLOBAL(currentMaterialPipeline)) + +#define RpMaterialSetPipelineMacro(_material, _pipeline) \ + ( ((_material)->pipeline = _pipeline), _material ) + +#define RpMaterialGetPipelineMacro(_material, _pipeline) \ + ( (*(_pipeline) = (_material)->pipeline), _material ) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RpWorldGetGenericSectorPipeline RpWorldGetGenericSectorPipelineMacro +#define RpWorldGetDefaultSectorPipeline RpWorldGetDefaultSectorPipelineMacro +#define RpWorldSetSectorPipeline RpWorldSetSectorPipelineMacro +#define RpWorldGetSectorPipeline RpWorldGetSectorPipelineMacro +#define RpWorldSectorSetPipeline RpWorldSectorSetPipelineMacro +#define RpWorldSectorGetPipeline RpWorldSectorGetPipelineMacro + +#define RpAtomicGetGenericPipeline RpAtomicGetGenericPipelineMacro +#define RpAtomicGetDefaultPipeline RpAtomicGetDefaultPipelineMacro +#define RpAtomicSetPipeline RpAtomicSetPipelineMacro +#define RpAtomicGetPipeline RpAtomicGetPipelineMacro + +#define RpMaterialGetGenericPipeline RpMaterialGetGenericPipelineMacro +#define RpMaterialGetDefaultPipeline RpMaterialGetDefaultPipelineMacro +#define RpMaterialSetPipeline RpMaterialSetPipelineMacro +#define RpMaterialGetPipeline RpMaterialGetPipelineMacro + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxPipeline *RpWorldSetDefaultSectorPipeline(RxPipeline *pipeline); +extern RxPipeline *RpAtomicSetDefaultPipeline(RxPipeline *pipeline); +extern RxPipeline *RpMaterialSetDefaultPipeline(RxPipeline *pipeline); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +extern RxPipeline *RpWorldGetGenericSectorPipeline(void); +extern RxPipeline *RpWorldGetDefaultSectorPipeline(void); +extern RpWorld *RpWorldSetSectorPipeline(RpWorld *world, + RxPipeline *pipeline); +extern RpWorld *RpWorldGetSectorPipeline(RpWorld *world, + RxPipeline **pipeline); +extern RpWorldSector *RpWorldSectorSetPipeline(RpWorldSector *sector, + RxPipeline *pipeline); +extern RpWorldSector *RpWorldSectorGetPipeline(RpWorldSector *sector, + RxPipeline **pipeline); + +extern RxPipeline *RpAtomicGetGenericPipeline(void); +extern RxPipeline *RpAtomicGetDefaultPipeline(void); +extern RpAtomic *RpAtomicSetPipeline(RpAtomic *atomic, + RxPipeline *pipeline); +extern const RpAtomic *RpAtomicGetPipeline(const RpAtomic *const atomic, + RxPipeline **pipeline); + +extern RxPipeline *RpMaterialGetGenericPipeline(void); +extern RxPipeline *RpMaterialGetDefaultPipeline(void); +extern RpMaterial *RpMaterialSetPipeline(RpMaterial *material, + RxPipeline *pipeline); +extern RpMaterial *RpMaterialGetPipeline(RpMaterial *material, + RxPipeline **pipeline); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern const RpGeometry *RpGeometryIsCorrectlySorted(const RpGeometry * geometry, + RwBool * result); +extern RpGeometry *RpGeometrySortByMaterial(const RpGeometry * geometry, + RpGeometrySortByMaterialCallBack callback); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* LEGACY-SUPPORT macros */ +#define RpWorldGetGenericSectorInstancePipeline RpWorldGetGenericSectorPipeline +#define RpWorldSetDefaultSectorInstancePipeline RpWorldSetDefaultSectorPipeline +#define RpWorldGetDefaultSectorInstancePipeline RpWorldGetDefaultSectorPipeline +#define RpWorldSetSectorInstancePipeline RpWorldSetSectorPipeline +#define RpWorldGetSectorInstancePipeline RpWorldGetSectorPipeline +#define RpWorldSectorSetInstancePipeline RpWorldSectorSetPipeline +#define RpWorldSectorGetInstancePipeline RpWorldSectorGetPipeline + +#define RpAtomicGetGenericInstancePipeline RpAtomicGetGenericPipeline +#define RpAtomicGetDefaultInstancePipeline RpAtomicGetDefaultPipeline +#define RpAtomicSetDefaultInstancePipeline RpAtomicSetDefaultPipeline +#define RpAtomicSetInstancePipeline RpAtomicSetPipeline +#define RpAtomicGetInstancePipeline RpAtomicGetPipeline + +#define RpMaterialGetGenericRenderPipeline RpMaterialGetGenericPipeline +#define RpMaterialSetDefaultRenderPipeline RpMaterialSetDefaultPipeline +#define RpMaterialGetDefaultRenderPipeline RpMaterialGetDefaultPipeline +#define RpMaterialSetRenderPipeline RpMaterialSetPipeline +#define RpMaterialGetRenderPipeline RpMaterialGetPipeline + + +/*--- Automatically derived from: c:/daily/rwsdk/world/baworobj.h ---*/ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Adding and removing cameras to/from the world */ +extern RpWorld *RpWorldRemoveCamera(RpWorld *world, RwCamera *camera); +extern RpWorld *RpWorldAddCamera(RpWorld *world, RwCamera *camera); +extern RpWorld *RwCameraGetWorld(const RwCamera *camera); + +/* Adding and removing atomics to/from the world */ +extern RpWorld *RpWorldRemoveAtomic(RpWorld *world, RpAtomic *atomic); +extern RpWorld *RpWorldAddAtomic(RpWorld *world, RpAtomic *atomic); +extern RpWorld *RpAtomicGetWorld(const RpAtomic *atomic); + +/* Adding and removing clumps to/from the world */ +extern RpWorld *RpWorldAddClump(RpWorld *world, RpClump *clump); +extern RpWorld *RpWorldRemoveClump(RpWorld *world, RpClump *clump); +extern RpWorld *RpClumpGetWorld(const RpClump *clump); + +/* Adding and removing lights to/from the world */ +extern RpWorld *RpWorldAddLight(RpWorld *world, RpLight *light); +extern RpWorld *RpWorldRemoveLight(RpWorld *world, RpLight *light); +extern RpWorld *RpLightGetWorld(const RpLight *light); + +/* Finding whats in the view frustum */ +extern RwCamera *RwCameraForAllClumpsInFrustum(RwCamera *camera, void *data); +extern RwCamera *RwCameraForAllClumpsNotInFrustum(RwCamera *camera, + RwInt32 numClumps, void *data); +extern RwCamera *RwCameraForAllSectorsInFrustum(RwCamera *camera, + RpWorldSectorCallBack callBack, + void *pData); + +/* Enumeration involving the world sectors */ +extern RpLight *RpLightForAllWorldSectors(RpLight *light, + RpWorldSectorCallBack callback, + void *data); +extern RpAtomic *RpAtomicForAllWorldSectors(RpAtomic *atomic, + RpWorldSectorCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllAtomics(RpWorldSector *sector, + RpAtomicCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllCollisionAtomics(RpWorldSector *sector, + RpAtomicCallBack callback, + void *data); +extern RpWorldSector *RpWorldSectorForAllLights(RpWorldSector *sector, + RpLightCallBack callback, + void *data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: c:/daily/rwsdk/world/babinwor.h ---*/ +/**************************************************************************** + Global types + */ + +/* Binary Representation + * + */ +typedef struct RpWorldChunkInfoSector RpWorldSectorChunkInfo; +typedef struct RpWorldChunkInfoSector _rpWorldSector; + +struct RpWorldChunkInfoSector +{ + RwInt32 matListWindowBase; + RwInt32 numPolygons; + RwInt32 numVertices; + RwV3d inf; + RwV3d sup; + RwBool collSectorPresent; + RwBool unused; +}; + +typedef struct RpPlaneSectorChunkInfo RpPlaneSectorChunkInfo; +typedef struct RpPlaneSectorChunkInfo _rpPlaneSector; + +struct RpPlaneSectorChunkInfo +{ + RwInt32 type; + RwReal value; + RwBool leftIsWorldSector; + RwBool rightIsWorldSector; + RwReal leftValue; + RwReal rightValue; +}; + +typedef struct RpWorldChunkInfo RpWorldChunkInfo; +typedef struct RpWorldChunkInfo _rpWorld; + +struct RpWorldChunkInfo +{ + RwBool rootIsWorldSector; + + RwV3d invWorldOrigin; + + RwSurfaceProperties surfaceProps; + + RwInt32 numPolygons; + RwInt32 numVertices; + RwInt32 numPlaneSectors; + RwInt32 numWorldSectors; + RwInt32 colSectorSize; + + RwInt32 format; /* Flags about the world */ +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Binary format */ +extern RwUInt32 RpWorldStreamGetSize(const RpWorld *world); +extern RpWorld *RpWorldStreamRead(RwStream *stream); +extern const RpWorld *RpWorldStreamWrite(const RpWorld *world, + RwStream *stream); +extern RpWorldSectorChunkInfo * +_rpWorldSectorChunkInfoRead(RwStream *stream, + RpWorldSectorChunkInfo *worldSectorChunkInfo, + RwInt32 *bytesRead); +extern RpPlaneSectorChunkInfo * +_rpPlaneSectorChunkInfoRead(RwStream *stream, + RpPlaneSectorChunkInfo *planeSectorChunkInfo, + RwInt32 *bytesRead); +extern RpWorldChunkInfo * +_rpWorldChunkInfoRead(RwStream *stream, + RpWorldChunkInfo *worldChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RpWorldSectorChunkInfoRead(stream, worldSectorChunkInfo, bytesRead) \ + _rpWorldSectorChunkInfoRead(stream, worldSectorChunkInfo, bytesRead) + +#define RpPlaneSectorChunkInfoRead(stream, planeSectorChunkInfo, bytesRead) \ + _rpPlaneSectorChunkInfoRead(stream, planeSectorChunkInfo, bytesRead) + +#define RpWorldChunkInfoRead(stream, worldChunkInfo, bytesRead) \ + _rpWorldChunkInfoRead(stream, worldChunkInfo, bytesRead) + +#endif /* RPWORLD_H */ diff --git a/rwsdk/include/d3d8/rpworld.rpe b/rwsdk/include/d3d8/rpworld.rpe new file mode 100644 index 00000000..080eefa5 --- /dev/null +++ b/rwsdk/include/d3d8/rpworld.rpe @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionWorld +{ + + +E_RP_WORLD_INVSPHERE, + +E_RP_WORLD_INVINTERSECTION, + +E_RP_WORLD_MATRANGE, + +E_RP_WORLD_CLUMPINWORLD, + +E_RP_WORLD_CLUMPNOTINWORLD, + +E_RP_WORLD_ATOMICNOFRAME, + +E_RP_WORLD_TOOMANYVERTICES, + + e_rwdb_CriterionWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionWorld e_rwdb_CriterionWorld; + + diff --git a/rwsdk/include/d3d8/rt2d.h b/rwsdk/include/d3d8/rt2d.h new file mode 100644 index 00000000..5bf1faea --- /dev/null +++ b/rwsdk/include/d3d8/rt2d.h @@ -0,0 +1,911 @@ +/* + * Data structures for 2d toolkit + * + * Copyright (c) Criterion Software Limited + */ + +/*************************************************************************** + * * + * Module : rt2d.h * + * * + * Purpose : * + * * + **************************************************************************/ + +#ifndef RT2D_H +#define RT2D_H + +/** + * \defgroup rt2d Rt2d + * \ingroup rttool + * + * 2D Rendering Toolkit for RenderWare. + */ + +/** + * \defgroup rt2ddatatypes Data Types + * \ingroup rt2d + * + * Basic Data Types + */ + +/** + * \defgroup rt2dsub Rt2d + * \ingroup rt2d + * + * Rt2d functions + */ + +/** + * \defgroup rt2dbrush Rt2dBrush + * \ingroup rt2d + * + * Brush functions + */ + +/** + * \defgroup rt2dctm Rt2dCTM + * \ingroup rt2d + * + * Current Transformation Matrix (CTM) + */ + +/** + * \defgroup rt2ddevice Rt2dDevice + * \ingroup rt2d + * + * Camera device functions + */ + +/** + * \defgroup rt2dfont Rt2dFont + * \ingroup rt2d + * + * Font functions + */ + +/** + * \defgroup rt2dobject Rt2dObject + * \ingroup rt2d + * + * Objects + */ + +/** + * \defgroup rt2dobjectstring Rt2dObjectString + * \ingroup rt2d + * + * String functions + */ + +/** + * \defgroup rt2dpath Rt2dPath + * \ingroup rt2d + * + * Path functions + */ + +/** + * \defgroup rt2dpickregion Rt2dPickRegion + * \ingroup rt2d + * + * Pick regions + */ + +/** + * \defgroup rt2dscene Rt2dScene + * \ingroup rt2d + * + * Scenes + */ + +/** + * \defgroup rt2dshape Rt2dShape + * \ingroup rt2d + * + * Shapes + */ + +/** + * \defgroup rt2drwv2d RwV2d + * \ingroup rt2d + * + * Rt2d plugin directly extends the Core Library's RwV2d API functions. + */ + +/**************************************************************************** + Includes + */ + +#include "rt2d.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +#define Rt2dBrushSetWidthMacro(_brush, _width) \ + ( ( (_brush)->halfwidth = ((_width) * 0.5f) ), (_brush) ) + +#define Rt2dBrushGetWidthMacro(_brush) \ + ( (_brush)->halfwidth * 2.0f ) + +#define Rt2dCTMReadMacro(_result) \ + (RwMatrixCopy((_result), _rt2dCTMGet()), (_result)) + +/**************************************************************************** + Global Types + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * rt2dShadeParameters + * typedef for a structure describing Shade Parameters + */ +typedef struct rt2dShadeParameters rt2dShadeParameters; + +/* + * + * rt2dShadeParameters + * describes Shade Parameters + */ +struct rt2dShadeParameters +{ + RwRGBAReal col; /* col */ + RwV2d uv; /* uv */ +}; + +/** + * \ingroup rt2ddatatypes + * \typedef Rt2dBrush + * typedef for a structure describing a Brush (opaque) + */ +typedef struct Rt2dBrush Rt2dBrush; + +/* + * Rt2dBrush + * structure describing a Brush + */ +#if defined (GCN_DRVMODEL_H) + #define VERTEXCACHESIZE 64 +#else + #define VERTEXCACHESIZE 256 +#endif + +struct Rt2dBrush +{ + RWIM3DVERTEX vertex[VERTEXCACHESIZE]; + rt2dShadeParameters top; + rt2dShadeParameters dtop; + rt2dShadeParameters bottom; + rt2dShadeParameters dbottom; + RwInt32 calcFields; + RwTexture *texture; + RwReal halfwidth; +}; + +/** + * \ingroup rt2ddatatypes + * \typedef Rt2dPath + * typedef for a structure describing a Path (opaque) + */ +typedef struct Rt2dPath Rt2dPath; + +/** + * \ingroup rt2ddatatypes + * \typedef Rt2dFont + * typedef for a structure describing a Font (opaque) + */ +typedef struct Rt2dFont Rt2dFont; + +/* + * typedef used for referencing a spot in a font dictionary + */ +typedef struct _rt2dFontDictionaryNode _rt2dFontDictionaryNode; + +/** + * \ingroup rt2ddatatypes + * \typedef Rt2dBBox + * typedef for a structure describing a Bounding Box + */ + +typedef struct Rt2dBBox Rt2dBBox; +/** +* \ingroup rt2ddatatypes + * \struct Rt2dBBox + * structure describing a Bounding Box + */ +struct Rt2dBBox +{ + RwReal x; /**< x-coordinate of lower-left corner */ + RwReal y; /**< y-coordinate of lower-left corner */ + RwReal w; /**< Width */ + RwReal h; /**< Height */ +}; + +/** + * \ingroup rt2ddatatypes + * \typedef Rt2dObject + * typedef for a structure describing a 2d Object + * This should be considered an opaque type. + * Use Rt2dObject, Rt2dScene, Rt2dShape, Rt2dPickRegion or Rt2dObjectString + * API functions to access. + */ +typedef struct Rt2dObject Rt2dObject; + +/* + * typedef for a structure describing a scene of shapes (opaque) + */ +typedef struct _rt2dScene _rt2dScene; + +/* + * typedef for a structure describing the depth of an object + */ +typedef struct _rt2dDepthOfObject _rt2dDepthOfObject; + +/* + * typedef for a structure describing the depth of an object + */ +struct _rt2dDepthOfObject +{ + Rt2dObject *object; + RwInt32 depth; +}; + +/* + * structure describing a scene of shapes + */ +struct _rt2dScene +{ + RwSList *objects; /* collection of objects in scene */ + RwInt32 objectCount; /* number of objects */ + RwSList *depths; /* depths for depthsort */ + RwBool isDirtyDepths; /* depthsort needs updating */ +}; + +/* + * typedef for a structure describing a shape (opaque) + */ +typedef struct _rt2dShape _rt2dShape; + +struct _rt2dShape +{ + RwSList *nodes; /* individual stroked/filled regions of the shape */ +}; + +/* + * typedef for a structure describing a pick region that can be tested for point inclusion (opaque) + */ +typedef struct _rt2dPickRegion _rt2dPickRegion; + +/* + * structure describing a pick region that can be tested for point inclusion + */ +struct _rt2dPickRegion +{ + Rt2dPath *path; /* path that defines region for testing */ + Rt2dBBox bbox; /* bounding box of path */ + RwMatrix transformation; + /* ivnert transformation used to place the pick region */ +}; + +/* + * structure describing a renderable text string + */ +struct _rt2dObjectString +{ + RwChar *textString; /* Text string to be rendered */ + Rt2dBrush *brush; /* Brush to be used to draw text */ + RwInt32 maxLength; /* Maximum string length before reallocation, excluding null */ + RwReal height; /* Font rendering Height */ + _rt2dFontDictionaryNode *font; /* Dictionary node identifying font to be used */ +}; + +/* + * typedef for a renderable string + */ +typedef struct _rt2dObjectString _rt2dObjectString; +/** + * \ingroup rt2ddatatypes + * \ref Rt2dObjectTypeEnum + * enumeration describing types of Rt2dObject + */ +enum Rt2dObjectTypeEnum { + rt2DOBJECTTYPEOBJECT=0, /** +#include "rt2danim.rpe" /* automatically generated header file */ +#include "rt2d.h" +#include "rpcriter.h" +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#define RT2D_BUTTON_MAX_STATES 4 +#define RT2D_BUTTON_MAX_STATE_TRANSITIONS 32 + +/* Button state flags. */ + +#define rt2dANIMBUTTONSTATEPICKREGION 0x0001 +#define rt2dANIMBUTTONSTATEUP 0x0002 +#define rt2dANIMBUTTONSTATEDOWN 0x0004 +#define rt2dANIMBUTTONSTATEOVER 0x0008 + +#define rt2dANIMBUTTONSTATEIDLETOOVERUP 0x0010 +#define rt2dANIMBUTTONSTATEOVERUPTOIDLE 0x0020 +#define rt2dANIMBUTTONSTATEOVERUPTOOVERDOWN 0x0040 +#define rt2dANIMBUTTONSTATEOVERDOWNTOOVERUP 0x0080 +#define rt2dANIMBUTTONSTATEOVERDOWNTOOUTDOWN 0x0100 +#define rt2dANIMBUTTONSTATEOUTDOWNTOOVERDOWN 0x0200 +#define rt2dANIMBUTTONSTATEOUTDOWNTOIDLE 0x0400 +#define rt2dANIMBUTTONSTATEIDLETOOVERDOWN 0x0800 +#define rt2dANIMBUTTONSTATEOVERDOWNTOIDLE 0x1000 + + +/* Mask to separate trans state in state flag. */ +#define rt2dANIMBUTTONSTATEMASK \ + (rt2dANIMBUTTONSTATEPICKREGION | \ + rt2dANIMBUTTONSTATEPICKUP | \ + rt2dANIMBUTTONSTATEPICKDOWN | \ + rt2dANIMBUTTONSTATEPICKOVER) + +/* Basic enumerations */ + +/** + * \ingroup rt2dmessage + * \ref Rt2dMessageType, this type represents the different types of + * messages that are available. + */ + +enum Rt2dMessageType +{ + rt2dMESSAGETYPENULL = 0, /**< Empty message. */ + rt2dMESSAGETYPEPLAY, /**< Play animation. */ + rt2dMESSAGETYPESTOP, /**< Stop animation. */ + rt2dMESSAGETYPENEXTFRAME, /**< Advance to next frame. */ + rt2dMESSAGETYPEPREVFRAME, /**< Rewind to previouse frame. */ + rt2dMESSAGETYPEGOTOFRAME, /**< Advance to frame by index. */ + rt2dMESSAGETYPEGOTOLABEL, /**< Advance to frame by label. */ + rt2dMESSAGETYPEGETURL, /**< Get URL */ + rt2dMESSAGETYPEDOACTION, /* Perform action. */ + rt2dMESSAGETYPEFOREIGN, /**< Application specific message. */ + rt2dMESSAGETYPEMOUSEMOVETO, /**< Move mouse. */ + rt2dMESSAGETYPEMOUSEBUTTONSTATE, /**< Mouse button up or down. */ + rt2dMESSAGETYPESPECIALTELLTARGET, /* Change target while queueing */ + rt2dMESSAGETYPEBUTTONBYLABEL, /**< Mouse button transition by label */ + rt2dMESSAGETYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum Rt2dMessageType Rt2dMessageType; + +/** + * \ingroup rt2dstringlabel + * \ref Rt2dStringLabelType, this type represents the different types of + * object that can be labelled in the maestro's label table. + */ + +enum Rt2dStringLabelType +{ + rt2dANIMLABELTYPENONE = 0, + rt2dANIMLABELTYPEANIM, /**< Animation label. */ + rt2dANIMLABELTYPEFRAME, /**< Frame or cel label. */ + rt2dANIMLABELTYPEBUTTON, /**< Button label. */ + rt2dANIMLABELTYPEFOREIGN, /**< Application specific. */ + rt2dANIMLABELTYPESHAPE, /**< Shape label. */ + rt2dANIMLABELTYPEURL, /**< URL label. */ + rt2dANIMLABELTYPEENUMSIZEINT = RWFORCEENUMSIZEINT +}; + +typedef enum Rt2dStringLabelType Rt2dStringLabelType; + +/* Basic animation structures */ + +/** + * \ingroup rt2danimsub + * \typedef Rt2dAnimProps + * typedef for a structure describing the current state of a scene (opaque) + */ +typedef struct Rt2dAnimProps Rt2dAnimProps; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameList + * typedef for a structure describing a list of keyframes + */ +typedef struct Rt2dKeyFrameList Rt2dKeyFrameList; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dAnimObjectUpdate + * typedef for a structure describing a set of changes to a 2d object (opaque) + */ +typedef struct Rt2dAnimObjectUpdate Rt2dAnimObjectUpdate; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameTransform + * typedef for a structure describing a transform change to a 2d object (opaque) + */ +typedef struct Rt2dKeyFrameTransform Rt2dKeyFrameTransform; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameColor + * typedef for a structure describing a color change to a 2d object (opaque) + */ +typedef struct Rt2dKeyFrameColor Rt2dKeyFrameColor; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameShow + * typedef for a structure describing a displayable or depth change to a 2d object (opaque) + */ +typedef struct Rt2dKeyFrameShow Rt2dKeyFrameShow; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameMorph + * typedef for a structure describing a morph change to a 2d object (opaque) + */ +typedef struct Rt2dKeyFrameMorph Rt2dKeyFrameMorph; + +/** + * \ingroup rt2danimsub + * \typedef Rt2dAnim + * typedef for a structure describing a 2d animation (opaque) + */ +typedef struct Rt2dAnim Rt2dAnim; + +/** + * \ingroup rt2dbutton + * \typedef Rt2dButton + * typedef for a structure describing a button (opaque) + */ +typedef struct Rt2dButton Rt2dButton; + +/** + * \ingroup rt2dcel + * \typedef Rt2dCel + * typedef for a structure describing a cel (opaque) + */ +typedef struct Rt2dCel Rt2dCel; + +/** + * \ingroup rt2dcel + * \typedef Rt2dCelList + * typedef for a structure describing a cel list (opaque) + */ +typedef struct Rt2dCelList Rt2dCelList; + +/** + * \ingroup rt2dmaestro + * \typedef Rt2dMaestro + * typedef for a structure describing a maestro (opaque) + */ +typedef struct Rt2dMaestro Rt2dMaestro; + +/** + * \ingroup rt2dmessage + * \typedef Rt2dMessage + * typedef for a structure describing a message (opaque) + */ +typedef struct Rt2dMessage Rt2dMessage; + +typedef struct Rt2dMessageList Rt2dMessageList; + +/** + * \ingroup rt2dstringlabel + * \typedef Rt2dStringLabel + * typedef for a structure describing a string label (opaque) + */ +typedef struct Rt2dStringLabel Rt2dStringLabel; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrame + * structure describing a transforming action + */ +struct Rt2dKeyFrameTransform +{ + RwMatrix matrix; /**< Transform to be applied */ /*64*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameColor + * structure describing a color setting action + */ +struct Rt2dKeyFrameColor +{ + RwRGBAReal color; /**< Color value for a keyframe */ /*16*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameShow + * structure describing a show/hide action + */ +struct Rt2dKeyFrameShow +{ + RwBool show; /**< visibility flag */ /*4*/ + RwInt32 depth; /**< Depth order (reverse-z) */ /*4*/ + RwUInt8 pad1[8]; /**< Alignment padding */ /*8*/ +}; + +/** + * \ingroup rt2danimsub + * \struct Rt2dKeyFrameMorph + * structure describing a morph action + */ +struct Rt2dKeyFrameMorph +{ + Rt2dObject *source; /**< start object */ /*4*/ + Rt2dObject *destination; /**< end object */ /*4*/ + RwReal alpha; /**< interpolation value (0.0f-1.0f) */ /*4*/ + RwInt32 pad1; /**< Alignment padding */ /*4*/ +}; + +/** + * \ingroup rt2dmessage + * \struct Rt2dMessage + * Structure describing a message. A message must have a valid message type, (\ref Rt2dMessageType) + * and animation index. The animation index identifies which animation the message applies to. + * A -1 indicates the currently active animation. A message can have none, one or two additional + * \ref RwInt32 parameters, depending on the message type. + */ +struct Rt2dMessage +{ + RwUInt32 messageType; /**< message identifier + (\ref Rt2dMessageType) */ + RwInt32 index; /**< animation to apply any + actions to */ + RwInt32 intParam1; /**< first param (message dependant) */ + RwInt32 intParam2; /**< second param (message dependant) */ +}; + +#define _rt2dMessageGetMessageTypeMacro(_message) \ + ((_message)->messageType); + +#define _rt2dMessageSetMessageTypeMacro(_message, _messageType) \ + ((_message)->messageType = (_messageType)); + +#define _rt2dMessageGetIndexMacro(_message) \ + ((_message)->index); + +#define _rt2dMessageSetIndexMacro(_message, _index) \ + ((_message)->index = (_index)); + +#define _rt2dMessageSetParamMacro(_message, _param1, _param2) \ +MACRO_START \ +{ \ + ((_message)->intParam1 = (_param1)); \ + ((_message)->intParam2 = (_param2)); \ +} \ +MACRO_STOP + +#define _rt2dMessageGetParamMacro(_message, _param1, _param2) \ +MACRO_START \ +{ \ + (*(_param1) = (_message)->intParam1); \ + (*(_param2) = (_message)->intParam2); \ +} \ +MACRO_STOP + +/** + * \ingroup rt2dstringlabel + * \struct Rt2dStringLabel + * structure containing label information. The enitityType identifies the type + * of the label. The label's name is stored as an index + * in common storage area. The entityType and name of the label are used as keys + * during a search. Additional internal and user data can be stored with the + * label. + */ +struct Rt2dStringLabel +{ + RwUInt32 entityType; /**< type of the label + (\ref Rt2dStringLabelType) */ + RwInt32 nameIndex; /**< index of name in internal data + area */ + void *internalData; /**< internal data */ + void *userData; /**< customizable data */ + +}; + +#define _rt2dStringLabelGetStringLabelTypeMacro(_strLabel) \ + ((_strLabel)->entityType); + +#define _rt2dStringLabelSetStringLabelTypeMacro(_strLabel, _entityType) \ + ((_strLabel)->entityType = (_entityType)); + +#define _rt2dStringLabelGetNameIndexMacro(_strLabel) \ + ((_strLabel)->nameIndex); + +#define _rt2dStringLabelSetNameIndexMacro(_strLabel, _index) \ + ((_strLabel)->nameIndex = (_index)); + +#define _rt2dStringLabelGetInternalDataMacro(_strLabel) \ + ((_strLabel)->internalData); + +#define _rt2dStringLabelSetInternalDataMacro(_strLabel, _internalData) \ + ((_strLabel)->internalData = (_internalData)); + +#define _rt2dStringLabelGetUserDataMacro(_strLabel) \ + ((_strLabel)->userData); + +#define _rt2dStringLabelSetUserDataMacro(_strLabel, _userData) \ + ((_strLabel)->userData = (_userData)); + +/** + * \ingroup rt2dcel + * \struct Rt2dCel + * structure containing cel information. The name of the cel is stored as an + * index into a label table. The buttons in the cel are stored as indices. These + * reference a list of buttons held by the cel's parent maestro. Any messages + * to be process when the cel is active is stored as index into the parent's + * maestro's message storage area. + */ +struct Rt2dCel +{ + RwInt32 strLabelIndex; /**< Frame label */ + RwInt32 celIndex; /**< Frame number */ + RwSList *buttonIndices; /**< List of buttons active in + this frame */ + RwInt32 messageListIndex; /**< Messages to be posted after + displaying this frame */ +}; + +#define _rt2dCelGetStringLabelIndexMacro(_cel) \ + ((_cel)->strLabelIndex); + +#define _rt2dCelSetStringLabelIndexMacro(_cel, _index) \ + ((_cel)->strLabelIndex = (_index)); + +#define _rt2dCelGetCelIndexMacro(_cel) \ + ((_cel)->celIndex); + +#define _rt2dCelSetCelIndexMacro(_cel, _index) \ + ((_cel)->celIndex = (_index)); + +#define _rt2dCelGetMessageListIndexMacro(_cel) \ + ((_cel)->messageListIndex); + +#define _rt2dCelSetMessageListIndexMacro(_cel, _index) \ + ((_cel)->messageListIndex = (_index)); + +/* Callback typedefs */ + +typedef Rt2dAnim *(*Rt2dAnimCallBack)(Rt2dAnim *object, + Rt2dAnimProps *props, + void *data); +/** + * \ingroup rt2danimsub + * \typedef Rt2dKeyFrameListCallBack + * This typedef defines a callback function to apply to a frame list. + * + * \param anim Pointer to the animation + * \param props Pointer to the props that the animation acts upon + * \param keyframeList The key frame list + * \param keyframeListTime The key frame list time + * \param data User defined data + */ +typedef Rt2dKeyFrameList *(Rt2dKeyFrameListCallBack)( + Rt2dAnim *anim, + Rt2dAnimProps *props, + Rt2dKeyFrameList *keyframeList, + RwReal keyframeListTime, + void *data); + +/** + * \ingroup rt2danimsub + * \typedef Rt2dAnimOnEndReachedCallBack + * This typedef defines a callback function called at the end of an animation. + * + * \param anim Pointer to the animation ending + * \param props Pointer to the props that the animation acts upon + * \param remainingDeltaTime Remaining time + */ +typedef Rt2dAnim *(*Rt2dAnimOnEndReachedCallBack)(Rt2dAnim *anim, + Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +/** + * \ingroup rt2dmaestro + * \typedef Rt2dMaestroAnimationsCallBack + * \ref Rt2dMaestroAnimationsCallBack represents the function called from + * \ref Rt2dMaestroForAllAnimations for all animations in the maestro. + * This function + * should return the current maestro to indicate success. The callback may + * return NULL to terminate further callbacks on the maestro. + * + * \param maestro Pointer to parent maestro. + * \param anim Pointer to the animation. + * \param props Pointer to the anim's props. + * \param pData Pointer to private data. + * + * \return Pointer to the maestro. + */ + +typedef Rt2dMaestro *(*Rt2dMaestroAnimationsCallBack) + (Rt2dMaestro *maestro, Rt2dAnim *anim, Rt2dAnimProps *props, void * pData); + +/** + * \ingroup rt2dmessage + * \typedef Rt2dMessageHandlerCallBack + * \ref Rt2dMessageHandlerCallBack represents the function called from + * \ref Rt2dMaestroProcessMessages for all messages in the maestro's + * process message queue. The maestro does not filter any messages. The + * handler may process or ignore any messages it is given. + * + * This function should return the current message to indicate success. The + * callback may return NULL to terminate further callbacks on the maestro. + * + * \param maestro Pointer to parent maestro. + * \param message Pointer to the message. + * + * \return Pointer to the message. + */ + +typedef Rt2dMessage *(*Rt2dMessageHandlerCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message); + +/* Message streaming call backs. */ + +typedef RwInt32 +(*Rt2dMessageStreamGetSizeCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message); + +typedef Rt2dMessage * +(*Rt2dMessageStreamReadCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message, RwStream *stream); + +typedef Rt2dMessage * +(*Rt2dMessageStreamWriteCallBack) + (Rt2dMaestro *maestro, Rt2dMessage *message, RwStream *stream); + +/* + * Data access macros. + */ + +/* + * Rt2dAnim + */ + +/* General */ + +extern Rt2dAnimOnEndReachedCallBack +Rt2dAnimSetOnEndReachedCallBack(Rt2dAnimOnEndReachedCallBack callback); + +extern Rt2dAnimOnEndReachedCallBack +Rt2dAnimGetOnEndReachedCallBack(void); + + +extern Rt2dAnim * +Rt2dAnimOnEndReachedCallBackLoop(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +extern Rt2dAnim * +Rt2dAnimOnEndReachedCallBackStop(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal remainingDeltaTime); + +/* Management */ +extern Rt2dAnim * +Rt2dAnimCreate(void); + +extern RwBool +Rt2dAnimDestroy(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimLock(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimUnlock(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimAddKeyFrameList(Rt2dAnim *anim, + Rt2dKeyFrameList *keyframeList, + RwReal time); + + +extern Rt2dAnim * +Rt2dAnimCopy(Rt2dAnim *srcAnim, Rt2dAnimProps *srcProps); + +/* Streaming */ +extern RwUInt32 +Rt2dAnimStreamGetSize( Rt2dAnim *anim, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamRead(RwStream *stream, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamReadTo(RwStream *dest, + RwStream *stream, + Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimStreamWrite(Rt2dAnim *anim, RwStream *stream, + Rt2dAnimProps *data); + +/* Playback */ +extern RwBool +Rt2dAnimIsInterpolated(Rt2dAnim *anim); + +extern Rt2dAnim * +Rt2dAnimSetInterpolate(Rt2dAnim *anim, RwBool interpolate); + +extern Rt2dAnim * +Rt2dAnimReset(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimSetDeltaTimeScale(Rt2dAnim *anim, RwReal timeScale); + +extern Rt2dAnim * +Rt2dAnimAddDeltaTime(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal deltaTime); + +extern Rt2dAnim * +Rt2dAnimAddDeltaFrameIndex(Rt2dAnim *anim, Rt2dAnimProps *props, + RwInt32 deltaFrame); + +extern Rt2dAnim * +Rt2dAnimTimeUpdate(Rt2dAnim *anim, Rt2dAnimProps *props); + +extern Rt2dAnim * +Rt2dAnimGotoKeyFrameListByTime(Rt2dAnim *anim, Rt2dAnimProps *props, + RwReal time); + +extern Rt2dAnim * +Rt2dAnimGotoKeyFrameListByIndex(Rt2dAnim *anim, Rt2dAnimProps *props, + RwInt32 frameIndex); + +/* Utilities */ +extern Rt2dAnim * +Rt2dAnimForAllKeyFrameLists(Rt2dAnim *anim, Rt2dKeyFrameListCallBack callBack, + Rt2dAnimProps *props, void *data); + +/* Interrogation */ +extern RwInt32 +Rt2dAnimGetNumberOfKeyFrames(Rt2dAnim *anim); + +extern Rt2dKeyFrameList * +Rt2dAnimGetKeyFrameListByIndex(Rt2dAnim *anim, RwUInt32 frameIndex); + +extern RwReal +Rt2dAnimGetCurrentTime(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetFinalKeyFrameListTime(Rt2dAnim *anim); + +extern RwInt32 +Rt2dAnimGetPrevFrameIndex(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetPrevFrameTime(Rt2dAnim *anim); + +extern RwInt32 +Rt2dAnimGetNextFrameIndex(Rt2dAnim *anim); + +extern RwReal +Rt2dAnimGetNextFrameTime(Rt2dAnim *anim); + +/* KeyFrameList Management */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListCreate(Rt2dAnimProps *props); + +extern RwBool +Rt2dKeyFrameListDestroy(Rt2dKeyFrameList *keyframeList); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListLock(Rt2dKeyFrameList *keyframeList, Rt2dAnimProps *props); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListUnlock(Rt2dKeyFrameList *keyframeList, + Rt2dAnimProps *props); + +extern Rt2dKeyFrameList* +Rt2dKeyFrameListAddUpdateObject(Rt2dKeyFrameList *keyframeList, + Rt2dAnimObjectUpdate *update); + +/* KeyFrameList Streaming */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListStreamRead(RwStream *stream); + +extern RwUInt32 +Rt2dKeyFrameListStreamGetSize(Rt2dKeyFrameList *keyframeList); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListStreamWrite(Rt2dKeyFrameList *keyframeList, + RwStream *stream); + +/* KeyFrameList Playback */ +extern Rt2dKeyFrameList * +Rt2dKeyFrameListAdvance(Rt2dKeyFrameList *keyframeList, + Rt2dAnimProps *props); + +extern Rt2dKeyFrameList * +Rt2dKeyFrameListApply(Rt2dKeyFrameList *keyframeList, Rt2dAnimProps *props, + RwReal alpha); + +/* KeyFrameList edition object */ +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateCreate(Rt2dObject *object); + +extern RwBool +Rt2dAnimObjectUpdateDestroy(Rt2dAnimObjectUpdate *update); + +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateClear(Rt2dAnimObjectUpdate *update); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetTransform(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameTransform *transform); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetColorOffs(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameColor *colorOffs); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetColorMult(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameColor *colorMult); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetShow(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameShow *show); + +extern Rt2dAnimObjectUpdate* +Rt2dAnimObjectUpdateSetMorph(Rt2dAnimObjectUpdate *update, + Rt2dKeyFrameMorph *morph); + +extern Rt2dAnimObjectUpdate * +Rt2dAnimObjectUpdateSetObject(Rt2dAnimObjectUpdate *update, + Rt2dObject *object); + +/* Props management */ +extern Rt2dAnimProps * +Rt2dAnimPropsCreate(Rt2dObject *scene); + +extern RwBool +Rt2dAnimPropsDestroy(Rt2dAnimProps *props); + +/* + * Rt2dButton + */ + +extern Rt2dMaestro * +Rt2dMaestroAddButton(Rt2dMaestro *maestro, RwInt32 strLabelIdx, RwInt32 objectIdx, + RwUInt32 stateFlag, RwInt32 *actionListIdx, + RwInt32 *index); + +/* + * Rt2dCel & Rt2dCelList + */ + +extern Rt2dCel * +Rt2dCelCreate(Rt2dMaestro *maestro, + RwChar *name, + RwInt32 celIndex, RwInt32 messageListIndex); + +extern Rt2dCelList * +Rt2dCelListCreate( void ); + +extern RwBool +Rt2dCelDestroy(Rt2dMaestro *maestro, Rt2dCel *cel); + +extern Rt2dCel * +Rt2dCelAddButtonIndex(Rt2dCel * cel, RwInt32 buttonIndex, RwInt32 *index); + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dCelGetStringLabelIndex(_cel) \ + _rt2dCelGetStringLabelIndexMacro((_cel)); + +#define Rt2dCelSetStringLabelIndex(_cel, _index) \ + _rt2dCelSetStringLabelIndexMacro((_cel), (_index)); + +#define Rt2dCelGetCelIndex(_cel) \ + _rt2dCelGetCelIndexMacro((_cel)); + +#define Rt2dCelSetCelIndex(_cel, _index) \ + _rt2dCelSetCelIndexMacro((_cel), (_index)); + +#define Rt2dCelGetMessageListIndex(_cel) \ + _rt2dCelGetMessageListIndexMacro((_cel)); + +#define Rt2dCelSetMessageListIndex(_cel, _index) \ + _rt2dCelSetMessageListIndexMacro((_cel), (_index)); + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwInt32 +Rt2dCelGetStringLabelIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetStringLabelIndex(Rt2dCel *cel, RwInt32 index); + +extern RwInt32 +Rt2dCelGetCelIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetCelIndex(Rt2dCel *cel, RwInt32 index); + +extern RwInt32 +Rt2dCelGetMessageListIndex(Rt2dCel *cel); + +extern void +Rt2dCelSetMessageListIndex(Rt2dCel *cel, RwInt32 index); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwBool +Rt2dCelListDestroy(Rt2dCelList *celList); + +extern Rt2dCelList * +Rt2dCelListLock(Rt2dCelList *celList); + +extern Rt2dCelList * +Rt2dCelListUnlock(Rt2dCelList * celList); + +extern Rt2dCelList * +Rt2dCelListCopy(Rt2dCelList *srcCelList); + +extern Rt2dCelList * +Rt2dCelListAddCel(Rt2dCelList *celList, Rt2dCel *cel, RwInt32 *index); + +extern Rt2dCelList * +Rt2dCelListCelGetStringLabelIndex(Rt2dCelList *celList, RwInt32 celIndex, RwInt32 *index); + +extern Rt2dCelList * +Rt2dCelListCelButtonGetDisplayVersion(Rt2dMaestro *maestro, Rt2dCelList * celList, + RwInt32 celIndex, RwInt32 celButtonIndex, RwInt32 *index); + +/* + * Rt2dMaestro + */ +extern Rt2dMaestro * +Rt2dMaestroCreate(void); + +extern RwBool +Rt2dMaestroDestroy(Rt2dMaestro *maestro); + +extern RwUInt32 +Rt2dMaestroStreamGetSize(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroStreamRead(Rt2dMaestro *maestro, RwStream *stream); + +extern Rt2dMaestro * +Rt2dMaestroStreamWrite(Rt2dMaestro *maestro, RwStream *stream); + + +extern Rt2dMaestro * +Rt2dMaestroForAllAnimations(Rt2dMaestro *maestro, + Rt2dMaestroAnimationsCallBack callback, void *data); + +extern Rt2dMaestro * +Rt2dMaestroForAllVisibleAnimations(Rt2dMaestro *maestro, + Rt2dMaestroAnimationsCallBack callback, void *data); + +extern Rt2dMaestro * +Rt2dMaestroAddAnimations(Rt2dMaestro *maestro, + RwInt32 parent, RwInt32 posInParentScene, + Rt2dAnim *anim, Rt2dAnimProps *animProps, Rt2dCelList *celList, + RwInt32 *index); + +extern Rt2dAnim * +Rt2dMaestroGetAnimationsByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dAnimProps * +Rt2dMaestroGetAnimPropsByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroUpdateAnimations(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroAddDeltaTime(Rt2dMaestro *maestro, RwReal deltaTime); + +extern Rt2dMaestro * +Rt2dMaestroLock(Rt2dMaestro * maestro); + +extern Rt2dMaestro * +Rt2dMaestroUnlock(Rt2dMaestro *maestro); + +extern Rt2dObject * +Rt2dMaestroGetScene(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetScene(Rt2dMaestro *maestro, Rt2dObject *scene); + +extern Rt2dObject * +Rt2dMaestroGetAnimSceneByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroRender(Rt2dMaestro *maestro); + +extern Rt2dBBox * +Rt2dMaestroGetBBox(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetBBox(Rt2dMaestro *maestro, Rt2dBBox *bbox); + + +/* + * Message & Message handlers. + */ +extern Rt2dMessageHandlerCallBack +Rt2dMaestroGetMessageHandler(Rt2dMaestro *maestro); + +extern Rt2dMaestro * +Rt2dMaestroSetMessageHandler(Rt2dMaestro *maestro, Rt2dMessageHandlerCallBack handler); + +extern Rt2dMaestro * +Rt2dMaestroAddMessageList(Rt2dMaestro *maestro, + Rt2dMessage *message, RwInt32 num, RwInt32 *index); + +extern Rt2dMaestro * +Rt2dMaestroPostMessages(Rt2dMaestro *maestro, Rt2dMessage *message, RwInt32 num); + +extern Rt2dMaestro * +Rt2dMaestroProcessMessages(Rt2dMaestro *maestro); + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dMessageGetMessageType(_message) \ + _rt2dMessageGetMessageTypeMacro((_message)); + +#define Rt2dMessageSetMessageTypeMacro(_message, _messageType) \ + _rt2dMessageSetMessageTypeMacro((_message), (_messageType)); + +#define Rt2dMessageGetIndex(_message) \ + _rt2dMessageGetIndexMacro((_message)); + +#define Rt2dMessageSetIndex(_message, _index) \ + _rt2dMessageSetIndexMarco((_message), (_index)); + +#define Rt2dMessageSetParam(_message, _param1, _param2) \ + _rt2dMessageSetParamMacro((_message), (_param1), (_param2)); + +#define Rt2dMessageGetParam(_message, _param1, _param2) \ + _rt2dMessageGetParamMacro((_message), (_param1), (_param2)); + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern Rt2dMessageType +Rt2dMessageGetMessageType(Rt2dMessage *message); + +extern void +Rt2dMessageSetMessageType(Rt2dMessage *message, Rt2dMessageType messageType); + +extern RwInt32 +Rt2dMessageGetIndex(Rt2dMessage *message); + +extern void +Rt2dMessageSetIndex(Rt2dMessage *message, RwInt32 index); + +extern void +Rt2dMessageGetParam(Rt2dMessage *message, RwInt32 *param1, RwInt32 *param2); + +extern void +Rt2dMessageSetParam(Rt2dMessage *message, RwInt32 param1, RwInt32 param2); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/* + * Default message handler. + */ +extern Rt2dMessage * +Rt2dMessageHandlerDefaultCallBack(Rt2dMaestro *maestro, Rt2dMessage *message); + + +/* + * Labels. + */ +extern Rt2dStringLabel * +Rt2dMaestroFindStringLabel(Rt2dMaestro *maestro, + Rt2dStringLabelType entityType, RwChar *lookupName, + RwInt32 *index); + +extern Rt2dStringLabel * +Rt2dMaestroGetStringLabelByIndex(Rt2dMaestro *maestro, RwInt32 index); + +extern Rt2dMaestro * +Rt2dMaestroAddStringLabel(Rt2dMaestro *maestro, + Rt2dStringLabelType entityType, RwChar *name, + void *internalData, RwInt32 *index); + +extern const RwChar * +Rt2dMaestroGetStringLabelName(Rt2dMaestro *maestro, + Rt2dStringLabel *strLabel); + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define Rt2dStringLabelGetStringLabelType(_strLabel) \ + _rt2dStringLabelGetStringLabelTypeMacro((_strLabel)); + +#define Rt2dStringLabelSetStringLabelType(_strLabel, _entityType) \ + _rt2dStringLabelSetStringLabelTypeMacro((_strLabel), (_entityType)); + +#define Rt2dStringLabelGetNameIndex(_strLabel) \ + _rt2dStringLabelGetNameIndexMacro((_strLabel)); + +#define Rt2dStringLabelSetNameIndex(_strLabel, _index) \ + _rt2dStringLabelSetNameIndexMacro((_strLabel), (_index)); + +#define Rt2dStringLabelGetInternalData(_strLabel) \ + _rt2dStringLabelGetInternalDataMacro((_strLabel)); + +#define Rt2dStringLabelSetInternalData(_strLabel, _internalData) \ + _rt2dStringLabelSetInternalDataMacro((_strLabel), (_internalData)); + +#define Rt2dStringLabelGetUserData(_strLabel) \ + _rt2dStringLabelGetUserDataMacro((_strLabel)); + +#define Rt2dStringLabelSetUserData(_strLabel, _userData) \ + _rt2dStringLabelSetUserDataMacro((_strLabel), (_userData)); + +#else /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern Rt2dStringLabelType +Rt2dStringLabelGetStringLabelType(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetStringLabelType(Rt2dStringLabel *strLabel, + Rt2dStringLabelType entityType); + +extern RwInt32 +Rt2dStringLabelGetNameIndex(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetNameIndex(Rt2dStringLabel *strLabel, RwInt32 index); + +extern void * +Rt2dStringLabelGetInternalData(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetInternalData(Rt2dStringLabel *strLabel, void *internalData); + +extern void * +Rt2dStringLabelGetUserData(Rt2dStringLabel *strLabel); + +extern void +Rt2dStringLabelSetUserData(Rt2dStringLabel *strLabel, void *userData); + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + + + +/* + * Cels & Cel Lists + */ +extern Rt2dCelList * +Rt2dMaestroGetCelListByIndex(Rt2dMaestro *maestro, RwInt32 index); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RT2DANIM_H*/ diff --git a/rwsdk/include/d3d8/rt2danim.rpe b/rwsdk/include/d3d8/rt2danim.rpe new file mode 100644 index 00000000..82a9dac9 --- /dev/null +++ b/rwsdk/include/d3d8/rt2danim.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum rwPLUGIN_ERRENUM +{ + + + + rwPLUGIN_ERRENUMLAST = RWFORCEENUMSIZEINT +}; + +typedef enum rwPLUGIN_ERRENUM rwPLUGIN_ERRENUM; + + diff --git a/rwsdk/include/d3d8/rtbary.h b/rwsdk/include/d3d8/rtbary.h new file mode 100644 index 00000000..61c39b07 --- /dev/null +++ b/rwsdk/include/d3d8/rtbary.h @@ -0,0 +1,141 @@ +/*************************************************************************** + * * + * Module : rtbary.h * + * * + * Purpose : Barycentric operations * + * * + **************************************************************************/ + +#ifndef RTBARY_H +#define RTBARY_H + +/** + * \defgroup rtbary RtBary + * \ingroup rttool + * + * Barycentric Toolkit for RenderWare. + */ + + +/**************************************************************************** + Includes + */ + +#include + +#include /* automatically generated header file */ + + +/**************************************************************************** + Global types + */ + +/** + * \ingroup rtbary + * \typedef RtBaryV4d + * typedef for the 4 element homogeneous row of a transform matrix mapping + * a point from Cartesian space to the barycentric space defined by a triangle. + */ +typedef RwReal RtBaryV4d[4]; + +/** + * \ingroup rtbary + * \typedef RtBaryTransform + * typedef for the 4x4 homogeneous transform matrix mapping a point + * from Cartesian space to the barycentric space defined by a triangle. + */ +typedef RtBaryV4d RtBaryTransform[4]; + +/**************************************************************************** + Defines + */ + +#define RtBaryV3dFromWeightsMacro(_out, _b, _v0, _v1, _v2) \ +MACRO_START \ +{ \ + (_out)->x = (RwReal)( ((_v0)->x * (_b)[0]) + \ + ((_v1)->x * (_b)[1]) + \ + ((_v2)->x * (_b)[2]) ); \ + (_out)->y = (RwReal)( ((_v0)->y * (_b)[0]) + \ + ((_v1)->y * (_b)[1]) + \ + ((_v2)->y * (_b)[2]) ); \ + (_out)->z = (RwReal)( ((_v0)->z * (_b)[0]) + \ + ((_v1)->z * (_b)[1]) + \ + ((_v2)->z * (_b)[2]) ); \ +} \ +MACRO_STOP + +#define RtBaryWeightsFromV3dMacro(_out, _m, _in) \ +MACRO_START \ +{ \ + (_out)[0] = ( (_m)[0][0] * (_in)->x + \ + (_m)[1][0] * (_in)->y + \ + (_m)[2][0] * (_in)->z + \ + (_m)[3][0] ); \ + (_out)[1] = ( (_m)[0][1] * (_in)->x + \ + (_m)[1][1] * (_in)->y + \ + (_m)[2][1] * (_in)->z + \ + (_m)[3][1] ); \ + (_out)[2] = ( (_m)[0][2] * (_in)->x + \ + (_m)[1][2] * (_in)->y + \ + (_m)[2][2] * (_in)->z + \ + (_m)[3][2] ); \ + (_out)[3] = ( (_m)[0][3] * (_in)->x + \ + (_m)[1][3] * (_in)->y + \ + (_m)[2][3] * (_in)->z + \ + (_m)[3][3] ); \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtBaryV3dFromWeights(_out, _b, _v0, _v1, _v2) \ + RtBaryV3dFromWeightsMacro(_out, _b, _v0, _v1, _v2) + +#define RtBaryWeightsFromV3d(_out, _m, _in) \ + RtBaryWeightsFromV3dMacro(_out, _m, _in) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RtBaryGetTransform(RtBaryTransform m, + RwReal * const area, + const RwV3d * const v0, + const RwV3d * const v1, + const RwV3d * const v2); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtBaryV3dFromWeights(RwV3d * const out, + const RtBaryV4d weights, + const RwV3d * const v0, + const RwV3d * const v1, + const RwV3d * const v2); + +extern void +RtBaryWeightsFromV3d(RtBaryV4d out, + RtBaryTransform mat, + const RwV3d * const in); + +extern void +_rtImportWorldBaryFromEdge(RtBaryV4d out, + RtBaryTransform mat, + const RwV3d * const in); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTBARY_H */ diff --git a/rwsdk/include/d3d8/rtbary.rpe b/rwsdk/include/d3d8/rtbary.rpe new file mode 100644 index 00000000..fdfe3afe --- /dev/null +++ b/rwsdk/include/d3d8/rtbary.rpe @@ -0,0 +1,645 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBary +{ + + + + e_rwdb_CriterionBaryLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBary e_rwdb_CriterionBary; + + diff --git a/rwsdk/include/d3d8/rtbezpat.h b/rwsdk/include/d3d8/rtbezpat.h new file mode 100644 index 00000000..8a5960cb --- /dev/null +++ b/rwsdk/include/d3d8/rtbezpat.h @@ -0,0 +1,401 @@ +/* + * Data structures for rtbezpat toolkit + * Copyright (c) Criterion Software Limited + */ + +#if (!defined(RTBEZPAT_H)) +#define RTBEZPAT_H + +/** + * \defgroup rtbezpatch RtBezPat + * \ingroup rttool + * + * The Bezier Patch Toolkit is a group of functions that support the way + * RenderWare processes patches. + */ + +/** + * \ingroup rtbezpatch + * \typedef RtBezierV4d + * typedef for struct RtBezierV4d. + */ +typedef struct RtBezierV4d RtBezierV4d; + +/** + * \ingroup rtbezpatch + * \struct RtBezierV4d + * This type represents 4d points and vectors specified by + * the (x, y, z, w) coordinates of a 4d point or + * the (x, y, z, w) components of a 4d vector. + */ +struct RtBezierV4d +{ + RwReal x; + /**< X value */ + RwReal y; + /**< Y value */ + RwReal z; + /**< Z value */ + RwReal w; + /**< W value */ +}; + +/** + * \ingroup rtbezpatch + * \typedef RtBezierRow + * typedef for a row of vectors. + * RtBezierRow is an array of 4 vectors + */ +typedef RtBezierV4d RtBezierRow[4]; + +/** + * \ingroup rtbezpatch + * \typedef RtBezierMatrix + * typedef for a matrix of 4*4 vectors. + * RtBezierMatrix is an array of 4 rows. + */ +typedef RtBezierRow RtBezierMatrix[4]; + +/* + * Bernstein polynomials; + */ + +#define RtBern03(_u, _cu) ( (_cu) * (_cu) * (_cu) ) +#define RtBern13(_u, _cu) ( 3 * (_u) * (_cu) * (_cu) ) +#define RtBern23(_u, _cu) ( 3 * (_u) * (_u) * (_cu) ) +#define RtBern33(_u, _cu) ( (_u) * (_u) * (_u) ) + +#define RtBezierQuadSample3dMacro(_out, _P, _u, _v) \ +MACRO_START \ +{ \ + const RtBezierV4d * const P0 = &(_P)[0][0]; \ + const RtBezierV4d * const P1 = &(_P)[1][0]; \ + const RtBezierV4d * const P2 = &(_P)[2][0]; \ + const RtBezierV4d * const P3 = &(_P)[3][0]; \ + const RwReal _pu = (_u); \ + const RwReal _cu = ((RwReal)1) - _pu; \ + const RwReal B03u = RtBern03(_pu,_cu); \ + const RwReal B13u = RtBern13(_pu,_cu); \ + const RwReal B23u = RtBern23(_pu,_cu); \ + const RwReal B33u = RtBern33(_pu,_cu); \ + const RwReal _pv = (_v); \ + const RwReal _cv = ((RwReal)1) - _pv; \ + const RwReal B03v = RtBern03(_pv,_cv); \ + const RwReal B13v = RtBern13(_pv,_cv); \ + const RwReal B23v = RtBern23(_pv,_cv); \ + const RwReal B33v = RtBern33(_pv,_cv); \ + RtBezierRow A; \ + \ + A[0].x = B03u*P0[0].x + B13u*P1[0].x + B23u*P2[0].x + B33u*P3[0].x; \ + A[0].y = B03u*P0[0].y + B13u*P1[0].y + B23u*P2[0].y + B33u*P3[0].y; \ + A[0].z = B03u*P0[0].z + B13u*P1[0].z + B23u*P2[0].z + B33u*P3[0].z; \ + A[1].x = B03u*P0[1].x + B13u*P1[1].x + B23u*P2[1].x + B33u*P3[1].x; \ + A[1].y = B03u*P0[1].y + B13u*P1[1].y + B23u*P2[1].y + B33u*P3[1].y; \ + A[1].z = B03u*P0[1].z + B13u*P1[1].z + B23u*P2[1].z + B33u*P3[1].z; \ + A[2].x = B03u*P0[2].x + B13u*P1[2].x + B23u*P2[2].x + B33u*P3[2].x; \ + A[2].y = B03u*P0[2].y + B13u*P1[2].y + B23u*P2[2].y + B33u*P3[2].y; \ + A[2].z = B03u*P0[2].z + B13u*P1[2].z + B23u*P2[2].z + B33u*P3[2].z; \ + A[3].x = B03u*P0[3].x + B13u*P1[3].x + B23u*P2[3].x + B33u*P3[3].x; \ + A[3].y = B03u*P0[3].y + B13u*P1[3].y + B23u*P2[3].y + B33u*P3[3].y; \ + A[3].z = B03u*P0[3].z + B13u*P1[3].z + B23u*P2[3].z + B33u*P3[3].z; \ + \ + (_out)->x = A[0].x*B03v + A[1].x*B13v + A[2].x*B23v + A[3].x*B33v; \ + (_out)->y = A[0].y*B03v + A[1].y*B13v + A[2].y*B23v + A[3].y*B33v; \ + (_out)->z = A[0].z*B03v + A[1].z*B13v + A[2].z*B23v + A[3].z*B33v; \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepU3dMacro(_row) \ +MACRO_START \ +{ \ + (_row)[0].x += (_row)[1].x; \ + (_row)[0].y += (_row)[1].y; \ + (_row)[0].z += (_row)[1].z; \ + \ + (_row)[1].x += (_row)[2].x; \ + (_row)[1].y += (_row)[2].y; \ + (_row)[1].z += (_row)[2].z; \ + \ + (_row)[2].x += (_row)[3].x; \ + (_row)[2].y += (_row)[3].y; \ + (_row)[2].z += (_row)[3].z; \ + \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepU4dMacro(_row) \ +MACRO_START \ +{ \ + (_row)[0].x += (_row)[1].x; \ + (_row)[0].y += (_row)[1].y; \ + (_row)[0].z += (_row)[1].z; \ + (_row)[0].w += (_row)[1].w; \ + \ + (_row)[1].x += (_row)[2].x; \ + (_row)[1].y += (_row)[2].y; \ + (_row)[1].z += (_row)[2].z; \ + (_row)[1].w += (_row)[2].w; \ + \ + (_row)[2].x += (_row)[3].x; \ + (_row)[2].y += (_row)[3].y; \ + (_row)[2].z += (_row)[3].z; \ + (_row)[2].w += (_row)[3].w; \ + \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepV3dMacro(_mat) \ +MACRO_START \ +{ \ + RtBezierV4d * const m0 = &(_mat)[0][0]; \ + RtBezierV4d * const m1 = &(_mat)[1][0]; \ + RtBezierV4d * const m2 = &(_mat)[2][0]; \ + RtBezierV4d * const m3 = &(_mat)[3][0]; \ + \ + /* (_row) 0 */ \ + m0[0].x += m1[0].x; \ + m0[0].y += m1[0].y; \ + m0[0].z += m1[0].z; \ + \ + m0[1].x += m1[1].x; \ + m0[1].y += m1[1].y; \ + m0[1].z += m1[1].z; \ + \ + m0[2].x += m1[2].x; \ + m0[2].y += m1[2].y; \ + m0[2].z += m1[2].z; \ + \ + m0[3].x += m1[3].x; \ + m0[3].y += m1[3].y; \ + m0[3].z += m1[3].z; \ + \ + /* (_row) 1 */ \ + m1[0].x += m2[0].x; \ + m1[0].y += m2[0].y; \ + m1[0].z += m2[0].z; \ + \ + m1[1].x += m2[1].x; \ + m1[1].y += m2[1].y; \ + m1[1].z += m2[1].z; \ + \ + m1[2].x += m2[2].x; \ + m1[2].y += m2[2].y; \ + m1[2].z += m2[2].z; \ + \ + m1[3].x += m2[3].x; \ + m1[3].y += m2[3].y; \ + m1[3].z += m2[3].z; \ + \ + /* (_row) 2 */ \ + m2[0].x += m3[0].x; \ + m2[0].y += m3[0].y; \ + m2[0].z += m3[0].z; \ + \ + m2[1].x += m3[1].x; \ + m2[1].y += m3[1].y; \ + m2[1].z += m3[1].z; \ + \ + m2[2].x += m3[2].x; \ + m2[2].y += m3[2].y; \ + m2[2].z += m3[2].z; \ + \ + m2[3].x += m3[3].x; \ + m2[3].y += m3[3].y; \ + m2[3].z += m3[3].z; \ +} \ +MACRO_STOP + +#define RtBezierQuadDifferenceStepV4dMacro(_mat) \ +MACRO_START \ +{ \ + RtBezierV4d * const m0 = &(_mat)[0][0]; \ + RtBezierV4d * const m1 = &(_mat)[1][0]; \ + RtBezierV4d * const m2 = &(_mat)[2][0]; \ + RtBezierV4d * const m3 = &(_mat)[3][0]; \ + \ + /* (_row) 0 */ \ + m0[0].x += m1[0].x; \ + m0[0].y += m1[0].y; \ + m0[0].z += m1[0].z; \ + m0[0].w += m1[0].w; \ + \ + m0[1].x += m1[1].x; \ + m0[1].y += m1[1].y; \ + m0[1].z += m1[1].z; \ + m0[1].w += m1[1].w; \ + \ + m0[2].x += m1[2].x; \ + m0[2].y += m1[2].y; \ + m0[2].z += m1[2].z; \ + m0[2].w += m1[2].w; \ + \ + m0[3].x += m1[3].x; \ + m0[3].y += m1[3].y; \ + m0[3].z += m1[3].z; \ + m0[3].w += m1[3].w; \ + \ + /* (_row) 1 */ \ + m1[0].x += m2[0].x; \ + m1[0].y += m2[0].y; \ + m1[0].z += m2[0].z; \ + m1[0].w += m2[0].w; \ + \ + m1[1].x += m2[1].x; \ + m1[1].y += m2[1].y; \ + m1[1].z += m2[1].z; \ + m1[1].w += m2[1].w; \ + \ + m1[2].x += m2[2].x; \ + m1[2].y += m2[2].y; \ + m1[2].z += m2[2].z; \ + m1[2].w += m2[2].w; \ + \ + m1[3].x += m2[3].x; \ + m1[3].y += m2[3].y; \ + m1[3].z += m2[3].z; \ + m1[3].w += m2[3].w; \ + \ + /* (_row) 2 */ \ + m2[0].x += m3[0].x; \ + m2[0].y += m3[0].y; \ + m2[0].z += m3[0].z; \ + m2[0].w += m3[0].w; \ + \ + m2[1].x += m3[1].x; \ + m2[1].y += m3[1].y; \ + m2[1].z += m3[1].z; \ + m2[1].w += m3[1].w; \ + \ + m2[2].x += m3[2].x; \ + m2[2].y += m3[2].y; \ + m2[2].z += m3[2].z; \ + m2[2].w += m3[2].w; \ + \ + m2[3].x += m3[3].x; \ + m2[3].y += m3[3].y; \ + m2[3].z += m3[3].z; \ + m2[3].w += m3[3].w; \ +} \ +MACRO_STOP + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +extern void +RtBezierQuadControlFit3d(RtBezierMatrix B, + RtBezierMatrix P); + +extern void +RtBezierQuadBernsteinWeight3d(RtBezierMatrix W, + RtBezierMatrix B); + +extern void +RtBezierQuadBernsteinWeight4d(RtBezierMatrix W, + RtBezierMatrix B); + +extern void +RtBezierQuadPointDifference3d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal PointU, + RwReal PointV, + RwReal StepU, + RwReal stepV); + +extern void +RtBezierQuadPointDifference4d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal PointU, + RwReal PointV, + RwReal StepU, + RwReal stepV); + +extern void +RtBezierQuadOriginDifference3d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal stepU, + RwReal setpV); + +extern void +RtBezierQuadOriginDifference4d(RtBezierMatrix D, + RtBezierMatrix W, + RwReal stepU, + RwReal setpV); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtBezierQuadSample3d(RwV3d * out, + RtBezierMatrix B, + RwReal u, + RwReal v); + +extern void RtBezierQuadDifferenceStepU3d(RtBezierRow row); +extern void RtBezierQuadDifferenceStepU4d(RtBezierRow row); + +extern void RtBezierQuadDifferenceStepV3d(RtBezierMatrix mat); +extern void RtBezierQuadDifferenceStepV4d(RtBezierMatrix mat); + + +#else /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#define RtBezierQuadSample3d(_out, _P, _u, _v) \ + RtBezierQuadSample3dMacro(_out, _P, _u, _v) + +#define RtBezierQuadDifferenceStepU3d(_row) \ + RtBezierQuadDifferenceStepU3dMacro(_row) + +#define RtBezierQuadDifferenceStepU4d(_row) \ + RtBezierQuadDifferenceStepU4dMacro(_row) + +#define RtBezierQuadDifferenceStepV3d(_mat) \ + RtBezierQuadDifferenceStepV3dMacro(_mat) + +#define RtBezierQuadDifferenceStepV4d(_mat) \ + RtBezierQuadDifferenceStepV4dMacro(_mat) + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +/* + * + */ + +extern void +RtBezierTriangleControlFit3d(RtBezierMatrix T, RtBezierMatrix P); + +extern void +RtBezierQuadFromTriangle(RtBezierMatrix Q, RtBezierMatrix T); + +extern void +RtBezierQuadTangent(RtBezierMatrix D, + RwReal theta, + RtBezierMatrix P); + +extern void +RtBezierQuadTangentPair(RtBezierMatrix Dt, + RtBezierMatrix Dp, + RwReal theta, + RtBezierMatrix P); + +extern void +RtBezierQuadGetNormals(RtBezierMatrix N, + RtBezierMatrix B); + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) + +extern void +_rtBezierGnuPlot(RtBezierMatrix B, + RwChar * name, + RwChar * title); + +#else /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#define _rtBezierGnuPlot(B, name, title) /* No-op */ + +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* (!defined(RTBEZPAT_H)) */ diff --git a/rwsdk/include/d3d8/rtbezpat.rpe b/rwsdk/include/d3d8/rtbezpat.rpe new file mode 100644 index 00000000..e49b65b4 --- /dev/null +++ b/rwsdk/include/d3d8/rtbezpat.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBEZPATCH +{ + + + + e_rwdb_CriterionBEZPATCHLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBEZPATCH e_rwdb_CriterionBEZPATCH; + + diff --git a/rwsdk/include/d3d8/rtbmp.h b/rwsdk/include/d3d8/rtbmp.h new file mode 100644 index 00000000..37b5c97b --- /dev/null +++ b/rwsdk/include/d3d8/rtbmp.h @@ -0,0 +1,51 @@ + +/*************************************************************************** + * * + * Module : rtBMP.h * + * * + * Purpose : Load BMP format files * + * * + **************************************************************************/ + +#ifndef RTBMP_H +#define RTBMP_H + +/** + * \defgroup rtbmp RtBMP + * \ingroup rttool + * + * BMP Image Format Toolkit for RenderWare. + * + * See also http://www.daubnet.com/formats/BMP.html + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtbmp.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtBMPImageWrite(RwImage * image, + const RwChar * imageName); +extern RwImage *RtBMPImageRead(const RwChar * imageName); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTBMP_H */ diff --git a/rwsdk/include/d3d8/rtbmp.rpe b/rwsdk/include/d3d8/rtbmp.rpe new file mode 100644 index 00000000..29dad089 --- /dev/null +++ b/rwsdk/include/d3d8/rtbmp.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionBMP +{ + + + + e_rwdb_CriterionBMPLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionBMP e_rwdb_CriterionBMP; + + diff --git a/rwsdk/include/d3d8/rtcharse.h b/rwsdk/include/d3d8/rtcharse.h new file mode 100644 index 00000000..4fdc2568 --- /dev/null +++ b/rwsdk/include/d3d8/rtcharse.h @@ -0,0 +1,111 @@ +/* + * + * Data structures for the charse toolkit + */ + +/*************************************************************************** + * * + * Module : rtcharse.h * + * * + * Purpose : Charset handling * + * * + **************************************************************************/ + +#ifndef RTCHARSE_H +#define RTCHARSE_H + +/** + * \defgroup rtcharset RtCharset + * \ingroup rttool + * + * Character Set/Foot Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include + +/**************************************************************************** + Global Types + */ + +/* RWPUBLIC */ + +typedef struct RtCharsetDesc RtCharsetDesc; + +/** + * \ingroup rtcharset + * \struct RtCharsetDesc + * Holds information about a character set. + */ +struct RtCharsetDesc +{ + RwInt32 width; + /**< Pixel-width of each character. */ + RwInt32 height; + /**< Pixel-height of each character. */ + RwInt32 width_internal; + /**< Pixel-width used internally, this is usually width+1 to add a border */ + RwInt32 height_internal; + /**< Pixel-height used internally, this is usually height+1 to add a border */ + RwInt32 count; + /**< Number of characters in the set. */ + RwInt32 tilewidth; + /**< Width of raster in characters. */ + RwInt32 tileheight; + /**< Height of raster in characters. */ + +}; + +/** + * \ingroup rtcharset + * \typedef RtCharset + * typedef for a structure defining a character set (opaque). + * \see RtCharsetCreate + */ +typedef RwRaster RtCharset; + +/* RWPUBLICEND */ + +/**************************************************************************** + Function prototypes + */ + +/* RWPUBLIC */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool RtCharsetOpen(void); +extern void RtCharsetClose(void); + +extern RtCharset *RtCharsetPrint(RtCharset * charSet, + const RwChar * string, + RwInt32 x, RwInt32 y); +extern RtCharset *RtCharsetPrintBuffered(RtCharset * charSet, + const RwChar * string, + RwInt32 x, RwInt32 y, + RwBool hideSpaces); +extern RwBool RtCharsetBufferFlush(void); + +extern RtCharset *RtCharsetSetColors(RtCharset * charSet, + const RwRGBA * foreGround, + const RwRGBA * backGround); +extern RtCharset *RtCharsetGetDesc(RtCharset * charset, + RtCharsetDesc * desc); + +extern RtCharset *RtCharsetCreate(const RwRGBA * foreGround, + const RwRGBA * backGround); +extern RwBool RtCharsetDestroy(RtCharset * charSet); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTCHARSE_H */ diff --git a/rwsdk/include/d3d8/rtcharse.rpe b/rwsdk/include/d3d8/rtcharse.rpe new file mode 100644 index 00000000..39c37312 --- /dev/null +++ b/rwsdk/include/d3d8/rtcharse.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionCharset +{ + + + + e_rwdb_CriterionCharsetLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionCharset e_rwdb_CriterionCharset; + + diff --git a/rwsdk/include/d3d8/rtimport.h b/rwsdk/include/d3d8/rtimport.h new file mode 100644 index 00000000..cf4e6283 --- /dev/null +++ b/rwsdk/include/d3d8/rtimport.h @@ -0,0 +1,1278 @@ +/*************************************************************************** + * * + * Module : rtimport.h * + * * + * Purpose : World handling functions. * + * * + **************************************************************************/ + +#ifndef RTIMPORT_H +#define RTIMPORT_H + +/** + * \defgroup rtimport RtWorldImport + * \ingroup rttool + * + * World Import Toolkit for Renderware. + */ + +/** + * \defgroup selectors RtWorldImportPartitionSelectors + * \ingroup rtimport + * + * 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 rtimport + * + * 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 rtimport + * + * 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 rtimport + * + * 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 rtimport + * + * Tools to manipulate the \ref RtWorldImportGuideKDTree that is used to + * manually build the sectors of a world. + */ + +/** + * \defgroup hints RtWorldImportHints + * \ingroup rtimport + * + * 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 rtimport + * \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 + +/**************************************************************************** + Global types + */ + +/** + * Internal use only + */ +typedef union RtWorldImportVertexState RtWorldImportVertexState; + + +/** + * \ingroup rtimport + * \typedef RtWorldImportVertex + * + * typedef for struct \ref RtWorldImportVertex + */ +typedef struct RtWorldImportVertex RtWorldImportVertex; + +/** + * \ingroup rtimport + * \typedef RtWorldImportWeldVertex + * + * typedef for struct \ref RtWorldImportWeldVertex + */ +typedef struct RtWorldImportWeldVertex RtWorldImportWeldVertex; + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildVertex + * + * typedef for struct \ref RtWorldImportBuildVertex + */ +typedef struct RtWorldImportBuildVertex RtWorldImportBuildVertex; + + + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildPolyInfo + * + * typedef for struct \ref RtWorldImportBuildPolyInfo + */ +typedef struct RtWorldImportBuildPolyInfo RtWorldImportBuildPolyInfo; +/** + * \ingroup rtimport + * \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 rtimport + * \struct RtWorldImportBuildVertexMode + * + * Mode of the vertex. + * + */ +union RtWorldImportBuildVertexMode +{ + RtWorldImportVertex *vpVert; + /**< The vertex */ + RwInt32 index; + /**< The index */ +}; + +/** + * \ingroup rtimport + * \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 */ +}; + + + +/** + * \ingroup rtimport + * \typedef RtWorldImportGuideKDTree + * + * typedef for struct \ref RtWorldImportGuideKDTree + */ +typedef struct RtWorldImportGuideKDTree RtWorldImportGuideKDTree; + +/* 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... + */ + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildClipStatistics + * + * typedef for struct \ref RtWorldImportBuildClipStatistics + */ +typedef struct RtWorldImportBuildClipStatistics RtWorldImportBuildClipStatistics; +/** + * \ingroup rtimport + * \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, + * disgregarding overlaps */ + + RwInt32 numPotentialLeft; + /**< The number of potential polygons and fragments on the + * left of the partition, disgregarding overlaps */ + + RwInt32 numPotentialRight; + /**< The number of potential polygons and fragments on the + * right of the partition, disgregarding 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 */ +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportPartition + * + * typedef for struct \ref RtWorldImportPartition + */ +typedef struct RtWorldImportPartition RtWorldImportPartition; +/** + * \ingroup rtimport + * \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 */ +}; + +/** + * \ingroup rtimport + * \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; + +struct _rtWorldImportGuideKDStackElement +{ + RwBool terminal; + RtWorldImportGuideKDTree *node; + _rtWorldImportGuideKDStackElement *next; +}; + +typedef struct _rtWorldImportGuideKDStack _rtWorldImportGuideKDStack; + +struct _rtWorldImportGuideKDStack +{ + _rtWorldImportGuideKDStackElement *top; + _rtWorldImportGuideKDStackElement *current; + _rtWorldImportGuideKDStackElement *bottom; +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildSector + * + * typedef for struct \ref RtWorldImportBuildSector + */ +typedef struct RtWorldImportBuildSector RtWorldImportBuildSector; +/** + * \ingroup rtimport + * \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 */ +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildStatus + * + * typedef for struct \ref RtWorldImportBuildStatus + */ +typedef struct RtWorldImportBuildStatus RtWorldImportBuildStatus; +/** + * \ingroup rtimport + * \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 */ +}; + +/** + * 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 */ +}; + +/** + * \ingroup rtimport + * \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 */ +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportTriangle + * Holds data for each triangle in the import world. + * + * \see RtWorldImportTriangle + */ +typedef struct RtWorldImportTriangle RtWorldImportTriangle; +/** + * \ingroup rtimport + * \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 */ +}; + + +/** + * \ingroup rtimport + * \typedef RtWorldImportHints + * + * typedef for struct \ref RtWorldImportHints + */ +typedef struct RtWorldImportHints RtWorldImportHints; + +/** + * \ingroup rtimport + * \struct RtWorldImportHints + * Bounding box hints used to control the world sectorization process. + * \see RtWorldImportHintsSet + */ +struct RtWorldImportHints +{ + /** The bounding box hints */ + RwBBox *boundingBoxes; + /** The number of bounding box hints */ + RwInt32 numBoundingBoxes; +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportParameters + * + * typedef for struct \ref RtWorldImportParameters + */ +typedef struct RtWorldImportParameters RtWorldImportParameters; + +/** + * \ingroup rtimport + * \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. */ +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImport + * + * typedef for struct \ref RtWorldImport + */ +typedef struct RtWorldImport RtWorldImport; +/** + * \ingroup rtimport + * \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 */ + + + RwSurfaceProperties surfaceProps; /**< The world's surface + lighting properties */ +}; + +/** + * \ingroup rtimport + * \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 rtimport + * \typedef RtWorldImportDestroyVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex destruction. + */ +typedef RwBool (*RtWorldImportDestroyVertexUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtimport + * \typedef RtWorldImportCloneVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex cloning. + */ +typedef RwBool (*RtWorldImportCloneVertexUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc); + +/** + * \ingroup rtimport + * \typedef RtWorldImportInterpVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * vertex interpolation. + */ +typedef RwBool (*RtWorldImportInterpVertexUserdataCallBack)(void **pUserdataDst, void **pUserdata1, void **pUserdata2, RwReal delta); + +/** + * \ingroup rtimport + * \typedef RtWorldImportDestroyPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * polygon destruction. + */ +typedef RwBool (*RtWorldImportDestroyPolygonUserdataCallBack)(void **pUserdata); + +/** + * \ingroup rtimport + * \typedef RtWorldImportSplitPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * polygon division. + */ +typedef RwBool (*RtWorldImportSplitPolygonUserdataCallBack)(void **pUserdataDst, void **pUserdataSrc); + +/** + * \ingroup rtimport + * \typedef RtWorldImportSectorSetVertexUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * the setting of the vertex user data. + */ +typedef RwBool (*RtWorldImportSectorSetVertexUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index); + +/** + * \ingroup rtimport + * \typedef RtWorldImportSectorSetPolygonUserdataCallBack + * + * A pointer to the CallBack function that will be called during + * the setting of the polygon user data. + */ +typedef RwBool (*RtWorldImportSectorSetPolygonUserdataCallBack)(void **pUserdata, RpWorldSector *sector, RwInt32 index); + + + + +/** + * \ingroup rtimport + * \typedef 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. + */ +typedef RwBool (*RtWorldImportTerminationBuildCallBack) + (RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + void *pData); + +/** + * \ingroup rtimport + * \typedef RtWorldImportPartitionBuildCallBack + * + * A pointer to the function that will be called during the + * build process to select a suitable sector partition. + */ +typedef RwReal (*RtWorldImportPartitionBuildCallBack) + (RtWorldImportBuildSector *buildSector, + RtWorldImportBuildStatus *buildStatus, + RtWorldImportPartition *partition, + void *pData); + +/** + * \ingroup rtimport + * \typedef RtWorldImportBuildCallBacks + * + * typedef for struct \ref RtWorldImportBuildCallBacks + */ +typedef struct RtWorldImportBuildCallBacks RtWorldImportBuildCallBacks; /* MAYBE: rename to SectorCallBacks ?*/ +/** + * \ingroup rtimport + * \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 */ +}; + +/** + * \ingroup rtimport + * \typedef RtWorldImportUserdataCallBacks + * + * typedef for struct \ref RtWorldImportUserdataCallBacks + */ +typedef struct RtWorldImportUserdataCallBacks RtWorldImportUserdataCallBacks; +/** + * \ingroup rtimport + * \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 rtimport + * \typedef 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); + +/* TODO: decide where these scheme functions are going and which ones are public and + whether _rt or RT should be used */ +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 +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); + + + +/* END TODO */ + +/* WorldImport hints */ +extern void +RtWorldImportHintsSet(RtWorldImportHints *hints); + +extern RtWorldImportHints * +RtWorldImportHintsGet(void); + +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); + +/* Surface lighting characteristics */ +extern RtWorldImport * +RtWorldImportSetSurfaceProperties(RtWorldImport * world, + RwSurfaceProperties * + surface); + +extern RwSurfaceProperties * +RtWorldImportGetSurfaceProperties(RtWorldImport * world); + +/* 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(); + + + +#endif /* RTIMPORT_H */ + + + + + + + + + + + + + + + + + + + diff --git a/rwsdk/include/d3d8/rtimport.rpe b/rwsdk/include/d3d8/rtimport.rpe new file mode 100644 index 00000000..d4b7ad2b --- /dev/null +++ b/rwsdk/include/d3d8/rtimport.rpe @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionNoHSWorld +{ + + +E_RW_SECTORDEGENERATE, + +E_RW_SECTORINVNOPOLYGONS, + +E_RW_NOPLANE, + +E_RW_SECTORINVPOLY, + +E_RW_SECTORUSED, + +E_RW_MAXBSPDEPTHEXCEEDED, + + + e_rwdb_CriterionNoHSWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionNoHSWorld e_rwdb_CriterionNoHSWorld; + + diff --git a/rwsdk/include/d3d8/rtintel.h b/rwsdk/include/d3d8/rtintel.h new file mode 100644 index 00000000..c11329df --- /dev/null +++ b/rwsdk/include/d3d8/rtintel.h @@ -0,0 +1,1206 @@ +/** + * Intel specific support toolkit + */ + +/********************************************************************** + * + * File : rtintel.h + * + * Abstract : Intel specific support/emulation + * + ********************************************************************** + * + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. or + * Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. will not, under any + * circumstances, be liable for any lost revenue or other damages arising + * from the use of this file. + * + * Copyright (c) 1998 Criterion Software Ltd. + * All Rights Reserved. + * + * RenderWare is a trademark of Canon Inc. + * + ************************************************************************/ + +#ifndef RTINTEL_H +#define RTINTEL_H + +/** + * \defgroup rtintel RtIntel + * \ingroup rttool + * + * Intel CPU Toolkit for RenderWare. + */ + +/**************************************************************************** + Include files + */ + +/* + * Pick up + * typedef struct _rwResEntryTag RwResEntry; + * from baresour.h (internal) / rwcore.h (external) + */ + +/**************************************************************************** + Global Types + */ + +#include "rtintel.rpe" /* automatically generated header file */ + +#if (!defined(RW_FIXED_64)) +typedef struct RwFixed64 RwFixed64; +struct RwFixed64 +{ + RwInt32 msb; + RwUInt32 lsb; +}; + +#define RW_FIXED_64 +#endif /* (!defined(RW_FIXED_64)) */ + +#define doubleFromRwFixed64(x) \ + ( ((double)((x).msb))*((double)(1<<16))*((double)(1<<16)) \ + + ((double)((x).lsb)) ) + +#if (!defined(RPINTELTIMEFUNCTION)) +typedef RwBool(*RtIntelTimeFunction) (void *data); + +#define RPINTELTIMEFUNCTION +#endif /* (!defined(RPINTELTIMEFUNCTION)) */ + +typedef struct RtIntelOverload RtIntelOverload; + +typedef void (*RwTransformFunction) (RwResEntry * repEntry); + +struct RtIntelOverload +{ + rwMatrixMultFn MatrixMultiplyFunction; + rwVectorMultFn VectorMultPointFunction; + rwVectorMultFn VectorMultVectorFunction; + RwTransformFunction TransformFunction; +}; + +#if (defined(__ICL)) +#define DEFINED__ICL " __ICL" +#define UNDEFINED__ICL "" +#else /* (defined(__ICL)) */ +#define DEFINED__ICL "" +#define UNDEFINED__ICL " __ICL" +#endif /* (defined(__ICL)) */ + +#if (defined(_MSC_VER)) + +# pragma comment ( user, "comment:" __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : " "DEFINED " DEFINED__ICL " ; UNDEFINED " UNDEFINED__ICL ) +/* # pragma message (__FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : " "DEFINED " DEFINED__ICL " ; UNDEFINED " UNDEFINED__ICL ) */ +/* # pragma comment ( user, "comment:" __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : " "DEFINED " DEFINED__ICL " ; UNDEFINED " UNDEFINED__ICL ) */ +#if (! (defined(__ICL) || defined(XBOX_DRVMODEL_H)) ) +#pragma message (__DATE__ " " __TIME__ " " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : No MMX intrinsics - defaulting to software emulation") +#pragma message (__DATE__ " " __TIME__ " " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : No SSE intrinsics - defaulting to software emulation") +#pragma comment ( user, "comment:" __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ") : No MMX intrinsics - defaulting to software emulation") +#endif /* (! (defined(__ICL) || defined(XBOX_DRVMODEL_H)) ) */ +#endif /* (defined(_MSC_VER)) */ + +/* + * MMX + */ + +#if (defined(__ICL)) + +#if (!defined(MMINTRIN_H)) +#include "mmintrin.h" +#define MMINTRIN_H +#endif /* (!defined(MMINTRIN_H)) */ + +#else /* (defined(__ICL)) */ + +#if (defined(_MSC_VER)) + +#if (!defined(__M64)) +typedef __int64 Rt_m64; + +#define __M64 +#endif /* (!defined(__M64)) */ + +#else /* (defined(_MSC_VER)) -- e.g. __GNUC__ */ + +#if (!defined(__M64)) + +typedef RwInt64 Rt_m64; + +#define __M64 + +#endif /* (!defined(__M64)) */ + +#endif /* (defined(_MSC_VER)) */ + +#endif /* (defined(__ICL)) */ + +/* + * SSE + */ + +/* + * From + * ccomp.pdf + * 12 Intel C/C++ Compiler User's Guide + * for Win32 Systems With Katmai New Instruction Support + * -------------------------------------------------------- + * Functionality Intrinsics Usage + * You need only define one preprocessor symbol and include the header file + * xmmintrin.h in your application to use the following functionality + * intrinsics: + * #define _MM_FUNCTIONALITY + * #include "xmmintrin.h" + * To encourage the compiler to inline the functionality intrinsic functions for + * better performance, consider using the -Qip and -Qipo compiler switches. + */ + +#if (defined(__ICL)) + +/* #define _MM2_FUNCTIONALITY */ + +/* #define _MM_FUNCTIONALITY */ + +/* #define _MM_NO_ABORT */ + +/* #define _MM_NO_ACCURACY */ + +/* #define _MM_NO_ALIGN_CHECK */ + +/* #define _MM_NO_INLINE */ + +/* + * Undefine "or", since this is valid assembler; e.g. in + * SDK10/include/xmm_func.h + * _asm { + * push eax + * fld f + * fstcw saved_cw + * mov eax, saved_cw + * or eax, 3072 + * mov new_cw, eax + * fldcw new_cw + * fistp ret + * fldcw saved_cw + * pop eax + * } + */ + +#if (!defined(XMMINTRIN_H)) +#include "xmmintrin.h" +#define XMMINTRIN_H +#endif /* (!defined(XMMINTRIN_H)) */ + +typedef __m64 Rt_m64; +typedef __m128 Rt_m128; + +#if (450 <= __ICL) +#if (!defined(EMMINTRIN_H)) +#include "emmintrin.h" +#define EMMINTRIN_H +typedef __m128d Rt_m128d; +typedef __m128i Rt_m128i; +#endif /* (!defined(EMMINTRIN_H)) */ +#else /* (450 <= __ICL) */ +typedef __m128 Rt_m128d; +typedef __m128 Rt_m128i; +#endif /* (450 <= __ICL) */ + +/* + * Report SSE options as compiler messages and object file comments + */ + +#ifdef _MM2_FUNCTIONALITY +#define DEFINED__MM2_FUNCTIONALITY " _MM2_FUNCTIONALITY" +#define UNDEFINED__MM2_FUNCTIONALITY "" +#else /* _MM2_FUNCTIONALITY */ +#define DEFINED__MM2_FUNCTIONALITY "" +#define UNDEFINED__MM2_FUNCTIONALITY " _MM2_FUNCTIONALITY" +#endif /* _MM2_FUNCTIONALITY */ + +#ifdef _MM_FUNCTIONALITY +#define DEFINED__MM_FUNCTIONALITY DEFINED__MM2_FUNCTIONALITY ## " _MM_FUNCTIONALITY" +#define UNDEFINED__MM_FUNCTIONALITY UNDEFINED__MM2_FUNCTIONALITY +#else /* _MM_FUNCTIONALITY */ +#define DEFINED__MM_FUNCTIONALITY DEFINED__MM2_FUNCTIONALITY +#define UNDEFINED__MM_FUNCTIONALITY UNDEFINED__MM2_FUNCTIONALITY ## " _MM_FUNCTIONALITY" +#endif /* _MM_FUNCTIONALITY */ + +#ifdef _MM_NO_ABORT +#define DEFINED__MM_NO_ABORT DEFINED__MM_FUNCTIONALITY ## " _MM_NO_ABORT" +#define UNDEFINED__MM_NO_ABORT UNDEFINED__MM_FUNCTIONALITY +#else /* _MM_NO_ABORT */ +#define DEFINED__MM_NO_ABORT DEFINED__MM_FUNCTIONALITY +#define UNDEFINED__MM_NO_ABORT UNDEFINED__MM_FUNCTIONALITY ## " _MM_NO_ABORT" +#endif /* _MM_NO_ABORT */ + +#ifdef _MM_NO_ACCURACY +#define DEFINED__MM_NO_ACCURACY DEFINED__MM_NO_ABORT ## " _MM_NO_ACCURACY" +#define UNDEFINED__MM_NO_ACCURACY UNDEFINED__MM_NO_ABORT +#else /* _MM_NO_ACCURACY */ +#define DEFINED__MM_NO_ACCURACY DEFINED__MM_NO_ABORT +#define UNDEFINED__MM_NO_ACCURACY UNDEFINED__MM_NO_ABORT ## " _MM_NO_ACCURACY" +#endif /* _MM_NO_ACCURACY */ + +#ifdef _MM_NO_ALIGN_CHECK +#define DEFINED__MM_NO_ALIGN_CHECK DEFINED__MM_NO_ACCURACY ## " _MM_NO_ALIGN_CHECK" +#define UNDEFINED__MM_NO_ALIGN_CHECK UNDEFINED__MM_NO_ACCURACY +#else /* _MM_NO_ALIGN_CHECK */ +#define DEFINED__MM_NO_ALIGN_CHECK DEFINED__MM_NO_ACCURACY +#define UNDEFINED__MM_NO_ALIGN_CHECK UNDEFINED__MM_NO_ACCURACY ## " _MM_NO_ALIGN_CHECK" +#endif /* _MM_NO_ALIGN_CHECK */ + +#ifdef _MM_NO_INLINE +#define DEFINED__MM_NO_INLINE DEFINED__MM_NO_ALIGN_CHECK ## " _MM_NO_INLINE" +#define UNDEFINED__MM_NO_INLINE UNDEFINED__MM_NO_ALIGN_CHECK +#else /* _MM_NO_INLINE */ +#define DEFINED__MM_NO_INLINE DEFINED__MM_NO_ALIGN_CHECK +#define UNDEFINED__MM_NO_INLINE UNDEFINED__MM_NO_ALIGN_CHECK ## " _MM_NO_INLINE" +#endif /* _MM_NO_INLINE */ + +#pragma comment ( user, "comment:" __DATE__" " __TIME__ " - " __FILE__ ":" RW_STRINGIFY_EXPANDED(__LINE__) ) +#pragma comment ( user, "comment:" "DEFINED :" DEFINED__MM_NO_INLINE ) +#pragma comment ( user, "comment:" "UNDEFINED:" UNDEFINED__MM_NO_INLINE ) + +#pragma message (__DATE__" " __TIME__ " - " __FILE__ ":" RW_STRINGIFY_EXPANDED(__LINE__) ) +#pragma message ("DEFINED :" DEFINED__MM_NO_INLINE ) +#pragma message ("UNDEFINED:" UNDEFINED__MM_NO_INLINE ) + +#else /* (defined(__ICL)) */ + +#define _MM_HINT_T0 1 +#define _MM_HINT_T1 2 +#define _MM_HINT_T2 3 +#define _MM_HINT_NTA 0 + +#if (defined(__R5900__)) +typedef RwInt128 Rt_m128; +#else /* (defined(__R5900__)) */ +#if (!defined(_PAIR__M64)) +struct Rt_m128 +{ + Rt_m64 lo; + Rt_m64 hi; +}; +#define _PAIR__M64 +typedef struct Rt_m128 Rt_m128; +#endif /* (!defined(_PAIR__M64)) */ +#endif /* (defined(__R5900__)) */ + +typedef Rt_m128 Rt_m128d; +typedef Rt_m128 Rt_m128i; +#endif /* (defined(__ICL)) */ + +typedef struct RtIntelV4d RtIntelV4d; +struct RtIntelV4d +{ + RwReal w; + RwV3d v3d; +}; + +typedef union _RpSSEOverlayM128 RpSSEOverlayM128; + +union _RpSSEOverlayM128 +{ + float _f[4]; + RwInt32 _d[4]; + RwUInt32 ud[4]; + RwInt16 _w[8]; + RwUInt16 uw[8]; + RwInt8 _b[16]; + RwUInt8 ub[16]; + Rt_m64 m64[2]; + Rt_m128 m128; + RtIntelV4d v4d; + RwSplitBits bits[4]; +}; + +typedef RpSSEOverlayM128 RpWNIOverlayM128; + +typedef union _RpWNIOverlayM128d RpWNIOverlayM128d; + +union _RpWNIOverlayM128d +{ + double df[2]; + float _f[4]; + RwInt32 _d[4]; + RwUInt32 ud[4]; + RwInt16 _w[8]; + RwUInt16 uw[8]; + RwInt8 _b[16]; + RwUInt8 ub[16]; + Rt_m64 m64[2]; + Rt_m128d m128d; + RtIntelV4d v4d; + RwSplitBits bits[4]; +}; + +typedef union _RpWNIOverlayM128i RpWNIOverlayM128i; + +union _RpWNIOverlayM128i +{ + double df[2]; + float _f[4]; + RwInt32 _d[4]; + RwUInt32 ud[4]; + RwInt16 _w[8]; + RwUInt16 uw[8]; + RwInt8 _b[16]; + RwUInt8 ub[16]; + Rt_m64 m64[2]; + Rt_m128i m128i; + RtIntelV4d v4d; + RwSplitBits bits[4]; +}; + +#define RWUNALIGNED16BYTE(ptr) (0x0000000FUL & ((RwUInt32)(ptr))) + +/*--- Plugin API Functions ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* + * MMX + */ + +/* General support intrinsics */ +extern void Rt_m_empty(void); +extern Rt_m64 Rt_m_from_int(int i); +extern int Rt_m_to_int(Rt_m64 m); +extern Rt_m64 Rt_m_packsswb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_packssdw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_packuswb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpckhbw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpckhwd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpckhdq(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpcklbw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpcklwd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_punpckldq(Rt_m64 m1, Rt_m64 m2); + +/* Packed arithmetic intrinsics */ +extern Rt_m64 Rt_m_paddb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddsb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddsw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddusb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_paddusw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubsb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubsw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubusb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_psubusw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pmaddwd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pmulhw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pmullw(Rt_m64 m1, Rt_m64 m2); + +/* Shift intrinsics */ +extern Rt_m64 Rt_m_psllw(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psllwi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_pslld(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_pslldi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psllq(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psllqi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psraw(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psrawi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psrad(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psradi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psrlw(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psrlwi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psrld(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psrldi(Rt_m64 m, int count); +extern Rt_m64 Rt_m_psrlq(Rt_m64 m, Rt_m64 count); +extern Rt_m64 Rt_m_psrlqi(Rt_m64 m, int count); + +/* Logical intrinsics */ +extern Rt_m64 Rt_m_pand(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pandn(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_por(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pxor(Rt_m64 m1, Rt_m64 m2); + +/* Comparision intrinsics */ +extern Rt_m64 Rt_m_pcmpeqb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pcmpeqw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pcmpeqd(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pcmpgtb(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pcmpgtw(Rt_m64 m1, Rt_m64 m2); +extern Rt_m64 Rt_m_pcmpgtd(Rt_m64 m1, Rt_m64 m2); + +/* + * SSE + */ + +/* + * Arithmetic Operations + */ + +extern Rt_m128 Rt_mm_add_ss(Rt_m128 a, Rt_m128 b) /* ADDSS */ ; +extern Rt_m128 Rt_mm_add_ps(Rt_m128 a, Rt_m128 b) /* ADDPS */ ; +extern Rt_m128 Rt_mm_sub_ss(Rt_m128 a, Rt_m128 b) /* SUBSS */ ; +extern Rt_m128 Rt_mm_sub_ps(Rt_m128 a, Rt_m128 b) /* SUBPS */ ; +extern Rt_m128 Rt_mm_mul_ss(Rt_m128 a, Rt_m128 b) /* MULSS */ ; +extern Rt_m128 Rt_mm_mul_ps(Rt_m128 a, Rt_m128 b) /* MULPS */ ; +extern Rt_m128 Rt_mm_div_ss(Rt_m128 a, Rt_m128 b) /* DIVSS */ ; +extern Rt_m128 Rt_mm_div_ps(Rt_m128 a, Rt_m128 b) /* DIVPS */ ; +extern Rt_m128 Rt_mm_sqrt_ss(Rt_m128 a) /* SQRTSS */ ; +extern Rt_m128 Rt_mm_sqrt_ps(Rt_m128 a) /* SQRTPS */ ; +extern Rt_m128 Rt_mm_rcp_ss(Rt_m128 a) /* RCPSS */ ; +extern Rt_m128 Rt_mm_rcp_ps(Rt_m128 a) /* RCPPS */ ; +extern Rt_m128 Rt_mm_rsqrt_ss(Rt_m128 a) /* RSQRTSS */ ; +extern Rt_m128 Rt_mm_rsqrt_ps(Rt_m128 a) /* RSQRTPS */ ; +extern Rt_m128 Rt_mm_min_ss(Rt_m128 a, Rt_m128 b) /* MINSS */ ; +extern Rt_m128 Rt_mm_min_ps(Rt_m128 a, Rt_m128 b) /* MINPS */ ; +extern Rt_m128 Rt_mm_max_ss(Rt_m128 a, Rt_m128 b) /* MAXSS */ ; +extern Rt_m128 Rt_mm_max_ps(Rt_m128 a, Rt_m128 b) /* MAXPS */ ; + +/* + * Logical Operations + */ + +extern Rt_m128 Rt_mm_and_ps(Rt_m128 a, Rt_m128 b) /* ANDPS */ ; +extern Rt_m128 Rt_mm_andnot_ps(Rt_m128 a, + Rt_m128 b) /* ANDNPS */ ; +extern Rt_m128 Rt_mm_or_ps(Rt_m128 a, Rt_m128 b) /* ORPS */ ; +extern Rt_m128 Rt_mm_xor_ps(Rt_m128 a, Rt_m128 b) /* XORPS */ ; + +/* + * Comparisons + */ + +extern Rt_m128 Rt_mm_cmpeq_ss(Rt_m128 a, + Rt_m128 b) /* CMPEQSS */ ; +extern Rt_m128 Rt_mm_cmpeq_ps(Rt_m128 a, + Rt_m128 b) /* CMPEQPS */ ; +extern Rt_m128 Rt_mm_cmplt_ss(Rt_m128 a, + Rt_m128 b) /* CMPLTSS */ ; +extern Rt_m128 Rt_mm_cmplt_ps(Rt_m128 a, + Rt_m128 b) /* CMPLTPS */ ; +extern Rt_m128 Rt_mm_cmple_ss(Rt_m128 a, + Rt_m128 b) /* CMPLESS */ ; +extern Rt_m128 Rt_mm_cmple_ps(Rt_m128 a, + Rt_m128 b) /* CMPLEPS */ ; +extern Rt_m128 Rt_mm_cmpgt_ss(Rt_m128 a, Rt_m128 b) /* CMPLTSS r */ + ; +extern Rt_m128 Rt_mm_cmpgt_ps(Rt_m128 a, Rt_m128 b) /* CMPLTPS r */ + ; +extern Rt_m128 Rt_mm_cmpge_ss(Rt_m128 a, Rt_m128 b) /* CMPLESS r */ + ; +extern Rt_m128 Rt_mm_cmpge_ps(Rt_m128 a, Rt_m128 b) /* CMPLEPS r */ + ; +extern Rt_m128 Rt_mm_cmpneq_ss(Rt_m128 a, + Rt_m128 b) /* CMPNEQSS */ ; +extern Rt_m128 Rt_mm_cmpneq_ps(Rt_m128 a, + Rt_m128 b) /* CMPNEQPS */ ; +extern Rt_m128 Rt_mm_cmpnlt_ss(Rt_m128 a, + Rt_m128 b) /* CMPNLTSS */ ; +extern Rt_m128 Rt_mm_cmpnlt_ps(Rt_m128 a, + Rt_m128 b) /* CMPNLTPS */ ; +extern Rt_m128 Rt_mm_cmpnle_ss(Rt_m128 a, + Rt_m128 b) /* CMPNLESS */ ; +extern Rt_m128 Rt_mm_cmpnle_ps(Rt_m128 a, + Rt_m128 b) /* CMPNLEPS */ ; +extern Rt_m128 Rt_mm_cmpngt_ss(Rt_m128 a, Rt_m128 b) + /* CMPNLTSS r */ ; +extern Rt_m128 Rt_mm_cmpngt_ps(Rt_m128 a, Rt_m128 b) + /* CMPNLTPS r */ ; +extern Rt_m128 Rt_mm_cmpnge_ss(Rt_m128 a, Rt_m128 b) + /* CMPNLESS r */ ; +extern Rt_m128 Rt_mm_cmpnge_ps(Rt_m128 a, Rt_m128 b) + /* CMPNLEPS r */ ; +extern Rt_m128 Rt_mm_cmpord_ss(Rt_m128 a, + Rt_m128 b) /* CMPORDSS */ ; +extern Rt_m128 Rt_mm_cmpord_ps(Rt_m128 a, + Rt_m128 b) /* CMPORDPS */ ; +extern Rt_m128 Rt_mm_cmpunord_ss(Rt_m128 a, + Rt_m128 b) /* CMPUNORDSS */ ; +extern Rt_m128 Rt_mm_cmpunord_ps(Rt_m128 a, + Rt_m128 b) /* CMPUNORDPS */ ; +extern int Rt_mm_comieq_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_comilt_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_comile_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_comigt_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_comige_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_comineq_ss(Rt_m128 a, + Rt_m128 b) /* COMISS */ ; +extern int Rt_mm_ucomieq_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; +extern int Rt_mm_ucomilt_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; +extern int Rt_mm_ucomile_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; +extern int Rt_mm_ucomigt_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; +extern int Rt_mm_ucomige_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; +extern int Rt_mm_ucomineq_ss(Rt_m128 a, + Rt_m128 b) /* UCOMISS */ ; + +/* + * Conversion Operations + */ + +extern int Rt_mm_cvt_ss2si(Rt_m128 a) /* CVTSS2SI */ ; +extern Rt_m64 Rt_mm_cvt_ps2pi(Rt_m128 a) /* CVTPS2PI */ ; +extern int Rt_mm_cvtt_ss2si(Rt_m128 a) /* CVTTSS2SI */ ; +extern Rt_m64 Rt_mm_cvtt_ps2pi(Rt_m128 a) /* CVTTPS2PI */ ; +extern Rt_m128 Rt_mm_cvt_si2ss(Rt_m128 a, + int b) /* CVTSI2SS */ ; +extern Rt_m128 Rt_mm_cvt_pi2ps(Rt_m128 a, + Rt_m64 b) /* CVTPI2PS */ ; + +/* + * Miscellaneous + */ + +extern Rt_m128 Rt_mm_shuffle_ps(Rt_m128 a, Rt_m128 b, + int i) /* SHUFPS */ ; +extern Rt_m128 Rt_mm_unpackhi_ps(Rt_m128 a, + Rt_m128 b) /* UNPCKHPS */ ; +extern Rt_m128 Rt_mm_unpacklo_ps(Rt_m128 a, + Rt_m128 b) /* UNPCKLPS */ ; +extern Rt_m128 Rt_mm_loadh_pi(Rt_m128 a, Rt_m64 * p) /* MOVHPS reg, mem */ + ; +extern void Rt_mm_storeh_pi(Rt_m64 * p, Rt_m128 a) /* MOVHPS mem, reg */ + ; +extern Rt_m128 Rt_mm_movehl_ps(Rt_m128 a, + Rt_m128 b) /* MOVHLPS */ ; +extern Rt_m128 Rt_mm_movelh_ps(Rt_m128 a, + Rt_m128 b) /* MOVLHPS */ ; +extern Rt_m128 Rt_mm_loadl_pi(Rt_m128 a, Rt_m64 * p) + /* MOVLPS reg, mem */ ; +extern void Rt_mm_storel_pi(Rt_m64 * p, Rt_m128 a) /* MOVLPS mem, reg */ + ; +extern int Rt_mm_movemask_ps(Rt_m128 a) /* MOVMSKPS */ ; +extern unsigned int Rt_mm_getcsr(void) /* STMXCSR */ ; +extern void Rt_mm_setcsr(unsigned int i) /* LDMXCSR */ ; + +/* + * Load Operations + */ + +extern Rt_m128 Rt_mm_load_ss(float *p) /* MOVSS */ ; +extern Rt_m128 Rt_mm_load_ps1(float *p) /* MOVSS + shuffling */ + ; +extern Rt_m128 Rt_mm_load_ps(float *p) /* MOVAPS */ ; +extern Rt_m128 Rt_mm_loadu_ps(float *p) /* MOVUPS */ ; +extern Rt_m128 Rt_mm_loadr_ps(float *p) + /* MOVAPS + shuffling */ ; + +/* + * Set Operations + */ + +extern Rt_m128 Rt_mm_set_ss(float w) /* (composite) */ ; +extern Rt_m128 Rt_mm_set_ps1(float w) /* (composite) */ ; +extern Rt_m128 Rt_mm_set_ps(float z, float y, float x, + float w) /* (composite) */ ; +extern Rt_m128 Rt_mm_setr_ps(float z, float y, float x, + float w) /* (composite) */ ; +extern Rt_m128 Rt_mm_setzero_ps(void) /* (composite) */ ; + +/* + * Store Operations + */ + +extern void Rt_mm_store_ss(float *p, + Rt_m128 a) /* MOVSS */ ; +extern void Rt_mm_store_ps1(float *p, Rt_m128 a) + /* MOVSS + shuffling */ ; +extern void Rt_mm_store_ps(float *p, + Rt_m128 a) /* MOVAPS */ ; +extern void Rt_mm_storeu_ps(float *p, + Rt_m128 a) /* MOVUPS */ ; +extern void Rt_mm_storer_ps(float *p, Rt_m128 a) + /* MOVAPS + shuffling */ ; +extern Rt_m128 Rt_mm_move_ss(Rt_m128 a, + Rt_m128 b) /* MOVSS */ ; + +/* + * Integer Intrinsics + */ + +extern int Rt_m_pextrw(Rt_m64 a, int n) /* PEXTRW */ ; +extern Rt_m64 Rt_m_pinsrw(Rt_m64 a, int d, + int n) /* PINSRW */ ; +extern Rt_m64 Rt_m_pmaxsw(Rt_m64 a, Rt_m64 b) /* PMAXSW */ ; +extern Rt_m64 Rt_m_pmaxub(Rt_m64 a, Rt_m64 b) /* PMAXUB */ ; +extern Rt_m64 Rt_m_pminsw(Rt_m64 a, Rt_m64 b) /* PMINSW */ ; +extern Rt_m64 Rt_m_pminub(Rt_m64 a, Rt_m64 b) /* PMINUB */ ; +extern int Rt_m_pmovmskb(Rt_m64 a) /* PMOVMSKB */ ; +extern Rt_m64 Rt_m_pmulhuw(Rt_m64 a, Rt_m64 b) /* PMULHUW */ ; +extern Rt_m64 Rt_m_pshufw(Rt_m64 a, int n) /* PSHUFW */ ; +extern void Rt_m_lwmaskmovq(Rt_m64 d, Rt_m64 n, + char *p) /* MASKMOVQ */ ; + +/* + * Cacheability Support + */ + +extern void Rt_mm_prefetch(char *p, int i) /* PREFETCH */ ; +extern void Rt_mm_stream_pi(Rt_m64 * p, + Rt_m64 a) /* MOVNTQ */ ; +extern void Rt_mm_stream_ps(float *p, + Rt_m128 a) /* MOVNTPS */ ; +extern void Rt_mm_sfence(void) /* SFENCE */ ; + +/* + * WNI + */ + +/* Arithmetic Operations */ + +extern Rt_m128d Rt_mm_add_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_add_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_div_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_div_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_max_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_max_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_min_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_min_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_mul_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_mul_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_sqrt_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_sqrt_pd(Rt_m128d a); +extern Rt_m128d Rt_mm_sub_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_sub_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_andnot_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_and_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_or_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_xor_pd(Rt_m128d a, Rt_m128d b); + +/* Comparisons */ + +extern Rt_m128d Rt_mm_cmpeq_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmplt_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmple_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpgt_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpge_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpord_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpunord_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpneq_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnlt_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnle_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpngt_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnge_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpeq_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmplt_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmple_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpgt_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpge_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpord_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpunord_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpneq_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnlt_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnle_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpngt_sd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_cmpnge_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comieq_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comilt_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comile_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comigt_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comige_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_comineq_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomieq_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomilt_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomile_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomigt_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomige_sd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_ucomineq_sd(Rt_m128d a, Rt_m128d b); + +/* Conversion Operations */ + +extern Rt_m128 Rt_mm_cvtpd_ps(Rt_m128d a); +extern Rt_m128d Rt_mm_cvtps_pd(Rt_m128 a); +extern Rt_m128d Rt_mm_cvtepi32_pd(Rt_m128i a); +extern Rt_m128i Rt_mm_cvtpd_epi32(Rt_m128d a); +extern int Rt_mm_cvtsd_si32(Rt_m128d a); +extern Rt_m128 Rt_mm_cvtsd_ss(Rt_m128 a, Rt_m128d b); +extern Rt_m128d Rt_mm_cvtsi32_sd(Rt_m128d a, int b); +extern Rt_m128d Rt_mm_cvtss_sd(Rt_m128d a, Rt_m128 b); +extern Rt_m128i Rt_mm_cvttpd_epi32(Rt_m128d a); +extern int Rt_mm_cvttsd_si32(Rt_m128d a); +extern Rt_m128 Rt_mm_cvtepi32_ps(Rt_m128i a); +extern Rt_m128i Rt_mm_cvtps_epi32(Rt_m128 a); +extern Rt_m128i Rt_mm_cvttps_epi32(Rt_m128 a); +extern Rt_m64 Rt_mm_cvtpd_pi32(Rt_m128d a); +extern Rt_m64 Rt_mm_cvttpd_pi32(Rt_m128d a); +extern Rt_m128d Rt_mm_cvtpi32_pd(Rt_m64 a); + +/* Miscellaneous Operations */ + +extern Rt_m128d Rt_mm_unpackhi_pd(Rt_m128d a, Rt_m128d b); +extern Rt_m128d Rt_mm_unpacklo_pd(Rt_m128d a, Rt_m128d b); +extern int Rt_mm_movemask_pd(Rt_m128d a); +extern Rt_m128d Rt_mm_shuffle_pd(Rt_m128d a, Rt_m128d b, int i); +extern Rt_m128d Rt_mm_load_pd(const double *p); +extern Rt_m128d Rt_mm_load1_pd(const double *p); +extern Rt_m128d Rt_mm_loadr_pd(const double *p); +extern Rt_m128d Rt_mm_loadu_pd(const double *p); +extern Rt_m128d Rt_mm_load_sd(const double *p); +extern Rt_m128d Rt_mm_loadh_pd(Rt_m128d a, const double *p); +extern Rt_m128d Rt_mm_loadl_pd(Rt_m128d a, const double *p); +extern Rt_m128d Rt_mm_set_sd(double w); +extern Rt_m128d Rt_mm_set1_pd(double w); +extern Rt_m128d Rt_mm_set_pd(double w, double x); +extern Rt_m128d Rt_mm_setr_pd(double w, double x); +extern Rt_m128d Rt_mm_setzero_pd(void); +extern Rt_m128d Rt_mm_move_sd(Rt_m128d a, Rt_m128d b); +extern void Rt_mm_stream_pd(double *p, Rt_m128d a); +extern void Rt_mm_store_sd(double *p, Rt_m128d a); +extern void Rt_mm_store1_pd(double *p, Rt_m128d a); +extern void Rt_mm_store_pd(double *p, Rt_m128d a); +extern void Rt_mm_storeu_pd(double *p, Rt_m128d a); +extern void Rt_mm_storer_pd(double *p, Rt_m128d a); +extern void Rt_mm_storeh_pd(double *p, Rt_m128d a); +extern void Rt_mm_storel_pd(double *p, Rt_m128d a); +extern Rt_m128i Rt_mm_add_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_add_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_add_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m64 Rt_mm_add_si64(Rt_m64 a, Rt_m64 b); +extern Rt_m128i Rt_mm_add_epi64(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_adds_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_adds_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_adds_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_adds_epu16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_avg_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_avg_epu16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_madd_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_max_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_max_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_min_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_min_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_mulhi_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_mulhi_epu16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_mullo_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m64 Rt_mm_mul_su32(Rt_m64 a, Rt_m64 b); +extern Rt_m128i Rt_mm_mul_epu32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_sad_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_sub_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_sub_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_sub_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m64 Rt_mm_sub_si64(Rt_m64 a, Rt_m64 b); +extern Rt_m128i Rt_mm_sub_epi64(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_subs_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_subs_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_subs_epu8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_subs_epu16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_and_si128(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_andnot_si128(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_or_si128(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_xor_si128(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_slli_si128(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_slli_epi16(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_sll_epi16(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_slli_epi32(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_sll_epi32(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_slli_epi64(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_sll_epi64(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_srai_epi16(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_sra_epi16(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_srai_epi32(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_sra_epi32(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_srli_si128(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_srli_epi16(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_srl_epi16(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_srli_epi32(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_srl_epi32(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_srli_epi64(Rt_m128i a, int count); +extern Rt_m128i Rt_mm_srl_epi64(Rt_m128i a, Rt_m128i count); +extern Rt_m128i Rt_mm_cmpeq_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmpeq_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmpeq_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmpgt_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmpgt_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmpgt_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmplt_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmplt_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cmplt_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_cvtsi32_si128(int a); +extern int Rt_mm_cvtsi128_si32(Rt_m128i a); + +/* Miscellaneous Operations */ + +extern Rt_m64 Rt_mm_movepi64_pi64(Rt_m128i a); +extern Rt_m128i Rt_mm_movpi64_epi64(Rt_m64 a); +extern Rt_m128i Rt_mm_move_epi64(Rt_m128i a); +extern Rt_m128i Rt_mm_packs_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_packs_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_packus_epi16(Rt_m128i a, Rt_m128i b); +extern int Rt_mm_extract_epi16(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_insert_epi16(Rt_m128i a, int b, int imm); +extern int Rt_mm_movemask_epi8(Rt_m128i a); +extern Rt_m128i Rt_mm_shuffle_epi32(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_shufflehi_epi16(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_shufflelo_epi16(Rt_m128i a, int imm); +extern Rt_m128i Rt_mm_unpackhi_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpackhi_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpackhi_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpackhi_epi64(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpacklo_epi8(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpacklo_epi16(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpacklo_epi32(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_unpacklo_epi64(Rt_m128i a, Rt_m128i b); +extern Rt_m128i Rt_mm_loadl_epi64(Rt_m128i const *p); +extern Rt_m128i Rt_mm_load_si128(const Rt_m128i * p); +extern Rt_m128i Rt_mm_loadu_si128(const Rt_m128i * p); +extern Rt_m128i Rt_mm_set_epi64(Rt_m64 q1, Rt_m64 q0); +extern Rt_m128i Rt_mm_set_epi32(int i3, int i2, int i1, int i0); +extern Rt_m128i + Rt_mm_set_epi16(short w7, short w6, + short w5, short w4, short w3, short w2, + short w1, short w0); +extern Rt_m128i Rt_mm_set_epi8(char b15, char b14, + char b13, char b12, + char b11, char b10, + char b9, char b8, + char b7, char b6, + char b5, char b4, + char b3, char b2, + char b1, char b0); +extern Rt_m128i Rt_mm_set1_epi64(Rt_m64 q); +extern Rt_m128i Rt_mm_set1_epi32(int i); +extern Rt_m128i Rt_mm_set1_epi16(short w); +extern Rt_m128i Rt_mm_set1_epi8(char b); +extern Rt_m128i Rt_mm_setr_epi64(Rt_m64 q0, Rt_m64 q1); +extern Rt_m128i Rt_mm_setr_epi32(int i0, int i1, int i2, + int i3); +extern Rt_m128i Rt_mm_setr_epi16(short w0, short w1, + short w2, short w3, + short w4, short w5, + short w6, short w7); +extern Rt_m128i Rt_mm_setr_epi8(char b0, char b1, + char b2, char b3, + char b4, char b5, + char b6, char b7, + char b8, char b9, + char b10, char b11, + char b12, char b13, + char b14, char b15); +extern Rt_m128i Rt_mm_setzero_si128(void); + +/* Store Operations */ + +extern void Rt_mm_store_si128(Rt_m128i * p, Rt_m128i a); +extern void Rt_mm_storeu_si128(Rt_m128i * p, Rt_m128i a); +extern void Rt_mm_maskmoveu_si128(Rt_m128i s, Rt_m128i n, + char *p); +extern void Rt_mm_storel_epi64(Rt_m128i * p, Rt_m128i a); +extern void Rt_mm_stream_si128(Rt_m128i * p, Rt_m128i a); +extern void Rt_mm_stream_si32(int *p, int a); +extern void Rt_mm_clflush(void const *p); +extern void Rt_mm_lfence(void); +extern void Rt_mm_mfence(void); + +/* + * API + */ +extern RwUInt32 RtIntelRDTSC(void); +extern RwUInt32 RtIntelToggleEFLAGS(int mask); +extern RwUInt32 RtIntelCPUID(RwUInt32 level, + void *pb, void *pc, void *pd); +extern RwUInt32 RtIntelHaveCPUID(void); +extern RwUInt32 RtIntelHaveRDTSC(void); +extern RwUInt32 RtIntelHaveMMX(void); +extern RwUInt32 RtIntelHaveSSE(void); +extern RwUInt32 RtIntelHaveWNI(void); +extern RwUInt32 RtIntelCpuType(void); + +extern RwBool RtIntelStartTiming(void * data); +extern RwBool RtIntelStopTiming(void *data); +extern RwBool RtIntelTime(RwFixed64 * result, + RtIntelTimeFunction func, + void *data); + +extern RwBool RtIntelPluginAttach(void); + +extern RtIntelOverload *_rtIntelOverloadGetHandle(void); + +extern RxNodeDefinition *RxNodeDefinitionGetSSETransformCSL(void); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* + * LEGACY-SUPPORT -- e.g. + * rwsdk/driver/d3d/baintd3d.c + * is locked at time of writing + */ + +#define RpIntelRDTSC() RtIntelRDTSC() +#define RpIntelToggleEFLAGS(_mask) RtIntelToggleEFLAGS(_mask) +#define RpIntelCPUID(_level, _pb, _pc, _pd) \ + RtIntelCPUID(_level, _pb, _pc, _pd) +#define RpIntelHaveCPUID() RtIntelHaveCPUID() +#define RpIntelHaveRDTSC() RtIntelHaveRDTSC() +#define RpIntelHaveMMX() RtIntelHaveMMX() +#define RpIntelHaveSSE() RtIntelHaveSSE() +#define RpIntelHaveWNI() RtIntelHaveWNI() +#define RpIntelCpuType() RtIntelCpuType() +#define RpIntelStartTiming(_data) RtIntelStartTiming(_data) +#define RpIntelStopTiming(_data) RtIntelStopTiming(_data) +#define RpIntelTime(_result, _func, _data) \ + RtIntelTime(_result, _func, _data) +#define RpIntelPluginAttach() RtIntelPluginAttach() +#define RpNodeDefinitionGetSSETransformCSL() \ + RxNodeDefinitionGetSSETransformCSL() + +typedef RtIntelOverload RwIntelOverload; +typedef RtIntelOverload RpIntelOverload; + +#define _rwIntelOverloadGetHandle() _rtIntelOverloadGetHandle() +#define _rpIntelOverloadGetHandle() _rtIntelOverloadGetHandle() +#define RwIntelHaveSSE() RtIntelHaveSSE() +#define RpIntelHaveSSE() RtIntelHaveSSE() + +#if (defined(RWEMULATEINTELSIMD) || !defined(__ICL)) + +/* + * MMX + */ + +/* General support intrinsics */ +#define _m_empty() Rt_m_empty() +#define _m_from_int(i) Rt_m_from_int(i) +#define _m_to_int(m) Rt_m_to_int(m) +#define _m_packsswb(m1, m2) Rt_m_packsswb(m1, m2) +#define _m_packssdw(m1, m2) Rt_m_packssdw(m1, m2) +#define _m_packuswb(m1, m2) Rt_m_packuswb(m1, m2) +#define _m_punpckhbw(m1, m2) Rt_m_punpckhbw(m1, m2) +#define _m_punpckhwd(m1, m2) Rt_m_punpckhwd(m1, m2) +#define _m_punpckhdq(m1, m2) Rt_m_punpckhdq(m1, m2) +#define _m_punpcklbw(m1, m2) Rt_m_punpcklbw(m1, m2) +#define _m_punpcklwd(m1, m2) Rt_m_punpcklwd(m1, m2) +#define _m_punpckldq(m1, m2) Rt_m_punpckldq(m1, m2) + +/* Packed arithmetic intrinsics */ +#define _m_paddb(m1, m2) Rt_m_paddb(m1, m2) +#define _m_paddw(m1, m2) Rt_m_paddw(m1, m2) +#define _m_paddd(m1, m2) Rt_m_paddd(m1, m2) +#define _m_paddsb(m1, m2) Rt_m_paddsb(m1, m2) +#define _m_paddsw(m1, m2) Rt_m_paddsw(m1, m2) +#define _m_paddusb(m1, m2) Rt_m_paddusb(m1, m2) +#define _m_paddusw(m1, m2) Rt_m_paddusw(m1, m2) +#define _m_psubb(m1, m2) Rt_m_psubb(m1, m2) +#define _m_psubw(m1, m2) Rt_m_psubw(m1, m2) +#define _m_psubd(m1, m2) Rt_m_psubd(m1, m2) +#define _m_psubsb(m1, m2) Rt_m_psubsb(m1, m2) +#define _m_psubsw(m1, m2) Rt_m_psubsw(m1, m2) +#define _m_psubusb(m1, m2) Rt_m_psubusb(m1, m2) +#define _m_psubusw(m1, m2) Rt_m_psubusw(m1, m2) +#define _m_pmaddwd(m1, m2) Rt_m_pmaddwd(m1, m2) +#define _m_pmulhw(m1, m2) Rt_m_pmulhw(m1, m2) +#define _m_pmullw(m1, m2) Rt_m_pmullw(m1, m2) + +/* Shift intrinsics */ +#define _m_psllw(m, count) Rt_m_psllw(m, count) +#define _m_psllwi(m, count) Rt_m_psllwi(m, count) +#define _m_pslld(m, count) Rt_m_pslld(m, count) +#define _m_pslldi(m, count) Rt_m_pslldi(m, count) +#define _m_psllq(m, count) Rt_m_psllq(m, count) +#define _m_psllqi(m, count) Rt_m_psllqi(m, count) +#define _m_psraw(m, count) Rt_m_psraw(m, count) +#define _m_psrawi(m, count) Rt_m_psrawi(m, count) +#define _m_psrad(m, count) Rt_m_psrad(m, count) +#define _m_psradi(m, count) Rt_m_psradi(m, count) +#define _m_psrlw(m, count) Rt_m_psrlw(m, count) +#define _m_psrlwi(m, count) Rt_m_psrlwi(m, count) +#define _m_psrld(m, count) Rt_m_psrld(m, count) +#define _m_psrldi(m, count) Rt_m_psrldi(m, count) +#define _m_psrlq(m, count) Rt_m_psrlq(m, count) +#define _m_psrlqi(m, count) Rt_m_psrlqi(m, count) + +/* Logical intrinsics */ +#define _m_pand(m1, m2) Rt_m_pand(m1, m2) +#define _m_pandn(m1, m2) Rt_m_pandn(m1, m2) +#define _m_por(m1, m2) Rt_m_por(m1, m2) +#define _m_pxor(m1, m2) Rt_m_pxor(m1, m2) + +/* Comparison intrinsics */ +#define _m_pcmpeqb(m1, m2) Rt_m_pcmpeqb(m1, m2) +#define _m_pcmpeqw(m1, m2) Rt_m_pcmpeqw(m1, m2) +#define _m_pcmpeqd(m1, m2) Rt_m_pcmpeqd(m1, m2) +#define _m_pcmpgtb(m1, m2) Rt_m_pcmpgtb(m1, m2) +#define _m_pcmpgtw(m1, m2) Rt_m_pcmpgtw(m1, m2) +#define _m_pcmpgtd(m1, m2) Rt_m_pcmpgtd(m1, m2) + +/* + * SSE + */ + +/* + * Arithmetic Operations + */ + +#define _mm_add_ss(a, b) Rt_mm_add_ss(a, b) +#define _mm_add_ps(a, b) Rt_mm_add_ps(a, b) +#define _mm_sub_ss(a, b) Rt_mm_sub_ss(a, b) +#define _mm_sub_ps(a, b) Rt_mm_sub_ps(a, b) +#define _mm_mul_ss(a, b) Rt_mm_mul_ss(a, b) +#define _mm_mul_ps(a, b) Rt_mm_mul_ps(a, b) +#define _mm_div_ss(a, b) Rt_mm_div_ss(a, b) +#define _mm_div_ps(a, b) Rt_mm_div_ps(a, b) +#define _mm_sqrt_ss(a) Rt_mm_sqrt_ss(a) +#define _mm_sqrt_ps(a) Rt_mm_sqrt_ps(a) +#define _mm_rcp_ss(a) Rt_mm_rcp_ss(a) +#define _mm_rcp_ps(a) Rt_mm_rcp_ps(a) +#define _mm_rsqrt_ss(a) Rt_mm_rsqrt_ss(a) +#define _mm_rsqrt_ps(a) Rt_mm_rsqrt_ps(a) +#define _mm_min_ss(a, b) Rt_mm_min_ss(a, b) +#define _mm_min_ps(a, b) Rt_mm_min_ps(a, b) +#define _mm_max_ss(a, b) Rt_mm_max_ss(a, b) +#define _mm_max_ps(a, b) Rt_mm_max_ps(a, b) + +/* + * Logical Operations + */ + +#define _mm_and_ps(a, b) Rt_mm_and_ps(a, b) +#define _mm_andnot_ps(a, b) Rt_mm_andnot_ps(a, b) +#define _mm_or_ps(a, b) Rt_mm_or_ps(a, b) +#define _mm_xor_ps(a, b) Rt_mm_xor_ps(a, b) + +/* + * Comparisons + */ + +#define _mm_cmpeq_ss(a, b) Rt_mm_cmpeq_ss(a, b) +#define _mm_cmpeq_ps(a, b) Rt_mm_cmpeq_ps(a, b) +#define _mm_cmplt_ss(a, b) Rt_mm_cmplt_ss(a, b) +#define _mm_cmplt_ps(a, b) Rt_mm_cmplt_ps(a, b) +#define _mm_cmple_ss(a, b) Rt_mm_cmple_ss(a, b) +#define _mm_cmple_ps(a, b) Rt_mm_cmple_ps(a, b) +#define _mm_cmpgt_ss(a, b) Rt_mm_cmpgt_ss(a, b) +#define _mm_cmpgt_ps(a, b) Rt_mm_cmpgt_ps(a, b) +#define _mm_cmpge_ss(a, b) Rt_mm_cmpge_ss(a, b) +#define _mm_cmpge_ps(a, b) Rt_mm_cmpge_ps(a, b) +#define _mm_cmpneq_ss(a, b) Rt_mm_cmpneq_ss(a, b) +#define _mm_cmpneq_ps(a, b) Rt_mm_cmpneq_ps(a, b) +#define _mm_cmpnlt_ss(a, b) Rt_mm_cmpnlt_ss(a, b) +#define _mm_cmpnlt_ps(a, b) Rt_mm_cmpnlt_ps(a, b) +#define _mm_cmpnle_ss(a, b) Rt_mm_cmpnle_ss(a, b) +#define _mm_cmpnle_ps(a, b) Rt_mm_cmpnle_ps(a, b) +#define _mm_cmpngt_ss(a, b) Rt_mm_cmpngt_ss(a, b) +#define _mm_cmpngt_ps(a, b) Rt_mm_cmpngt_ps(a, b) +#define _mm_cmpnge_ss(a, b) Rt_mm_cmpnge_ss(a, b) +#define _mm_cmpnge_ps(a, b) Rt_mm_cmpnge_ps(a, b) +#define _mm_cmpord_ss(a, b) Rt_mm_cmpord_ss(a, b) +#define _mm_cmpord_ps(a, b) Rt_mm_cmpord_ps(a, b) +#define _mm_cmpunord_ss(a, b) Rt_mm_cmpunord_ss(a, b) +#define _mm_cmpunord_ps(a, b) Rt_mm_cmpunord_ps(a, b) +#define _mm_comieq_ss(a, b) Rt_mm_comieq_ss(a, b) +#define _mm_comilt_ss(a, b) Rt_mm_comilt_ss(a, b) +#define _mm_comile_ss(a, b) Rt_mm_comile_ss(a, b) +#define _mm_comigt_ss(a, b) Rt_mm_comigt_ss(a, b) +#define _mm_comige_ss(a, b) Rt_mm_comige_ss(a, b) +#define _mm_comineq_ss(a, b) Rt_mm_comineq_ss(a, b) +#define _mm_ucomieq_ss(a, b) Rt_mm_ucomieq_ss(a, b) +#define _mm_ucomilt_ss(a, b) Rt_mm_ucomilt_ss(a, b) +#define _mm_ucomile_ss(a, b) Rt_mm_ucomile_ss(a, b) +#define _mm_ucomigt_ss(a, b) Rt_mm_ucomigt_ss(a, b) +#define _mm_ucomige_ss(a, b) Rt_mm_ucomige_ss(a, b) +#define _mm_ucomineq_ss(a, b) Rt_mm_ucomineq_ss(a, b) + +/* + * Conversion Operations + */ + +#define _mm_cvt_ss2si(a) Rt_mm_cvt_ss2si(a) +#define _mm_cvt_ps2pi(a) Rt_mm_cvt_ps2pi(a) +#define _mm_cvtt_ss2si(a) Rt_mm_cvtt_ss2si(a) +#define _mm_cvtt_ps2pi(a) Rt_mm_cvtt_ps2pi(a) +#define _mm_cvt_si2ss(a, b) Rt_mm_cvt_si2ss(a, b) +#define _mm_cvt_pi2ps(a, b) Rt_mm_cvt_pi2ps(a, b) + +/* + * Miscellaneous + */ + +#define _mm_shuffle_ps(a, b, i) Rt_mm_shuffle_ps(a, b, i) +#define _mm_unpackhi_ps(a, b) Rt_mm_unpackhi_ps(a, b) +#define _mm_unpacklo_ps(a, b) Rt_mm_unpacklo_ps(a, b) +#define _mm_loadh_pi(a, p) Rt_mm_loadh_pi(a, p) +#define _mm_storeh_pi(p, a) Rt_mm_storeh_pi(p, a) +#define _mm_movehl_ps(a, b) Rt_mm_movehl_ps(a, b) +#define _mm_movelh_ps(a, b) Rt_mm_movelh_ps(a, b) +#define _mm_loadl_pi(a, p) Rt_mm_loadl_pi(a, p) +#define _mm_storel_pi(p, a) Rt_mm_storel_pi(p, a) +#define _mm_movemask_ps(a) Rt_mm_movemask_ps(a) +#define _mm_getcsr() Rt_mm_getcsr() +#define _mm_setcsr(i) Rt_mm_setcsr(i) + +/* + *Load Operations + */ + +#define _mm_load_ss(p) Rt_mm_load_ss(p) +#define _mm_load_ps1(p) Rt_mm_load_ps1(p) +#define _mm_load_ps(p) Rt_mm_load_ps(p) +#define _mm_loadu_ps(p) Rt_mm_loadu_ps(p) +#define _mm_loadr_ps(p) Rt_mm_loadr_ps(p) + +/* + * Set Operations + */ + +#define _mm_set_ss(w) Rt_mm_set_ss(w) +#define _mm_set_ps1(w) Rt_mm_set_ps1(w) +#define _mm_set_ps(z, y, x, w) Rt_mm_set_ps(z, y, x, w) +#define _mm_setr_ps(z, y, x, w) Rt_mm_setr_ps(z, y, x, w) +#define _mm_setzero_ps() Rt_mm_setzero_ps() + +/* + * Store Operations + */ + +#define _mm_store_ss(p, a) Rt_mm_store_ss(p, a) +#define _mm_store_ps1(p, a) Rt_mm_store_ps1(p, a) +#define _mm_store_ps(p, a) Rt_mm_store_ps(p, a) +#define _mm_storeu_ps(p, a) Rt_mm_storeu_ps(p, a) +#define _mm_storer_ps(p, a) Rt_mm_storer_ps(p, a) +#define _mm_move_ss(a, b) Rt_mm_move_ss(a, b) + +/* + * Integer Intrinsics + */ + +#define _m_pextrw(a, n) Rt_m_pextrw(a, n) +#define _m_pinsrw(a, d, n) Rt_m_pinsrw(a, d, n) +#define _m_pmaxsw(a, b) Rt_m_pmaxsw(a, b) +#define _m_pmaxub(a, b) Rt_m_pmaxub(a, b) +#define _m_pminsw(a, b) Rt_m_pminsw(a, b) +#define _m_pminub(a, b) Rt_m_pminub(a, b) +#define _m_pmovmskb(a) Rt_m_pmovmskb(a) +#define _m_pmulhuw(a, b) Rt_m_pmulhuw(a, b) +#define _m_pshufw(a, n) Rt_m_pshufw(a, n) +#define _m_lwmaskmovq(d, n, p) Rt_m_lwmaskmovq(d, n, p) + +/* + * Cacheability Support + */ + +#define _mm_prefetch(p, i) Rt_mm_prefetch(p, i) +#define _mm_stream_pi(p, a) Rt_mm_stream_pi(p, a) +#define _mm_stream_ps(p, a) Rt_mm_stream_ps(p, a) +#define _mm_sfence() Rt_mm_sfence() + +#endif /* (defined(RWEMULATEINTELSIMD) || !defined(__ICL)) */ + +#endif /* RTINTEL_H */ diff --git a/rwsdk/include/d3d8/rtintel.rpe b/rwsdk/include/d3d8/rtintel.rpe new file mode 100644 index 00000000..bf297ca0 --- /dev/null +++ b/rwsdk/include/d3d8/rtintel.rpe @@ -0,0 +1,645 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionIntel +{ + + + + e_rwdb_CriterionIntelLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionIntel e_rwdb_CriterionIntel; + + diff --git a/rwsdk/include/d3d8/rtintsec.h b/rwsdk/include/d3d8/rtintsec.h new file mode 100644 index 00000000..cb482b17 --- /dev/null +++ b/rwsdk/include/d3d8/rtintsec.h @@ -0,0 +1,138 @@ +/*************************************************************************** + * * + * Module : rtintsec.h * + * * + * Purpose : Intersection tests on geometry primitives. * + * * + **************************************************************************/ + +#ifndef RTINTSEC_H +#define RTINTSEC_H + +/** + * \defgroup rtintersect RtIntersection + * \ingroup rttool + * + * Object Intersection Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include +#include "rtintsec.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +#define RTINTSECEPSILON (RwReal)(1e-8) +#define RTINTSECEDGEEPS (RwReal)(1e-5) + +#define RtIntersectionLineTriangleMacro(_result, \ + _lineStart, _lineDelta, \ + _v0, _v1, _v2, \ + _distance) \ +MACRO_START \ +{ \ + RwV3d edge1, edge2, tVec, pVec, qVec; \ + RwReal det; \ + \ + /* Find vectors for two edges sharing vert0 */ \ + RwV3dSubMacro(&edge1, (_v1), (_v0)); \ + RwV3dSubMacro(&edge2, (_v2), (_v0)); \ + \ + /* Begin calculating determinant \ + * - also used to calculate U parameter */ \ + RwV3dCrossProductMacro(&pVec, (_lineDelta), &edge2); \ + \ + /* If determinant is \ + * + near zero, ray lies in plane of \ + * triangle \ + * + negative, triangle is backfacing \ + */ \ + det = RwV3dDotProductMacro(&edge1, &pVec); \ + (_result) = (det > RTINTSECEPSILON); \ + \ + if ((_result)) \ + { \ + RwReal lo, hi, u; \ + \ + /* Calculate bounds for parameters with tolerance */ \ + lo = - det*RTINTSECEDGEEPS; \ + hi = det - lo; \ + \ + /* Calculate U parameter and test bounds */ \ + RwV3dSubMacro(&tVec, (_lineStart), (_v0)); \ + u = RwV3dDotProductMacro(&tVec, &pVec); \ + (_result) = (u >= lo && u <= hi); \ + \ + if ((_result)) \ + { \ + RwReal v; \ + \ + /* Calculate V parameter and test bounds */ \ + RwV3dCrossProductMacro(&qVec, &tVec, &edge1); \ + v = RwV3dDotProductMacro((_lineDelta), &qVec); \ + (_result) = (v >= lo && (u + v) <= hi); \ + \ + if ((_result)) \ + { \ + /* Calculate t, \ + * and make sure intersection is in bounds of line */ \ + *(_distance) = RwV3dDotProductMacro(&edge2, &qVec); \ + \ + /* Within bounds of line? */ \ + (_result) = (*(_distance) >= lo && *(_distance) <= hi); \ + \ + if ((_result)) \ + { \ + *(_distance) = ((*(_distance)) / (det)); \ + } \ + } \ + } \ + } \ +} \ +MACRO_STOP + + +/**************************************************************************** + Global Types + */ + + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Line intersections */ +extern RwBool +RtIntersectionLineTriangle(RwV3d *lineStart, RwV3d *lineDelta, + RwV3d *v0, RwV3d *v1, RwV3d *v2, + RwReal *distance); + +/* Sphere intersections */ +extern RwBool +RtIntersectionSphereTriangle(RwSphere *sphere, + RwV3d *v0, RwV3d *v1, RwV3d *v2, + RwV3d *normal, + RwReal *distance); + +/* BBox intersections */ +extern RwBool +RtIntersectionBBoxTriangle(RwBBox *bbox, RwV3d *v0, RwV3d *v1, RwV3d *v2); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTINTSEC_H */ diff --git a/rwsdk/include/d3d8/rtintsec.rpe b/rwsdk/include/d3d8/rtintsec.rpe new file mode 100644 index 00000000..7b2ce6e1 --- /dev/null +++ b/rwsdk/include/d3d8/rtintsec.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionIntsec +{ + + + + e_rwdb_CriterionIntsecLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionIntsec e_rwdb_CriterionIntsec; + + diff --git a/rwsdk/include/d3d8/rtltmap.h b/rwsdk/include/d3d8/rtltmap.h new file mode 100644 index 00000000..1a53b185 --- /dev/null +++ b/rwsdk/include/d3d8/rtltmap.h @@ -0,0 +1,601 @@ + +/** + * \defgroup rtltmap RtLtMap + * \ingroup rttool + * + * Lightmap Generation Toolkit for RenderWare. + */ + +#ifndef RTLTMAP_H +#define RTLTMAP_H + +/*===========================================================================* + *--- Includes --------------------------------------------------------------* + *===========================================================================*/ + +#include "rwcore.h" +#include "rpworld.h" + +#include "rpltmap.h" + + +/** + * \ingroup rtltmap + * \typedef RtLtMapIlluminateSampleCallBack + * \ref RtLtMapIlluminateSampleCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, for groups of samples in the objects + * currently being illuminated. + * + * For lightmapped objects, samples are grouped on a per-polygon basis and + * for vertex-lit objects, samples are grouped on a per-object basis (see + * \ref RtLtMapObjectFlags). + * + * This callback will receive an array of color values to fill in, each + * representing one sample in the current object - this may correspond to + * a texel in the current object's lightmap or the prelight colour of a + * vertex, depending on whether the object is lightmapped and/or vertex-lit. + * It will receive positions (in world-space) for each sample and the normal + * vector (again, in world-space) of each sample (normals are interpolated + * across polygons for non-flat-shaded materials. See \ref RtLtMapMaterialFlags). + * For lightmap samples (not vertex-lighting samples), it will receive + * barycentric coordinates within the current polygon. It will also receive + * a list of RpLights affecting the current object. + * + * The barycentric coordinates may be used, for example, to allow a callback + * to easily import existing lighting data (e.g from previously generated + * lightmaps in a different format, or from an art package with lighting + * functionality). + * + * NOTE: The alpha channel of the RwRGBA results array must NOT be modified. + * These values are used internally and their modification may result in + * unwanted visual artifacts in the resulting lighting solution. + * + * The default RtLtMapIlluminateSampleCallBacks supplied with RtLtMap is + * \ref RtLtMapDefaultSampleCallBack. This callback performs point and area + * lighting (the area lights use are those passed to \ref RtLtMapIlluminate). + * + * \param results A pointer to an array of \ref RwRGBA sample color values + * \param samplePositions A pointer to an array of \ref RwV3d values specifying the + * world-space positions of each of the samples in the results array + * \param baryCoords A pointer to an array of \ref RwV3d values specifying the + * barycentric coordinates (within the current polygon) of + * each of the samples in the results array + * \param numSamples The length of the results, samplePositions, baryCoords and normals arrays + * \param lights An array of pointers to \ref RpLight's affecting the current object + * \param numLights The length of the lights array + * \param normals A pointer to an array of \ref RwV3d values specifying the + * world-space, unit normals of each of the samples in the results array + * + * \return A pointer to the results array on success, NULL otherwise + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + * \see RtLtMapIlluminateProgressCallBack + */ +typedef RwRGBA *(*RtLtMapIlluminateSampleCallBack)(RwRGBA *results, + RwV3d *samplePositions, + RwV3d *baryCoords, + RwUInt32 numSamples, + RpLight **lights, + RwUInt32 numLights, + RwV3d *normals); + +/** + * \ingroup rtltmap + * \typedef RtLtMapIlluminateVisCallBack + * \ref RtLtMapIlluminateVisCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, to determine the visibility between a + * sample and a light. + * + * This callback is called for all samples in the current + * \ref RtLtMapLightingSession and for each light source which may + * potentially affect each of those samples (this may not be all the + * lights in the scene, as some hierarchical culling is performed). + * Each sample may represent a texel in the current object's lightmap + * or the prelight color of a vertex, depending on whether the object + * is lightmapped and/or vertex-lit (see \ref RtLtMapObjectFlags). + * + * The callback will receive a pointer to the world of the current + * \ref RtLtMapLightingSession (this may be used to perform intersection + * tests), the world-space position of the sample, the world-space + * position of the light, a pointer to a light and a pointer to an + * \ref RwRGBAReal result value. + * + * If the light pointer is NULL, this means that the current light + * is an area light (as opposed to an \ref RpLight), of an internal + * format. The area lights use are those passed to \ref RtLtMapIlluminate. + * + * The callback should return FALSE to signify that the light is wholly + * occluded w.r.t the sample position, otherwise it should return TRUE. + * Partial degrees of (color-frequency-dependent) occlusion may be + * expressed by modifying the RwRGBAReal value. This defaults to bright + * white but may be reduced to signify that the light from the light + * source should be attenuated. This could be used to take into account + * light-filtering objects in the scene (such as coloured glass or fog). + * + * The default RtLtMapIlluminateVisCallBack supplied with RtLtMap is + * \ref RtLtMapDefaultVisCallBack. This callback performs visibility + * tests using the line-intersection tests from \ref rtintersect. It tests + * for occlusion by RpWorldSectors and RpAtomics and it respects the + * relevant \ref RtLtMapObjectFlags and \ref RtLtMapMaterialFlags but it + * does not filter light; visibility is determined to be either one or zero. + * + * \param world The world of the current RtLtMapLightingSession + * \param result An RwRGBAReal value to attentuate this light's + * contribution to the current sample + * \param samplePos The world-space positiuon of the sample + * \param lightPos The world-space positiuon of the light + * \param light A pointer to the light (NULL if it is an are light) + * + * \return TRUE if the light is visible from the sample, FALSE if it is occluded + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateSampleCallBack + * \see RtLtMapIlluminateProgressCallBack + */ +typedef RwBool (*RtLtMapIlluminateVisCallBack)(RpWorld *world, + RwRGBAReal *result, + RwV3d *samplePos, + RwV3d *lightPos, + RpLight *light); + +/** + * \ingroup rtltmap + * \typedef RtLtMapIlluminateProgressCallBack + * \ref RtLtMapIlluminateProgressCallBack is the callback to be called, from + * within \ref RtLtMapIlluminate, to allow a user to track lighting progress. + * + * The progress callback will be called at several stages during lighting, + * with a different 'message' parameter value used at each stage (see + * \ref RtLtMapProgressMessage). It will be called at the very start of + * lighting (for a given \ref RtLtMapLightingSession), before any samples + * are lit. It will also be called at the very end of lighting, after all + * samples have been lit. It will be called before and after each lighting + * 'slice' (see \ref RtLtMapIlluminate) and also after each group of + * samples have been lit. + * + * For lightmapped objects, samples are grouped on a per-polygon basis and + * for vertex-lit objects, samples are grouped on a per-object basis (see + * \ref RtLtMapObjectFlags). + * + * The progress callback will receive a RwReal value specifying the percentage + * of samples already lit in the current \ref RtLtMapLightingSession (see + * \ref RtLtMapLightingSessionGetNumSamples). + * + * By returning FALSE, the progress callback may cause early termination of + * the current lighting 'slice' (this may be used, for example, to keep + * the time spent lighting each slice fairly constant). + * + * There is no default progress callback supplied with RtLtMap. + * + * \param message A \ref RtLtMapProgressMessage identifying the stage + * of the current call to the progress callback + * \param value The percentage of samples already lit in the + * current \ref RtLtMapLightingSession + * + * \return FALSE to immediately terminate lighting, otherwise TRUE + * + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateSampleCallBack + * \see RtLtMapIlluminateVisCallBack + */ +typedef RwBool (*RtLtMapIlluminateProgressCallBack)(RwInt32 message, + RwReal value); + + +/** + * \ingroup rtltmap + * \ref RtLtMapProgressMessage is an enumerated type identifying the different + * stages at which the \ref RtLtMapIlluminateProgressCallBack may be called + * from within \ref RtLtMapIlluminate. + * + * \see RtLtMapIlluminateProgressCallBack + * \see RtLtMapIlluminate + */ +enum RtLtMapProgressMessage +{ + rtLTMAPPROGRESSNAMESSAGE = 0, + + rtLTMAPPROGRESSSTART = 1, /**< This is issued at the beginning of + * an incremental lighting session */ + rtLTMAPPROGRESSSTARTSLICE = 2, /**< This is issued at the beginning of every + * slice in an incremental lighting session */ + rtLTMAPPROGRESSUPDATE = 3, /**< This is issued after the lighting of each + * lightmapped triangle or vertex-lit object */ + rtLTMAPPROGRESSENDSLICE = 4, /**< This is issued at the end of every slice + * in an incremental lighting session */ + rtLTMAPPROGRESSEND = 5, /**< This is issued at the end of an + * incremental lighting session */ + + rtLTMAPPROGRESSFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapProgressMessage RtLtMapProgressMessage; + +typedef struct RtLtMapLightingSession RtLtMapLightingSession; +/** + * \ingroup rtltmap + * \typedef RtLtMapLightingSession + * The \ref RtLtMapLightingSession structure holds information to be passed to + * \ref RtLtMapIlluminate. It is used to parameterize the lighting process. + * + * The \ref RtLtMapLightingSession structure encapsulates a set of objects and + * keeps track of the proportion of samples, within that set, that have already + * been lit by calls to \ref RtLtMapIlluminate. Each call performs lighting for + * one 'slice' of the whole 'session'. If the camera member is non-NULL, it is + * important that the camera is not moved between lighting slices. + * + * The \ref RtLtMapLightingSession is also passed to + * \ref RtLtMapLightMapsCreate, \ref RtLtMapLightMapsClear, + * \ref RtLtMapLightMapsDestroy and \ref RtLtMapAreaLightGroupCreate, + * though not all of the session structure's member will be used in + * each of these cases. + * + * \see RtLtMapIlluminate + * \see RtLtMapLightMapsCreate + * \see RtLtMapLightMapsClear + * \see RtLtMapLightMapsDestroy + * \see RtLtMapAreaLightGroupCreate + */ +struct RtLtMapLightingSession +{ + RpWorld *world; /**< This world is that in which collisions are performed + * during illumination (for the purposes of lighting + * visibility determination) */ + RwCamera *camera; /**< An optional pointer to a camera. The camera's frustum + * may be used to cull objects and/or triangles from the + * set of those to be processed. */ + RpWorldSector **sectorList; /**< An optional array of \ref RpWorldSector pointers, + * specifying which sectors in the world to light. If + * this is NULL, then all sectors in the world (or those + * inside the optional camera's frustum) will be lit. */ + RwInt32 numSectors; /**< The length of the sectorList array. If this is set to + * '-1' then none of the sectors in the world will be lit. */ + RpAtomic **atomicList; /**< An optional array of \ref RpAtomic pointers, + * specifying which atomics to light. If this is NULL + * then all atomics in the world (or those inside the + * optional camera's frustum) will be lit. */ + RwInt32 numAtomics; /**< The length of the atomicList array. If this is set to + * '-1' then none of the atomics in the world will be lit. */ + RwUInt32 startSample; /**< Lighting for the current 'slice' should begin with this + * sample. It is the user's responsibility to increment this + * value after each slice. Note that partial lighting is + * quantized to be per-polygon (for lightmapped objects). + * startSample will always be rounded down, not up. */ + RwUInt32 numSamples; /**< This specifies how many lightmap samples should be lit. + * If it is left zero then all samples in the current set + * of objects will be lit. Note that partial lighting is + * quantized to be per-polygon (for lightmapped objects). + * numSamples will always be rounded up, not down. */ + RwUInt32 totalSamples;/**< This specifies how many lightmap samples will be lit in + * total for the world specified (this is filled in by + * \ref RtLtMapIlluminate, not the calling function). */ + RtLtMapIlluminateSampleCallBack sampleCallBack; /**< A \ref RtLtMapIlluminateSampleCallBack + * to use during lighting. If this is left + * NULL, the default callback will be used. */ + RtLtMapIlluminateVisCallBack visCallBack; /**< A \ref RtLtMapIlluminateVisCallBack + * to use during lighting. If this is left + * NULL, the default callback will be used. */ + RtLtMapIlluminateProgressCallBack progressCallBack; /**< A \ref RtLtMapIlluminateProgressCallBack + * to use during lighting. If this is left + * NULL, no progress callback will be used. */ +}; + +/** + * \ingroup rtltmap + * \ref RtLtMapMaterialFlags is an enumerated type specifying the different + * lightmap-related flags which may be applied to materials. These values + * will be taken into consideration within \ref RtLtMapIlluminate. + * + * \see RtLtMapMaterialGetFlags + * \see RtLtMapMaterialSetFlags + * \see RtLtMapMaterialGetAreaLightColor + * \see RtLtMapMaterialSetAreaLightColor + * \see RtLtMapMaterialGetLightMapDensityModifier + * \see RtLtMapMaterialSetLightMapDensityModifier + * \see RtLtMapMaterialGetAreaLightDensityModifier + * \see RtLtMapMaterialSetAreaLightDensityModifier + * \see RtLtMapMaterialSetAreaLightRadiusModifier + * \see RtLtMapMaterialGetAreaLightRadiusModifier + * \see RtLtMapIlluminate + * \see RtLtMapAreaLightGroupCreate + * \see RtLtMapIlluminateVisCallBack + */ +enum RtLtMapMaterialFlags +{ + rtLTMAPMATERIALNAFLAG = 0, + + rtLTMAPMATERIALLIGHTMAP = 1, /**< This material should be lightmapped + * [for non-lightmapped materials within lightmapped objects, + * texel values will be set to (0, 0, 0) (or (255, 255, 255) if + * the rtLTMAPMATERIALAREALIGHT flag is present, so that light- + * emitting textures appear as bright as the light which they are + * emittering) and the mesh may be 'shrunk' in UV-space so as not + * to waste lightmap texels] */ + rtLTMAPMATERIALAREALIGHT = 2, /**< This material is an area light emitter + * (see \ref RtLtMapAreaLightGroupCreate) */ + rtLTMAPMATERIALNOSHADOW = 4, /**< This material does not block light */ + rtLTMAPMATERIALSKY = 8, /**< This material blocks everything but directional + * lights, to allow sky polygons to occlude geometry + * and yet emit directional light (sky or sun light, + * being as if cast from an infinite distance) */ + rtLTMAPMATERIALFLATSHADE = 16, /**< This material will be lit as if flat-shaded + * (polygon normals will be used during illumination) */ + + rtLTMAPMATERIALFLAGFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapMaterialFlags RtLtMapMaterialFlags; + +/** + * \ingroup rtltmap + * \ref RtLtMapObjectFlags is an enumerated type specifying the different + * lightmap-related flags which may be applied to world sectors and + * atomics. These values will be taken into consideration within + * \ref RtLtMapLightMapsCreate and \ref RtLtMapIlluminate. + * + * \see RtLtMapAtomicGetFlags + * \see RtLtMapAtomicSetFlags + * \see RtLtMapWorldSectorGetFlags + * \see RtLtMapWorldSectorSetFlags + * \see RtLtMapLightMapsCreate + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + */ +enum RtLtMapObjectFlags +{ + rtLTMAPOBJECTNAFLAG = 0, + + rtLTMAPOBJECTLIGHTMAP = 1, /**< This object is to be lightmapped */ + rtLTMAPOBJECTVERTEXLIGHT = 2, /**< This object's vertex prelight colours should + * be lit within \ref RtLtMapIlluminate. */ + rtLTMAPOBJECTNOSHADOW = 4, /**< This object does not cast shadows (useful, for + * example, for moving objects for which dynamic + * shadows are to be rendered - such as doors) */ + + rtLTMAPOBJECTFLAGFORCEENUMSIZEINT = 0x7FFFFFFF +}; +typedef enum RtLtMapObjectFlags RtLtMapObjectFlags; + +/* Area-lighting stuff:* + ***********************/ + +/** + * \ingroup rtltmap + * \typedef RtLtMapAreaLightGroup + * \ref RtLtMapAreaLightGroup is a structure which acts as a container + * for area lights created by a call to \ref RtLtMapAreaLightGroupCreate. + * The containers may be chained and passed to \ref RtLtMapIlluminate. + * Each container has an optional pointer to a RwFrame which is used to + * transform the contained area lights relative to the world of the current + * \ref RtLtMapLightingSession and relative to each other (such that, for + * example, lights from multiple worlds, which are connected by portals, + * or which are composed of atomics and not world sectors, may be used + * within a single call to \ref RtLtMapIlluminate). + * + * \see RtLtMapAreaLightGroupCreate + * \see RtLtMapAreaLightGroupDestroy + * \see RtLtMapIlluminate + * \see RtLtMapIlluminateVisCallBack + */ +typedef struct RtLtMapAreaLightGroup RtLtMapAreaLightGroup; +struct RtLtMapAreaLightGroup +{ + RwSList *meshes; /**< A list of hierarchically-grouped area lights */ + RwFrame *frame; /**< An (optional) pointer to a frame (owned by something else) + * whose LTM specifies the coordinate system of this container, + * relative to the world of the current \ref RtLtMapLightingSession. */ + RtLtMapAreaLightGroup *next; /**< A pointer for chaining are light groups together */ +}; + +/* Area light triangles are grouped by source mesh (this may change) */ +typedef struct LtMapAreaLightMesh LtMapAreaLightMesh; +struct LtMapAreaLightMesh +{ + RwUInt32 flags; /* To hold hierarchical visibility culling flags, + * relevant to the object/triangle *currently* being lit. */ + RpMaterial *material; /* The emitter material, containing colour, etc */ + RwSphere sphere; /* Each mesh has an associated center and radius */ + RwReal ROI; /* Centred on the above sphere, the R.O.I. of the + * samples in this mesh (a conservative estimate) */ + RwSList *triangles; /* A list of the area light triangles in this mesh */ +}; + +/* Area light samples are grouped by source triangle */ +typedef struct LtMapAreaLight LtMapAreaLight; +struct LtMapAreaLight +{ + RwUInt16 flags; /* To hold hierarchical visibility culling flags, + * relevant to the object/triangle *currently* being lit. */ + RwUInt16 numSamples; /* Number of area light samples in this triangle */ + RwReal areaPerSample; /* (triangleArea / numSamples) for this triangle */ + RwPlane plane; /* This 'area light' is a triangle, this is its plane. */ + RwSphere sphere; /* This bounds the triangle's points in world-space (it's + * not worth storing 3 points, coarse culling is fine) */ + RwV3d *lights; /* Array of area light sample positions (in world-space) */ +}; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* Lightmap creation functionality: */ +extern RtLtMapLightingSession * +RtLtMapLightMapsCreate(RtLtMapLightingSession *session, + RwReal density, RwRGBA *color); + +extern void +RtLtMapLightMapsDestroy(RtLtMapLightingSession *session); +extern RpAtomic * +RtLtMapAtomicLightMapDestroy(RpAtomic *atomic); +extern RpWorldSector * +RtLtMapWorldSectorLightMapDestroy(RpWorldSector *sector); + +extern RwReal +RtLtMapGetVertexWeldThreshold(void); +extern RwBool +RtLtMapSetVertexWeldThreshold(RwReal threshold); + +extern RwUInt32 +RtLtMapLightMapGetDefaultSize(void); +extern RwBool +RtLtMapLightMapSetDefaultSize(RwUInt32 size); + +extern RwUInt32 +RtLtMapAtomicGetLightMapSize(RpAtomic *atomic); +extern RpAtomic * +RtLtMapAtomicSetLightMapSize(RpAtomic *atomic, RwUInt32 size); +extern RwUInt32 +RtLtMapWorldSectorGetLightMapSize(RpWorldSector *sector); +extern RpWorldSector * +RtLtMapWorldSectorSetLightMapSize(RpWorldSector *sector, RwUInt32 size); + +extern RwUInt32 +RtLtMapAtomicGetFlags(RpAtomic *atomic); +extern RpAtomic * +RtLtMapAtomicSetFlags(RpAtomic *atomic, RwUInt32 flags); +extern RwUInt32 +RtLtMapWorldSectorGetFlags(RpWorldSector *sector); +extern RpWorldSector * +RtLtMapWorldSectorSetFlags(RpWorldSector *sector, RwUInt32 flags); + + +/* Lightmap illumination functionality: */ +extern RwUInt32 +RtLtMapIlluminate(RtLtMapLightingSession *session, + RtLtMapAreaLightGroup *lights); + +extern RwReal +RtLtMapGetSliverAreaThreshold(void); +extern RwBool +RtLtMapSetSliverAreaThreshold(RwReal threshold); + +extern RwRGBA * +RtLtMapDefaultSampleCallBack(RwRGBA *results, + RwV3d *samplePositions, + RwV3d * __RWUNUSED__ baryCoords, + RwUInt32 numSamples, + RpLight **lights, + RwUInt32 numLights, + RwV3d *normals); + +extern RwBool +RtLtMapDefaultVisCallBack(RpWorld *world, + RwRGBAReal __RWUNUSED__ *result, + RwV3d *samplePos, + RwV3d *lightPos, + RpLight __RWUNUSED__ *light); + +extern RtLtMapLightingSession * +RtLtMapLightingSessionInitialize(RtLtMapLightingSession *session, + RpWorld *world); + +extern RwInt32 +RtLtMapLightingSessionGetNumSamples(RtLtMapLightingSession *session); +extern RwInt32 +RtLtMapWorldSectorGetNumSamples(RpWorldSector *sector); +extern RwInt32 +RtLtMapAtomicGetNumSamples(RpAtomic *atomic); + +extern RtLtMapLightingSession * +RtLtMapImagesPurge(RtLtMapLightingSession *session); +extern RpAtomic * +RtLtMapAtomicImagePurge(RpAtomic *atomic); +extern RpWorldSector * +RtLtMapWorldSectorImagePurge(RpWorldSector *sector); + +extern RtLtMapLightingSession * +RtLtMapLightMapsClear(RtLtMapLightingSession *session, RwRGBA *color); +extern RpAtomic * +RtLtMapAtomicLightMapClear(RpAtomic *atomic, RwRGBA *color); +extern RpWorldSector * +RtLtMapWorldSectorLightMapClear(RpWorldSector *sector, RwRGBA *color); + + +/* Material/area-lighting functionality: */ +extern RtLtMapAreaLightGroup * +RtLtMapAreaLightGroupCreate(RtLtMapLightingSession *session, RwReal density); +extern RwBool +RtLtMapAreaLightGroupDestroy(RtLtMapAreaLightGroup *lights); + +extern RwUInt32 +RtLtMapMaterialGetFlags(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetFlags(RpMaterial *material, RwUInt32 flags); + +extern RwReal +RtLtMapMaterialGetLightMapDensityModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetLightMapDensityModifier(RpMaterial *material, RwReal modifier); + +extern RwRGBA +RtLtMapMaterialGetAreaLightColor(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightColor(RpMaterial *material, RwRGBA color); + +extern RwReal +RtLtMapMaterialGetAreaLightDensityModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightDensityModifier(RpMaterial *material, RwReal modifier); + +extern RwReal +RtLtMapMaterialGetAreaLightRadiusModifier(RpMaterial *material); +extern RpMaterial * +RtLtMapMaterialSetAreaLightRadiusModifier(RpMaterial *material, RwReal modifier); + +extern RwUInt32 +RtLtMapGetMaxAreaLightSamplesPerMesh(void); +extern RwBool +RtLtMapSetMaxAreaLightSamplesPerMesh(RwUInt32 maxSamples); +extern RwReal +RtLtMapGetAreaLightDensityModifier(void); +extern RwBool +RtLtMapSetAreaLightDensityModifier(RwReal modifier); +extern RwReal +RtLtMapGetAreaLightRadiusModifier(void); +extern RwBool +RtLtMapSetAreaLightRadiusModifier(RwReal modifier); +extern RwReal +RtLtMapGetAreaLightErrorCutoff(void); +extern RwBool +RtLtMapSetAreaLightErrorCutoff(RwReal tolerance); + + + +/* Texture-saving functionality: */ +extern RwTexDictionary * +RtLtMapTexDictionaryCreate(RtLtMapLightingSession *session); + +extern const RwChar * +RtLtMapGetDefaultPrefixString(void); +extern RwBool +RtLtMapSetDefaultPrefixString(RwChar *string); + +extern RwUInt32 +RtLtMapGetLightMapCounter(void); +extern RwBool +RtLtMapSetLightMapCounter(RwUInt32 value); + + +#if (defined(SKY2_DRVMODEL_H) || defined(NULLSKY_DRVMODEL_H)) + +/* PS2-specific functionality: */ +extern RwTexture *RtLtMapSkyLightMapMakeDarkMap(RwTexture *lightMap); + +extern RwTexture *RtLtMapSkyBaseTextureProcess(RwTexture *texture); +extern RpAtomic *RtLtMapSkyAtomicBaseTexturesProcess(RpAtomic *atomic); +extern RpWorldSector * +RtLtMapSkyWorldSectorBaseTexturesProcess(RpWorldSector *sector); +extern RtLtMapLightingSession * +RtLtMapSkyBaseTexturesProcess(RtLtMapLightingSession *session); + +#endif /* (defined(SKY2_DRVMODEL_H) || defined(NULLSKY_DRVMODEL_H)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTLTMAP_H */ + + diff --git a/rwsdk/include/d3d8/rtltmap.rpe b/rwsdk/include/d3d8/rtltmap.rpe new file mode 100644 index 00000000..e510d78b --- /dev/null +++ b/rwsdk/include/d3d8/rtltmap.rpe @@ -0,0 +1,638 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionLTMAPTOOL +{ + + + + e_rwdb_CriterionLTMAPTOOLLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionLTMAPTOOL e_rwdb_CriterionLTMAPTOOL; + + diff --git a/rwsdk/include/d3d8/rtmipk.h b/rwsdk/include/d3d8/rtmipk.h new file mode 100644 index 00000000..c06a3879 --- /dev/null +++ b/rwsdk/include/d3d8/rtmipk.h @@ -0,0 +1,58 @@ +/** + * Mipmap K toolkit + */ + +/*************************************************************************** + * * + * Module : rtmipk.h * + * * + * Purpose : To calculate mipmap K values for Sky * + * * + **************************************************************************/ + +#ifndef RTMIPK_H +#define RTMIPK_H + +/** + * \defgroup rtmipk RtMipmapK + * \ingroup rttool + * + * Ps2/Mipmap K Value Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" + +/* RWPUBLIC */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void RtMipKWorldCalculateKValues(RpWorld *world, RwCamera *camera); +extern void RtMipKClumpCalculateKValues(RpClump *clump, RwCamera *camera); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTMIPK_H */ diff --git a/rwsdk/include/d3d8/rtmipk.rpe b/rwsdk/include/d3d8/rtmipk.rpe new file mode 100644 index 00000000..24e1fd33 --- /dev/null +++ b/rwsdk/include/d3d8/rtmipk.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionMipmapK +{ + + + + e_rwdb_CriterionMipmapKLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionMipmapK e_rwdb_CriterionMipmapK; + + diff --git a/rwsdk/include/d3d8/rtpick.h b/rwsdk/include/d3d8/rtpick.h new file mode 100644 index 00000000..5ea78058 --- /dev/null +++ b/rwsdk/include/d3d8/rtpick.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * * + * Module : rtpick.h * + * * + * Purpose : Utils for picking atomics. * + * * + **************************************************************************/ + +#ifndef RTPICK_H +#define RTPICK_H + +/** + * \defgroup rtpick RtPick + * \ingroup rttool + * + * Picking Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rtpick.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Camera pixel ray */ +extern const RwCamera *RwCameraCalcPixelRay(const RwCamera *camera, + RwLine *line, + const RwV2d *pixel); + +/* Picking atomics */ +extern RpAtomic *RpWorldPickAtomicOnLine(RpWorld *world, + const RwLine *line); +extern RpAtomic *RwCameraPickAtomicOnPixel(const RwCamera *camera, + const RwV2d *pixel); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* RTPICK_H */ diff --git a/rwsdk/include/d3d8/rtpick.rpe b/rwsdk/include/d3d8/rtpick.rpe new file mode 100644 index 00000000..055ea9ff --- /dev/null +++ b/rwsdk/include/d3d8/rtpick.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPick +{ + + + + e_rwdb_CriterionPickLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPick e_rwdb_CriterionPick; + + diff --git a/rwsdk/include/d3d8/rtpitexd.h b/rwsdk/include/d3d8/rtpitexd.h new file mode 100644 index 00000000..39287bcd --- /dev/null +++ b/rwsdk/include/d3d8/rtpitexd.h @@ -0,0 +1,74 @@ +/*********************************************************************** + * + * Module: rtpitexd.h + * + * Purpose: Platform Independent Texture Dictionaries + * + ***********************************************************************/ + +#if !defined( RTPITEXD_H ) +#define RTPITEXD_H + +/** + * \defgroup rtpitexd RtPITexD + * \ingroup rttool + * + * Platform Independent Texture Dictionaries + * + */ + + +/* ===================================================================== + * Includes + * ===================================================================== */ +#include +#include /* automatically generated */ + + +/* ===================================================================== + * Defines + * ===================================================================== */ + + +/* ===================================================================== + * Module specific type definitions + * ===================================================================== */ + +/* ===================================================================== + * Extern variables + * ===================================================================== */ + + +/* ===================================================================== + * Extern function prototypes + * ===================================================================== */ + +#if defined( __cplusplus ) +extern "C" +{ +#endif /* defined( __cplusplus ) */ + +/* RWPUBLIC */ + +extern RwUInt32 +RtPITexDictionaryStreamGetSize( const RwTexDictionary *texDict ); + +extern RwTexDictionary * +RtPITexDictionaryStreamRead( RwStream *stream ); + +extern RwTexDictionary * +RtPITexDictionaryStreamWrite( RwTexDictionary *texDict, + RwStream *stream ); + +/* RWPUBLICEND */ + +extern void +_rwImageGammaUnCorrectArrayOfRGBA( RwRGBA * rgbaOut, + RwRGBA * rgbaIn, + RwInt32 numEls ); + +#if defined( __cplusplus ) +} +#endif /* defined( __cplusplus ) */ + +#endif /* !defined( RTPITEXD_H ) */ diff --git a/rwsdk/include/d3d8/rtpitexd.rpe b/rwsdk/include/d3d8/rtpitexd.rpe new file mode 100644 index 00000000..0650ea5c --- /dev/null +++ b/rwsdk/include/d3d8/rtpitexd.rpe @@ -0,0 +1,682 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPITexDict +{ + + + + e_rwdb_CriterionPITexDictLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPITexDict e_rwdb_CriterionPITexDict; + + diff --git a/rwsdk/include/d3d8/rtpng.h b/rwsdk/include/d3d8/rtpng.h new file mode 100644 index 00000000..694c8400 --- /dev/null +++ b/rwsdk/include/d3d8/rtpng.h @@ -0,0 +1,49 @@ + +/*************************************************************************** + * * + * Module : rtPng.h * + * * + * Purpose : Load PNG format files * + * * + **************************************************************************/ + +#ifndef RTPNG_H +#define RTPNG_H + +/** + * \defgroup rtpng RtPNG + * \ingroup rttool + * + * PNG/Portable Network Graphics Image Format Toolkit for RenderWare. + * + * See also http://www.libpng.org/pub/png/ + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtpng.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtPNGImageWrite(RwImage * image, const RwChar * imageName); +extern RwImage *RtPNGImageRead(const RwChar * imageName); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTPNG_H */ diff --git a/rwsdk/include/d3d8/rtpng.rpe b/rwsdk/include/d3d8/rtpng.rpe new file mode 100644 index 00000000..7a6b6cc2 --- /dev/null +++ b/rwsdk/include/d3d8/rtpng.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionPNG +{ + + + + e_rwdb_CriterionPNGLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionPNG e_rwdb_CriterionPNG; + + diff --git a/rwsdk/include/d3d8/rtquat.h b/rwsdk/include/d3d8/rtquat.h new file mode 100644 index 00000000..05e971d0 --- /dev/null +++ b/rwsdk/include/d3d8/rtquat.h @@ -0,0 +1,646 @@ +/* + * Data structures for Quaternions + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Hamilton.html + * + * Copyright (c) Criterion Software Limited + */ + +#ifndef RTQUAT_H +#define RTQUAT_H + +/** + * \defgroup rtquat RtQuat + * \ingroup rttool + * + * Quaternion Toolkit for RenderWare. + * + * See also http://www.gamasutra.com/features/19980703/quaternions_01.htm + */ + +/* + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Hamilton.html + * On 16 October 1843 (a Monday) Hamilton was walking in along the Royal + * Canal with his wife to preside at a Council meeting of the Royal Irish + * Academy. + * + * Although his wife talked to him now and again Hamilton hardly + * heard, for the discovery of the quaternions, the first noncommutative + * algebra to be studied, was taking shape in his mind:- + * + * "And here there dawned on me the notion that we must admit, in + * some sense, a fourth dimension of space for the purpose of calculating + * with triples ... An electric circuit seemed to close, and a spark + * flashed forth." + */ + + +/**************************************************************************** + Includes + */ + +#include +/* renderware */ +#include "rwcore.h" + +#include "rtquat.rpe" /* automatically generated header file */ + +#define RW_TOL_ORTHONORMAL ((RwReal)0.01) + +/**************************************************************************** + Global Types + */ + + +typedef struct RtQuat RtQuat; +/** + * \ingroup rtquat + * \struct RtQuat + * A structure describing a Quaternion + * +*/ +struct RtQuat +{ + RwV3d imag; /**< The imaginary part(s) */ + RwReal real; /**< The real part */ +}; + + +/**************************************************************************** + Defines + */ + +#define RtQuatInitMacro( result, _x, _y, _z, _w) \ +MACRO_START \ +{ \ + (result)->real = (_w); \ + (result)->imag.x = (_x); \ + (result)->imag.y = (_y); \ + (result)->imag.z = (_z); \ +} \ +MACRO_STOP + +#if (!defined(RtQuatAssignMacro)) +#define RtQuatAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RtQuatAssignMacro)) */ + +#define RtQuatAddMacro( result, q1, q2 ) \ +MACRO_START \ +{ \ + (result)->real = (q1)->real + (q2)->real; \ + RwV3dAddMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ +} \ +MACRO_STOP + +#define RtQuatIncrementRealPartMacro(result, s, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real + s; \ + (result)->imag.x = (q)->imag.x; \ + (result)->imag.y = (q)->imag.y; \ + (result)->imag.z = (q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatDecrementRealPartMacro(result, s, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real - s; \ + (result)->imag.x = (q)->imag.x; \ + (result)->imag.y = (q)->imag.y; \ + (result)->imag.z = (q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatIncrementMacro( result, dq ) \ +MACRO_START \ +{ \ + (result)->real = (result)->real + (dq)->real; \ + RwV3dAddMacro(&(result)->imag, &(result)->imag, &(dq)->imag); \ +} \ +MACRO_STOP + +#define RtQuatSubMacro( result, q1, q2 ) \ +MACRO_START \ +{ \ + (result)->real = (q1)->real - (q2)->real; \ + RwV3dSubMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ +} \ +MACRO_STOP + +#define RtQuatNegateMacro( result, q ) \ +MACRO_START \ +{ \ + (result)->real = -(q)->real; \ + (result)->imag.x = -(q)->imag.x; \ + (result)->imag.y = -(q)->imag.y; \ + (result)->imag.z = -(q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatConjugateMacro( result, q) \ +MACRO_START \ +{ \ + (result)->real = (q)->real; \ + (result)->imag.x = -(q)->imag.x; \ + (result)->imag.y = -(q)->imag.y; \ + (result)->imag.z = -(q)->imag.z; \ +} \ +MACRO_STOP + +#define RtQuatScaleMacro(result, q, scale ) \ +MACRO_START \ +{ \ + (result)->real = (q)->real * scale; \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, scale); \ +} \ +MACRO_STOP + +#define RtQuatModulusSquaredMacro( q ) \ + ((q)->real * (q)->real + \ + RwV3dDotProductMacro(&(q)->imag, &(q)->imag)) + +#define RtQuatModulusMacro( result, q ) \ +MACRO_START \ +{ \ + (result) = RtQuatModulusSquaredMacro(q); \ + rwSqrtMacro(&result, result); \ +} \ +MACRO_STOP + +#define RtQuatMultiplyMacro( result, q1, q2) \ +MACRO_START \ +{ \ + /* \ + * Assumes q1 != result != q2 \ + */ \ + (result)->real = \ + (q1)->real * (q2)->real - \ + RwV3dDotProductMacro(&(q1)->imag,&(q2)->imag); \ + RwV3dCrossProductMacro(&(result)->imag, &(q1)->imag, &(q2)->imag); \ + RwV3dIncrementScaledMacro(&(result)->imag, &(q2)->imag, (q1)->real); \ + RwV3dIncrementScaledMacro(&(result)->imag, &(q1)->imag, (q2)->real); \ +} \ +MACRO_STOP + +#define RtQuatReciprocalMacro( result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal val = RtQuatModulusSquaredMacro(q); \ + \ + if (val > (RwReal) 0) \ + { \ + val = ((RwReal)1) / val; \ + (result)->real = (q)->real * val; \ + val = -val; \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, val); \ + } \ +} \ +MACRO_STOP + +#define RtQuatSquareMacro( result, q ) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal val = ((RwReal)2) * (q)->real ; \ + \ + (result)->real = \ + (q)->real * (q)->real - \ + RwV3dDotProductMacro(&(q)->imag, &(q)->imag); \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, val); \ +} \ +MACRO_STOP + +#define RtQuatSquareRootMacro( result, q ) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + * other root is of course -result \ + */ \ + RwReal val; \ + \ + RtQuatModulusMacro(val,q); \ + val = ((q)->real + val) * ((RwReal) 0.5); \ + \ + if (val > ((RwReal)0)) \ + { \ + rwSqrtMacro(&val, val); \ + (result)->real = val; \ + val = ((RwReal)0.5) / val; \ + RwV3dScale(&(result)->imag, &(q)->imag, val); \ + } \ + else \ + { \ + result->imag.x = -(q)->real; \ + rwSqrtMacro(&(result->imag.x), result->imag.x); \ + result->imag.y = ((RwReal)0); \ + result->imag.x = ((RwReal)0); \ + result->real = ((RwReal)0); \ + } \ +} \ +MACRO_STOP + +#define RtQuatLogMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + const RwReal mod2 = RtQuatModulusSquaredMacro(q); \ + RwReal sin_b; \ + RwReal radians; \ + RwReal factor; \ + \ + sin_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&sin_b, sin_b); \ + radians = (RwReal) RwATan2(sin_b, (q)->real); \ + factor = (sin_b > (RwReal) 0) ? (((RwReal)radians) / sin_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = ((RwReal) RwLog(mod2)) * ((RwReal) 0.5); \ + \ +} \ +MACRO_STOP + +#define RtQuatExpMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + const RwReal exp_a = (RwReal)RwExp((q)->real); \ + RwReal mod_b; \ + RwReal factor; \ + \ + mod_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&mod_b, mod_b); \ + factor = ( (mod_b > (RwReal) 0) ? \ + (exp_a * ((RwReal)RwSin(mod_b)) / mod_b) : \ + 0 ) ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = exp_a * (RwReal)RwCos(mod_b); \ +} \ +MACRO_STOP + +#define RtQuatPowMacro( result, q, e) \ +MACRO_START \ +{ \ + RtQuat qLog; \ + \ + RtQuatLogMacro(&qLog, q); \ + RtQuatScaleMacro(&qLog, &qLog, e); \ + RtQuatExpMacro(result, &qLog); \ +} \ +MACRO_STOP + +#define RtQuatUnitLogMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal sin_b ; \ + RwReal radians ; \ + RwReal factor ; \ + \ + sin_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&sin_b, sin_b); \ + radians = (RwReal)RwATan2(sin_b, (q)->real); \ + factor = (sin_b > (RwReal) 0) ? (((RwReal)radians) / sin_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = (RwReal)0; \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitExpMacro(result, q) \ +MACRO_START \ +{ \ + /* \ + * Assumes result != q \ + */ \ + RwReal mod_b; \ + RwReal factor; \ + \ + mod_b = RwV3dDotProduct(&(q)->imag, &(q)->imag); \ + rwSqrtMacro(&mod_b, mod_b); \ + factor = (mod_b > (RwReal) 0) ? (((RwReal)RwSin(mod_b)) / mod_b) : 0 ; \ + \ + RwV3dScaleMacro(&(result)->imag, &(q)->imag, factor); \ + (result)->real = (RwReal)RwCos(mod_b); \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitPowMacro( result, q, e) \ +MACRO_START \ +{ \ + RtQuat qLog; \ + \ + RtQuatUnitLogMacro(&qLog, q); \ + RwV3dScaleMacro(&qLog.imag, &qLog.imag, e); \ + RtQuatUnitExpMacro(result, &qLog); \ +} \ +MACRO_STOP + +#define RtQuatConvertToMatrixMacro(qpQuat, mpMatrix) \ +MACRO_START \ +{ \ + RwReal rS; \ + RwV3d rV; \ + RwV3d rW; \ + RwV3d square; \ + RwV3d cross; \ + \ + rS = ((RwReal) 2) / RtQuatModulusSquaredMacro((qpQuat)); \ + \ + RwV3dScale(&rV, &(qpQuat)->imag, rS); \ + RwV3dScale(&rW, &rV, (qpQuat)->real); \ + \ + square.x = (qpQuat)->imag.x * rV.x; \ + square.y = (qpQuat)->imag.y * rV.y; \ + square.z = (qpQuat)->imag.z * rV.z; \ + \ + cross.x = (qpQuat)->imag.y * rV.z; \ + cross.y = (qpQuat)->imag.z * rV.x; \ + cross.z = (qpQuat)->imag.x * rV.y; \ + \ + (mpMatrix)->right.x = ((RwReal) 1) - (square.y + square.z); \ + (mpMatrix)->right.y = cross.z + rW.z; \ + (mpMatrix)->right.z = cross.y - rW.y; \ + \ + (mpMatrix)->up.x = cross.z - rW.z; \ + (mpMatrix)->up.y = ((RwReal) 1) - (square.z + square.x); \ + (mpMatrix)->up.z = cross.x + rW.x; \ + \ + (mpMatrix)->at.x = cross.y + rW.y; \ + (mpMatrix)->at.y = cross.x - rW.x; \ + (mpMatrix)->at.z = ((RwReal) 1) - (square.x + square.y); \ + \ + /* Set position */ \ + (mpMatrix)->pos.x = ((RwReal) 0); \ + (mpMatrix)->pos.y = ((RwReal) 0); \ + (mpMatrix)->pos.z = ((RwReal) 0); \ + \ + /* Matrix is orthogonal */ \ + rwMatrixSetFlags((mpMatrix), \ + (rwMATRIXTYPEORTHOGANAL & \ + ~rwMATRIXINTERNALIDENTITY) ); \ + \ +} \ +MACRO_STOP + +#define RtQuatUnitConvertToMatrixMacro(qpQuat, mpMatrix) \ +MACRO_START \ +{ \ + const RwReal x = (qpQuat)->imag.x; \ + const RwReal y = (qpQuat)->imag.y; \ + const RwReal z = (qpQuat)->imag.z; \ + const RwReal w = (qpQuat)->real; \ + RwV3d square; \ + RwV3d cross; \ + RwV3d wimag; \ + \ + square.x = x * x; \ + square.y = y * y; \ + square.z = z * z; \ + \ + cross.x = y * z; \ + cross.y = z * x; \ + cross.z = x * y; \ + \ + wimag.x = w * x; \ + wimag.y = w * y; \ + wimag.z = w * z; \ + \ + (mpMatrix)->right.x = 1 - 2 * (square.y + square.z); \ + (mpMatrix)->right.y = 2 * (cross.z + wimag.z); \ + (mpMatrix)->right.z = 2 * (cross.y - wimag.y); \ + \ + (mpMatrix)->up.x = 2 * (cross.z - wimag.z); \ + (mpMatrix)->up.y = 1 - 2 * (square.x + square.z); \ + (mpMatrix)->up.z = 2 * (cross.x + wimag.x); \ + \ + (mpMatrix)->at.x = 2 * (cross.y + wimag.y); \ + (mpMatrix)->at.y = 2 * (cross.x - wimag.x); \ + (mpMatrix)->at.z = (1 - 2 * (square.x + square.y)); \ + \ + /* Set position */ \ + (mpMatrix)->pos.x = ((RwReal) 0); \ + (mpMatrix)->pos.y = ((RwReal) 0); \ + (mpMatrix)->pos.z = ((RwReal) 0); \ + \ + /* Matrix is orthonormal */ \ + rwMatrixSetFlags((mpMatrix), \ + (rwMATRIXTYPEORTHONORMAL & \ + ~rwMATRIXINTERNALIDENTITY) ); \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtQuatInit( result, _x, _y, _z, _w) \ + RtQuatInitMacro( result, _x, _y, _z, _w) + +#define RtQuatAssign( to, from ) \ + RtQuatAssignMacro( to, from ) + +#define RtQuatAdd( result, q1, q2 ) \ + RtQuatAddMacro( result, q1, q2 ) + +#define RtQuatIncrementRealPart(result, s, q) \ + RtQuatIncrementRealPartMacro(result, s, q) + +#define RtQuatDecrementRealPart(result, s, q) \ + RtQuatDecrementRealPartMacro(result, s, q) + +#define RtQuatIncrement( result, dq ) \ + RtQuatIncrementMacro( result, dq ) + +#define RtQuatSub( result, q1, q2 ) \ + RtQuatSubMacro( result, q1, q2 ) + +#define RtQuatNegate( result, q ) \ + RtQuatNegateMacro( result, q ) + +#define RtQuatConjugate( result, q) \ + RtQuatConjugateMacro( result, q) + +#define RtQuatScale(result, q, scale ) \ + RtQuatScaleMacro(result, q, scale ) + +#define RtQuatModulusSquared( q ) \ + RtQuatModulusSquaredMacro( q ) + +#define RtQuatMultiply( result, q1, q2) \ + RtQuatMultiplyMacro( result, q1, q2) + +#define RtQuatReciprocal( result, q) \ + RtQuatReciprocalMacro( result, q) + +#define RtQuatSquare( result, q ) \ + RtQuatSquareMacro( result, q ) + +#define RtQuatSquareRoot( result, q ) \ + RtQuatSquareRootMacro( result, q ) + +#define RtQuatLog( result, q ) \ + RtQuatLogMacro( result, q ) + +#define RtQuatExp( result, q ) \ + RtQuatExpMacro( result, q ) + +#define RtQuatPow( result, q, e ) \ + RtQuatPowMacro( result, q, e ) + +#define RtQuatUnitLog( result, q ) \ + RtQuatUnitLogMacro( result, q ) + +#define RtQuatUnitExp( result, q ) \ + RtQuatUnitExpMacro( result, q ) + +#define RtQuatUnitPow( result, q, e ) \ + RtQuatUnitPowMacro( result, q, e ) + +#define RtQuatConvertToMatrix(qpQuat, mpMatrix) \ + RtQuatConvertToMatrixMacro(qpQuat, mpMatrix) + +#define RtQuatUnitConvertToMatrix(qpQuat, mpMatrix) \ + RtQuatUnitConvertToMatrixMacro(qpQuat, mpMatrix) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RtQuatConvertFromMatrix(RtQuat * const qpQuat, + const RwMatrix * const mpMatrix); + +extern RtQuat * +RtQuatRotate(RtQuat * quat, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combineOp); + +extern const RtQuat * +RtQuatQueryRotate(const RtQuat *quat, + RwV3d * unitAxis, + RwReal * angle); + +extern RwV3d * +RtQuatTransformVectors(RwV3d * vectorsOut, + const RwV3d * vectorsIn, + const RwInt32 numPoints, + const RtQuat *quat); + +extern RwReal +RtQuatModulus(RtQuat * q); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtQuatInit(RtQuat * result, RwReal x, RwReal y, RwReal z, RwReal w); + +extern void +RtQuatAssign(RtQuat * to, RtQuat * from); + +extern void +RtQuatAdd(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatIncrementRealPart(RtQuat * result, RwReal s, RtQuat * q); + +extern void +RtQuatDecrementRealPart(RtQuat * result, RwReal s, RtQuat * q); + +extern void +RtQuatIncrement(RtQuat * result, RtQuat * dq); + +extern void +RtQuatSub(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatNegate(RtQuat * result, RtQuat * q); + +extern void +RtQuatConjugate(RtQuat * result, RtQuat * q); + +extern void +RtQuatScale(RtQuat * result, RtQuat * q, RwReal scale); + +extern RwReal +RtQuatModulusSquared(RtQuat * q); + +extern void +RtQuatMultiply(RtQuat * result, RtQuat * q1, RtQuat * q2); + +extern void +RtQuatReciprocal(RtQuat * result, RtQuat * q); + +extern void +RtQuatSquare(RtQuat * result, RtQuat * q); + +extern void +RtQuatSquareRoot(RtQuat * result, RtQuat * q); + +extern void +RtQuatLog(RtQuat * result, RtQuat * q); + +extern void +RtQuatExp(RtQuat * result, RtQuat * q); + +extern void +RtQuatPow(RtQuat * result, RtQuat * q, RwReal e); + +extern void +RtQuatUnitLog(RtQuat * result, RtQuat * q); + +extern void +RtQuatUnitExp(RtQuat * result, RtQuat * q); + +extern void +RtQuatUnitPow(RtQuat * result, RtQuat * q, RwReal e); + +extern void +RtQuatConvertToMatrix(const RtQuat * const qpQuat, + RwMatrix * const mpMatrix); + +extern void +RtQuatUnitConvertToMatrix(const RtQuat * const qpQuat, + RwMatrix * const mpMatrix); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* + * Backwards compatibility code + */ + +typedef RtQuat RpQuat; + +#define RpAnimQuatConvertFromMatrix(qpQuat, mpMatrix) \ + RtQuatConvertFromMatrix(qpQuat, mpMatrix) + +#define RpAnimQuatConvertToMatrix(qpQuat,mpMatrix) \ + RtQuatUnitConvertToMatrix(qpQuat,mpMatrix) + + +#endif /* RTQUAT_H */ + diff --git a/rwsdk/include/d3d8/rtquat.rpe b/rwsdk/include/d3d8/rtquat.rpe new file mode 100644 index 00000000..e43bb50c --- /dev/null +++ b/rwsdk/include/d3d8/rtquat.rpe @@ -0,0 +1,645 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionQuat +{ + + + + e_rwdb_CriterionQuatLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionQuat e_rwdb_CriterionQuat; + + diff --git a/rwsdk/include/d3d8/rtras.h b/rwsdk/include/d3d8/rtras.h new file mode 100644 index 00000000..0a9064a8 --- /dev/null +++ b/rwsdk/include/d3d8/rtras.h @@ -0,0 +1,54 @@ +/*************************************************************************** + * * + * Module : rtRAS.h * + * * + * Purpose : Load RAS format files * + * * + **************************************************************************/ + +#ifndef RTRAS_H +#define RTRAS_H + +/** + * \defgroup rtras RtRAS + * \ingroup rttool + * + * RAS/Sun Raster Fule Format Image Format Toolkit for RenderWare. + * + * See also http://www.sworks.com/hollasch/cgindex/formats/sunraster.html + * + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtras.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtRASImageWrite(RwImage * image, + const RwChar * imageName); +extern RwImage *RtRASImageRead(const RwChar * imageName); + +extern void _rwImageGammaUnCorrectArrayOfRGBA(RwRGBA * rgbaOut, + RwRGBA * rgbaIn, + RwInt32 numEls); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTRAS_H */ diff --git a/rwsdk/include/d3d8/rtras.rpe b/rwsdk/include/d3d8/rtras.rpe new file mode 100644 index 00000000..3398c3cc --- /dev/null +++ b/rwsdk/include/d3d8/rtras.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRAS +{ + + + + e_rwdb_CriterionRASLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRAS e_rwdb_CriterionRAS; + + diff --git a/rwsdk/include/d3d8/rtray.h b/rwsdk/include/d3d8/rtray.h new file mode 100644 index 00000000..4bf0a343 --- /dev/null +++ b/rwsdk/include/d3d8/rtray.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * * + * Module : rtray.h * + * * + * Purpose : Picking with rays * + * * + **************************************************************************/ + +#ifndef RTRAY_H +#define RTRAY_H + +/** + * \defgroup rtray RtRay + * \ingroup rttool + * + * Line Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rtray.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + + + /**************************************************************************** + Global Types + */ + + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Line intersections */ +extern RwReal RtLineTriangleIntersectionTest(RwLine *line, RwV3d *normal, + RwV3d *v0, RwV3d *v1, RwV3d *v2); +extern RwReal RtLineSphereIntersectionTest(RwLine *line, RwSphere *sphere); + +/* Line clipping */ +extern RwLine *RtLineClipPlane(RwLine *line, RwPlane *plane); +extern RwLine *RtLineClipBBox(RwLine *line, RwBBox *box); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RTRAY_H */ diff --git a/rwsdk/include/d3d8/rtray.rpe b/rwsdk/include/d3d8/rtray.rpe new file mode 100644 index 00000000..27788d94 --- /dev/null +++ b/rwsdk/include/d3d8/rtray.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionRay +{ + + + + e_rwdb_CriterionRayLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionRay e_rwdb_CriterionRay; + + diff --git a/rwsdk/include/d3d8/rtslerp.h b/rwsdk/include/d3d8/rtslerp.h new file mode 100644 index 00000000..ec41752c --- /dev/null +++ b/rwsdk/include/d3d8/rtslerp.h @@ -0,0 +1,262 @@ +/* + * Data Structures for Slerps/Spherical Linear Interpolations + * See also GemsIII/quatspin.c in + * http://www.acm.org/pubs/tog/GraphicsGems/gemsiii.zip + * Copyright (c) Criterion Software Limited + */ + +/*************************************************************************** + * * + * Module : rtslerp.h * + * * + * Purpose : Slerp functionality * + * * + **************************************************************************/ + +#ifndef RTSLERP_H +#define RTSLERP_H + +/** + * \defgroup rtslerp RtSlerp + * \ingroup rttool + * + * Slerp/Spherical Linear Interpolations Toolkit for RenderWare. + * + * See also http://www.cis.ohio-state.edu/~parent/book/Full.html + */ + +#include "rwcore.h" +#include "rtquat.h" + +/**************************************************************************** + Includes + */ + +#include "rtslerp.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/* Masks for specifying which matrices to store by reference */ +#define rtSLERPREFNONE 0x00 +#define rtSLERPREFSTARTMAT 0x01 +#define rtSLERPREFENDMAT 0x02 +#define rtSLERPREFALL (~rtSLERPREFNONE) + +/**************************************************************************** + Global Types + */ + + +typedef struct RtSlerp RtSlerp; +/** + * \ingroup rtslerp + * \struct RtSlerp + * structure describing a Slerps/Spherical Linear Interpolations. + * See also GemsIII/quatspin.c in + * http://www.acm.org/pubs/tog/GraphicsGems/gemsiii.zip + */ +struct RtSlerp +{ + RwInt32 matRefMask; /**< Which matrices do we NOT own */ + RwMatrix *startMat; /**< The start matrix */ + RwMatrix *endMat; /**< The end matrix */ + RwV3d axis; /**< The axis of rotation for the slerp */ + RwReal angle; /**< The angle (in degrees) between src & dest */ + + /* Though a slerp may be a bad idea and opting for a lerp is better */ + RwBool useLerp; /**< Do we want to use lerps? */ +}; + +/* static frame sequence animation - contains no state */ + + +typedef struct RtQuatSlerpCache RtQuatSlerpCache; +/** + * \ingroup rtslerp + * \struct RtQuatSlerpCache + * structure describing a SlerpCache, + * which should be initialized with \ref RtQuatSetupSlerpCache. + */ +struct RtQuatSlerpCache +{ + RtQuat raFrom; /**< Scaled initial quaternion */ + RtQuat raTo; /**< Scaled final quaternion */ + RwReal omega; /**< Angular displacement in radians */ + RwBool nearlyZeroOm; /**< Flags near-zero angular + displacement*/ +}; + + +typedef struct RtQuatSlerpArgandCache RtQuatSlerpArgandCache; +/** + * \ingroup rtslerp + * \struct RtQuatSlerpArgandCache + * a structure describing + * an Argand SlerpCache which should be + * initialized with \ref RtQuatSetupSlerpArgandCache. + * See http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Argand.html + * Jean Argand was an accountant and amateur mathematician. + * He is famed for his geometrical interpretation of the complex numbers + * where i is interpreted as a rotation through 90. + */ +struct RtQuatSlerpArgandCache +{ + RtQuat logTo; /**< field Logarithm of final quaternion */ + RtQuat logBase; /**< Logarithm of initial relative to final quaternion */ +}; + +#define RtQuatSlerpMacro(qpResult, qpFrom, qpTo, rT, sCache) \ +MACRO_START \ +{ \ + if ((rT) <= ((RwReal) 0)) \ + { \ + /* t is before start */ \ + *(qpResult) = *(qpFrom); \ + } \ + else if (((RwReal) 1) <= (rT)) \ + { \ + \ + /* t is after end */ \ + *(qpResult) = *(qpTo); \ + } \ + else \ + { \ + /* ... so t must be in the interior then */ \ + /* Calc coefficients rSclFrom, rSclTo */ \ + RwReal rSclFrom = ((RwReal) 1) - (rT); \ + RwReal rSclTo = (rT); \ + \ + if (!((sCache)->nearlyZeroOm)) \ + { \ + /* Standard case: slerp */ \ + /* SLERPMESSAGE(("Neither nearly ZERO nor nearly PI")); */ \ + \ + rSclFrom *= (sCache)->omega; \ + RwSinMinusPiToPiMacro(rSclFrom, rSclFrom); \ + rSclTo *= (sCache)->omega; \ + RwSinMinusPiToPiMacro(rSclTo, rSclTo); \ + } \ + \ + /* Calc final values */ \ + RwV3dScaleMacro(&(qpResult)->imag, \ + &(sCache)->raFrom.imag, rSclFrom); \ + RwV3dIncrementScaledMacro(&(qpResult)->imag, \ + &(sCache)->raTo.imag, rSclTo); \ + (qpResult)->real = \ + ((sCache)->raFrom.real * rSclFrom) + \ + ((sCache)->raTo.real * rSclTo); \ + } \ +} \ +MACRO_STOP + +#define RtQuatSlerpArgandMacro(qpResult, qpFrom, qpTo, rT, sArgandCache) \ +MACRO_START \ +{ \ + if ((rT) <= ((RwReal) 0)) \ + { \ + /* t is before start */ \ + *(qpResult) = *(qpFrom); \ + } \ + else if (((RwReal) 1) <= (rT)) \ + { \ + /* t is after end */ \ + *(qpResult) = *(qpTo); \ + } \ + else \ + { \ + RtQuat logBlend; \ + \ + /* ... so t must be in the interior then */ \ + \ + logBlend.imag.x = \ + (sArgandCache)->logBase.imag.x + \ + (rT) * (sArgandCache)->logTo.imag.x; \ + logBlend.imag.y = \ + (sArgandCache)->logBase.imag.y + \ + (rT) * (sArgandCache)->logTo.imag.y; \ + logBlend.imag.z = \ + (sArgandCache)->logBase.imag.z + \ + (rT) * (sArgandCache)->logTo.imag.z; \ + logBlend.real = 0; \ + \ + RtQuatUnitExpMacro((qpResult), &logBlend); \ + \ + } \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RtQuatSlerp(qpResult, qpFrom, qpTo, rT, sCache) \ + RtQuatSlerpMacro(qpResult, qpFrom, qpTo, rT, sCache) + +#define RtQuatSlerpArgand(qpResult, qpFrom, qpTo, rT, sArgandCache) \ + RtQuatSlerpArgandMacro(qpResult, qpFrom, qpTo, rT, sArgandCache) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Creating and destroying slerps */ + +extern RtSlerp *RtSlerpCreate(RwInt32 nMatRefMask); + +extern void RtSlerpDestroy(RtSlerp * spSlerp); + +/* setting up a slerp */ +extern RtSlerp *RtSlerpInitialize(RtSlerp * spSlerp, + RwMatrix * mpMat1, + RwMatrix * mpMat2); + +/* Get a matrix */ +extern RwMatrix *RtSlerpGetMatrix(RtSlerp * spSlerp, + RwMatrix * mpResultMat, + RwReal nDelta); + +/* Set if lerp or slerp */ +extern RtSlerp *RtSlerpSetLerp(RtSlerp * spSlerp, + RwBool bUseLerp); + +extern void +RtQuatSetupSlerpCache(RtQuat * qpFrom, + RtQuat * qpTo, + RtQuatSlerpCache * sCache); + +extern void +RtQuatSetupSlerpArgandCache(RtQuat * qpFrom, + RtQuat * qpTo, + RtQuatSlerpArgandCache * sArgandCache); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void +RtQuatSlerp(RtQuat * qpResult, + RtQuat * qpFrom, + RtQuat * qpTo, + RwReal rT, + RtQuatSlerpCache * sCache); + +extern void +RtQuatSlerpArgand(RtQuat * qpResult, + RtQuat * qpFrom, + RtQuat * qpTo, + RwReal rT, + RtQuatSlerpArgandCache * sArgandCache); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTSLERP_H */ + diff --git a/rwsdk/include/d3d8/rtslerp.rpe b/rwsdk/include/d3d8/rtslerp.rpe new file mode 100644 index 00000000..847ccb00 --- /dev/null +++ b/rwsdk/include/d3d8/rtslerp.rpe @@ -0,0 +1,646 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionSlerp +{ + + + + e_rwdb_CriterionSlerpLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionSlerp e_rwdb_CriterionSlerp; + + diff --git a/rwsdk/include/d3d8/rtsplpvs.h b/rwsdk/include/d3d8/rtsplpvs.h new file mode 100644 index 00000000..38ae118f --- /dev/null +++ b/rwsdk/include/d3d8/rtsplpvs.h @@ -0,0 +1,65 @@ + +/*************************************************************************** + * * + * Module : rtsplpvs.h * + * * + * Purpose : To generate pvs data for a world froma spline * + * * + **************************************************************************/ + +#ifndef RTSPLINEPVS_H +#define RTSPLINEPVS_H + +/** + * \defgroup rtsplinepvs RtSplinePVS + * \ingroup rttool + * + * Spline PVS Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rwcore.h" +#include "rpworld.h" +#include "rpspline.h" + +/* RWPUBLIC */ + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +/**************************************************************************** + Function prototypes + */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RpWorld * +RtSplinePVSConstruct(RpWorld * world, + RpSpline *spline, RwInt32 samples); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +/* for back compatibility */ +#define RtSplinePVSCreate(_world, _raster, _zraster, \ + _mindist, _maxdist, _spline, _samples) \ + RtSplinePVSConstruct(_world, \ + _spline, _samples) + + +#endif /* RTSPLINEPVS_H */ diff --git a/rwsdk/include/d3d8/rtsplpvs.rpe b/rwsdk/include/d3d8/rtsplpvs.rpe new file mode 100644 index 00000000..d436b610 --- /dev/null +++ b/rwsdk/include/d3d8/rtsplpvs.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionSplinePVS +{ + + + + e_rwdb_CriterionSplinePVSLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionSplinePVS e_rwdb_CriterionSplinePVS; + + diff --git a/rwsdk/include/d3d8/rttiff.h b/rwsdk/include/d3d8/rttiff.h new file mode 100644 index 00000000..9dbf22c8 --- /dev/null +++ b/rwsdk/include/d3d8/rttiff.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * * + * Module : rttiff.h * + * * + * Purpose : Load TIFF format files * + * * + **************************************************************************/ + +#ifndef RWTIFF_H +#define RWTIFF_H + +/** + * \defgroup rttiff RtTIFF + * \ingroup rttool + * + * TIFF/Tag Image File Format Image Format Toolkit for RenderWare. + * + * See also http://www.libtiff.org + */ + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rttiff.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwImage *RtTIFFImageRead(const RwChar *imageName); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RWTIFF_H */ diff --git a/rwsdk/include/d3d8/rttiff.rpe b/rwsdk/include/d3d8/rttiff.rpe new file mode 100644 index 00000000..f82c7d82 --- /dev/null +++ b/rwsdk/include/d3d8/rttiff.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTIFF +{ + + + + e_rwdb_CriterionTIFFLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTIFF e_rwdb_CriterionTIFF; + + diff --git a/rwsdk/include/d3d8/rttilerd.h b/rwsdk/include/d3d8/rttilerd.h new file mode 100644 index 00000000..f11b703b --- /dev/null +++ b/rwsdk/include/d3d8/rttilerd.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * * + * Module : rttilerd.h * + * * + * Purpose : Tile renderer * + * * + **************************************************************************/ + +#ifndef RTTILERD_H +#define RTTILERD_H + +/** + * \defgroup rttilerender RtTileRender + * \ingroup rttool + * + * Tile renderer - e.g. grabbing screen shots - Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ +#include "rwcore.h" + +#include "rpcriter.h" + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +typedef RwCamera * (*RtTileRenderCallBack)(RwCamera *camera, + RwInt32 x, RwInt32 y, + void *pData); + +typedef RwImage * (*RtTileArchiveCallBack)(RwImage *image, + RwInt32 x, RwInt32 y, + void *pData); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Tile renderer */ + +extern RwCamera * +RtTileRender(RwCamera *camera, + RwInt32 imageWidth, RwInt32 imageHeight, + RwInt32 tileWidth, RwInt32 tileHeight, + RtTileRenderCallBack renderCallBack, + RtTileArchiveCallBack archiveCallBack, + void *pData); + +extern RwImage * +RtTileDefaultArchive(RwImage *image, + RwInt32 x, RwInt32 y, void *pData); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTTILERD_H */ diff --git a/rwsdk/include/d3d8/rttilerd.rpe b/rwsdk/include/d3d8/rttilerd.rpe new file mode 100644 index 00000000..78222d06 --- /dev/null +++ b/rwsdk/include/d3d8/rttilerd.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTileRend +{ + + + + e_rwdb_CriterionTileRendLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTileRend e_rwdb_CriterionTileRend; + + diff --git a/rwsdk/include/d3d8/rttoc.h b/rwsdk/include/d3d8/rttoc.h new file mode 100644 index 00000000..02893aa8 --- /dev/null +++ b/rwsdk/include/d3d8/rttoc.h @@ -0,0 +1,99 @@ +/*************************************************************************** + * * + * Module : rttoc.h * + * * + * Purpose : Table Of Contents (TOC) * + * * + **************************************************************************/ + +#ifndef RTTOC_H +#define RTTOC_H + +/** + * \defgroup rttoc RtTOC + * \ingroup rttool + * + * Table Of Contents (TOC) - e.g. creating a TOC for a RwStream. + */ + +/**************************************************************************** + Includes + */ +#include "rwcore.h" + +#include "rpcriter.h" + +/**************************************************************************** + Defines + */ + +/**************************************************************************** + Global Types + */ + +typedef struct _rtTOCGUID _rtTOCGUID; +struct _rtTOCGUID +{ + RwUInt32 data1; + RwUInt16 data2; + RwUInt16 data3; + RwUInt8 data4[8]; +}; + +typedef struct RtTOCEntry RtTOCEntry; +/** + * \ingroup rttoc + * \struct RtTOCEntry + * + * BLAH + */ +struct RtTOCEntry +{ + RwCorePluginID id; /**< Chunk ID */ + RwUInt32 offset;/**< Offset of chunk from the start of the file + * including TOC */ + _rtTOCGUID guid; /**< GUID */ +}; + +typedef struct RtTOC RtTOC; + +/** + * \ingroup rttoc + * \struct RtTOC + * + * BLAH + */ +struct RtTOC +{ + RwInt32 numEntries; /**< Number of entries*/ + RtTOCEntry entry[1]; /**< Entry*/ +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Create/Destroy */ +extern RtTOC *RtTOCCreate(RwStream *stream); +extern void RtTOCDestroy(RtTOC *toc); + +/* Access */ +extern RwInt32 RtTOCGetNumEntries(const RtTOC *toc); +extern RtTOCEntry *RtTOCGetEntry(RtTOC *toc, RwInt32 entry); + +/* Serialization */ +extern RwUInt32 RtTOCStreamGetSize(const RtTOC *toc); +extern const RtTOC *RtTOCStreamWrite(RtTOC *toc, RwStream *stream); +extern RtTOC *RtTOCStreamRead(RwStream *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTTOC_H */ diff --git a/rwsdk/include/d3d8/rttoc.rpe b/rwsdk/include/d3d8/rttoc.rpe new file mode 100644 index 00000000..796f8de5 --- /dev/null +++ b/rwsdk/include/d3d8/rttoc.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTOC +{ + + + + e_rwdb_CriterionTOCLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTOC e_rwdb_CriterionTOC; + + diff --git a/rwsdk/include/d3d8/rtvcat.h b/rwsdk/include/d3d8/rtvcat.h new file mode 100644 index 00000000..474095e1 --- /dev/null +++ b/rwsdk/include/d3d8/rtvcat.h @@ -0,0 +1,38 @@ + +/*************************************************************************** + * * + * Module : rtvcat.h * + * * + * Purpose : Tristripping callback for vertex cache aware strips * + * * + **************************************************************************/ + +#ifndef RTVCAT_H +#define RTVCAT_H + +/**************************************************************************** + Includes + */ + +/*--- Include files ---*/ +#include "rwcore.h" + +#include "rtvcat.rpe" /* automatically generated header file */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern RpMeshHeader * +RpBuildMeshGenerateCacheAwareTriStrip(RpBuildMesh *buildMesh, + void *data); + +#ifdef __cplusplus +} +#endif + +#endif /* RTVCAT_H */ diff --git a/rwsdk/include/d3d8/rtvcat.rpe b/rwsdk/include/d3d8/rtvcat.rpe new file mode 100644 index 00000000..464ca886 --- /dev/null +++ b/rwsdk/include/d3d8/rtvcat.rpe @@ -0,0 +1,629 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionVextexCacheStrip +{ + + + + e_rwdb_CriterionVextexCacheStripLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionVextexCacheStrip e_rwdb_CriterionVextexCacheStrip; + + diff --git a/rwsdk/include/d3d8/rtworld.h b/rwsdk/include/d3d8/rtworld.h new file mode 100644 index 00000000..fef3e17c --- /dev/null +++ b/rwsdk/include/d3d8/rtworld.h @@ -0,0 +1,85 @@ +/* + * World toolkit. + */ +/*************************************************************************** + * * + * Module : rtworld.h * + * * + * Purpose : World tool helper functions header * + * * + **************************************************************************/ + +#ifndef RTWORLD_H +#define RTWORLD_H + +/** + * \defgroup rtworld RtWorld + * \ingroup rttool + * + * World Import Toolkit for RenderWare. + */ + +/**************************************************************************** + Includes + */ + +#include "rpworld.h" + +#include "rtworld.rpe" /* automatically generated header file */ + +/**************************************************************************** + Defines + */ + +/* RWPUBLIC */ +/**************************************************************************** + Global Types + */ + +/* RWPUBLICEND */ + +/**************************************************************************** + Exported globals + */ + +/* RWPUBLIC */ +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Get the number of various things in the world */ +extern RwInt32 RtWorldGetNumWorldSectors(RpWorld *world); +extern RwInt32 RtWorldGetNumVertices(RpWorld *world); +extern RwInt32 RtWorldGetNumPolygons(RpWorld *world); + +/* Find things out about materials in the world */ +extern RwInt32 RtWorldFindMaterialNum(RpWorld *world, RpMaterial *material); +extern RpMaterial *RtWorldFindMaterialWithTextureName(RpWorld *world, RwChar *name); + +/* Optimisation functions in optimise.c */ +extern RpClump *RtClumpOptimize(RpClump *clump, RwReal dist); +extern RpAtomic *RtAtomicOptimize(RpAtomic *atomic, RwReal dist); + +/* + * This function has been removed, however it still exists as a stealth + * function, _rtGeometryOptimize. + */ +#define RtGeometryOptimize(geometry, dist) (geometry) + +extern RpGeometry *_rtGeometryOptimize(RpGeometry *geometry, RwReal dist); + +/* Import utility functions from imputil.c */ +extern RpGeometry *RtGeometryCalculateVertexNormals(RpGeometry *geometry); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* RWPUBLICEND */ + +#endif /* RWTLWRLD_H */ diff --git a/rwsdk/include/d3d8/rtworld.rpe b/rwsdk/include/d3d8/rtworld.rpe new file mode 100644 index 00000000..bc20947e --- /dev/null +++ b/rwsdk/include/d3d8/rtworld.rpe @@ -0,0 +1,628 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +enum e_rwdb_CriterionTlWorld +{ + + + + e_rwdb_CriterionTlWorldLAST = RWFORCEENUMSIZEINT +}; + +typedef enum e_rwdb_CriterionTlWorld e_rwdb_CriterionTlWorld; + + diff --git a/rwsdk/include/d3d8/rwcore.h b/rwsdk/include/d3d8/rwcore.h new file mode 100644 index 00000000..b9214c63 --- /dev/null +++ b/rwsdk/include/d3d8/rwcore.h @@ -0,0 +1,4791 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Wed Jul 10 10:45:00 2002 + * + ************************************************************************/ + +#ifndef RWCORE_H +#define RWCORE_H + +/*--- System Header Files ---*/ +#include + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/barwasmm.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2resort.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2macros.h ---*/ + +#define RxClusterDecCursorByStride(_cluster, _stride) \ + ((_cluster)->currentData = \ + (void *)(((RwUInt8 *)(_cluster)->currentData) - \ + (_stride))) + +#define RxClusterDecCursor(_cluster) \ + RxClusterDecCursorByStride(_cluster, (_cluster)->stride) + +#define RxClusterIncCursorByStride(_cluster, _stride) \ + ((_cluster)->currentData = \ + (void *)(((RwUInt8 *)(_cluster)->currentData) + \ + (_stride))) + +#define RxClusterIncCursor(_cluster) \ + RxClusterIncCursorByStride(_cluster, (_cluster)->stride) + +#define RxClusterResetCursor(_cluster) \ + ((_cluster)->currentData = (_cluster)->data) + +#define RxClusterGetCursorData(_cluster, _type) \ + ((_type *)(_cluster)->currentData) + +#define RxClusterGetIndexedData(_cluster, _type, _index) \ + ((_type *)(((RwUInt8 *)(_cluster)->data) + (_cluster)->stride*(_index))) + +#define RxClusterGetFreeIndex(_cluster) ( (_cluster)->numUsed++ ) + +#define RxPipelineClusterAssertAttributeSet(_cluster, _attributeSet) \ + RWASSERT( (_cluster)->clusterRef->attributeSet != NULL && \ + rwstrcmp((_cluster)->clusterRef->attributeSet, \ + (_attributeSet)) == 0 ) + +#define RxPipelineNodeParamGetData(_param) \ + ( (_param)->dataParam ) + +#define RxPipelineNodeParamGetHeap(_param) \ + ( (_param)->heap ) + + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2heap.h ---*/ + +#if (defined(RWDEBUG) && (defined(RWMEMDEBUG))) + +#if (!defined(DISABLERWHEAP)) +#define DISABLERWHEAP +#endif /* (!defined(DISABLERWHEAP)) */ + +#endif /* (defined(RWDEBUG) && (defined(RWMEMDEBUG))) */ + +typedef struct rxHeapFreeBlock rxHeapFreeBlock; +typedef struct rxHeapSuperBlockDescriptor rxHeapSuperBlockDescriptor; +typedef struct RxHeap RxHeap; +typedef struct rxHeapBlockHeader rxHeapBlockHeader; + +struct rxHeapFreeBlock +{ + RwUInt32 size; + rxHeapBlockHeader *ptr; +}; + +struct rxHeapSuperBlockDescriptor +{ + void *start; + RwUInt32 size; + rxHeapSuperBlockDescriptor *next; +}; + +/** + * \ingroup rwcoregeneric + * \struct RxHeap + * structure describing a pipeline execution heap + */ +struct RxHeap +{ + RwUInt32 superBlockSize; /**< Granularity of heap growth */ + rxHeapSuperBlockDescriptor *head; /**< Internally used superblock pointer */ + rxHeapBlockHeader *headBlock; /**< Internally used block pointer */ + rxHeapFreeBlock *freeBlocks; /**< Internally used free blocks pointer */ + RwUInt32 entriesAlloced; /**< Number of entries allocated */ + RwUInt32 entriesUsed; /**< Number of entries used */ + RwBool dirty; /**< Internally used boolean, flags whether + * the heap needs resetting or not. */ +}; + +struct rxHeapBlockHeader +{ + /* present in all blocks (used & unused) */ + rxHeapBlockHeader *prev, *next; + RwUInt32 size; + rxHeapFreeBlock *freeEntry; /* (or null) */ + RwUInt32 pad[4]; /* alignment padding to 32 bytes */ +}; + +/* This wrapper cheaply early-outs when a heap doesn't *need* resetting */ +#define RxHeapReset(heap) \ + ((FALSE == (heap)->dirty) ? (TRUE) : (_rxHeapReset(heap))) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxHeap *RxHeapCreate(RwUInt32 size); +extern void RxHeapDestroy(RxHeap * heap); +extern RwBool _rxHeapReset(RxHeap * heap); +extern void *RxHeapAlloc(RxHeap * heap, RwUInt32 size); +extern void RxHeapFree(RxHeap * heap, void *block); +extern void *RxHeapRealloc(RxHeap * heap, void *block, + RwUInt32 newSize, RwBool allowCopy); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if (defined(DISABLERWHEAP)) + +typedef struct rxHeapMallocTrace rxHeapMallocTrace; +struct rxHeapMallocTrace +{ + rxHeapMallocTrace *next; + rxHeapBlockHeader *block; +}; + +#endif /* (defined(DISABLERWHEAP)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2dep.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2core.h ---*/ + +extern RwInt32 _rxPipelineMaxNodes; +extern RwInt32 _rxHeapInitialSize; +/* LEGACY-SUPPORT MACRO */ +#define _rwRxHeapInitialSize _rxHeapInitialSize + +/* Beneficial padding of PowerPipe types is still being worked out... */ +#define PADCLUSTERSx + + +/************************************************************* + * Global Defines + */ + +#define RWBOOLTOGGLE(bVar) ((bVar == FALSE)?(bVar = TRUE):(bVar = FALSE)) + +/* Both these currently limited due to the use of RwUInt32 bit-fields */ +#define RXNODEMAXCLUSTERSOFINTEREST 32 +#define RXNODEMAXOUTPUTS 32 + +/* Useful (for memory alloc) to limit this during pipeline construction */ +#define RXPIPELINEDEFAULTMAXNODES 64 + +/* + * Cluster flags + */ + +#define rxCLFLAGS_NULL ((RwUInt16) 0x0000U) +#define rxCLFLAGS_CLUSTERVALID ((RwUInt16) 0x0001U) +#define rxCLFLAGS_EXTERNAL ((RwUInt16) 0x0002U) +#define rxCLFLAGS_EXTERNALMODIFIABLE ((RwUInt16) 0x0004U | 0x0002U) +#define rxCLFLAGS_MODIFIED ((RwUInt16) 0x0008U) + +/* + * Packet flags + */ + +#define rxPKFLAGS_NULL ((RwUInt16) 0x0000U) + +/* + * used in input specification + */ + +/** + * \ingroup rwcoregeneric + * \ref RxClusterValidityReq + * Flags specifying the state requirements for + * a \ref RxCluster on entry to a node */ +enum RxClusterValidityReq +{ + rxCLREQ_DONTWANT = 0, /**inputToClusterSlot[(CLIND)]) + +#define RxClusterLockRead(PKT, CLIND) \ + ( (((RwInt32)RXCLSLOT(PKT, CLIND)) == -1) ? \ + ((RxCluster *)NULL) : \ + (RxClusterResetCursor(&PKT->clusters[RXCLSLOT(PKT, CLIND)]), \ + &PKT->clusters[RXCLSLOT(PKT, CLIND)]) ) + +#endif /* !RWDEBUG */ + +extern RxCluster * +RxClusterLockWrite(RxPacket * packet, + RwUInt32 clusterIndex, + RxPipelineNode * node); + +extern void +RxClusterUnlock(RxCluster * cluster); + +extern RwUInt32 +RxPipelineNodeSendConfigMsg(RxPipelineNode * dest, + RwUInt32 msg, + RwUInt32 intparam, + void *ptrparam); + +extern RxPipelineNode * +RxPipelineNodeForAllConnectedOutputs(RxPipelineNode * node, + RxPipeline * pipeline, + RxPipelineNodeOutputCallBack callbackfn, + void *callbackdata); + +/* Cluster attributes api [pipeline construction time] */ + +extern RxPipelineCluster * +RxPipelineNodeGetPipelineCluster(RxPipelineNode *node, + RwUInt32 clustersOfInterestIndex); + +extern RwUInt32 +RxPipelineClusterGetCreationAttributes(RxPipelineCluster *cluster); + +extern RxPipelineCluster * +RxPipelineClusterSetCreationAttributes(RxPipelineCluster *cluster, + RwUInt32 creationAttributes); + +/* Cluster attributes api [pipeline execution time] */ + +extern RwUInt32 +RxClusterGetAttributes(RxCluster *cluster); + +extern RxCluster * +RxClusterSetAttributes(RxCluster *cluster, RwUInt32 attributes); + + +extern void +_rxEmbeddedPacketBetweenPipelines(RxPipeline * fromPipeline, + RxPipeline * toPipeline); + +extern RxPipelineNode * +_rxEmbeddedPacketBetweenNodes(RxPipeline *pipeline, + RxPipelineNode *nodeFrom, + RwUInt32 whichOutput); + +extern RxExecutionContext _rxExecCtxGlobal; + +/* Summary of dispatch rules: + * o nodes that never fetch are safe to dispatch NULL, whether + * nodes above pass them a packet or not + * o if you destroy the packet you can dispatch(NULL,,) + * o if you fetch/create and dispatch(NULL), it doesn't really + * matter - the packet'll get passed on anyway */ + +/* TODO: there's currently no way to prematurely terminate the pipeline + * without doing so as an error condition. You should create an + * enum for the exit code, either RXNODEEXITCONTINUE, RXNODEEXITTERMINATE + * or RXNODEEXTTERMINATEERROR and then test for RXNODEEXITCONTINUE in + * the below macros rather than FALSE. */ + +/* TODO: _packet redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchMacro(_packet, _output, _self) \ +MACRO_START \ +{ \ + RxPipeline *curPipeline = _rxExecCtxGlobal.pipeline; \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RxPipelineNode *nextNode = \ + _rxEmbeddedPacketBetweenNodes(curPipeline, \ + _self, \ + (_output)); \ + if ( nextNode != NULL ) \ + { \ + RwUInt32 exitCode = \ + nextNode->nodeDef->nodeMethods.nodeBody( \ + nextNode, &(_rxExecCtxGlobal.params)); \ + /* Don't overwrite 'error' with 'success' */ \ + if (FALSE == exitCode) _rxExecCtxGlobal.exitCode = exitCode; \ + } \ + } \ + if ( curPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + curPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(curPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +/* TODO: _self redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchToPipelineMacro(_packet, _pipeline, _self) \ +MACRO_START \ +{ \ + RxPipeline *toPipeline = (_pipeline); \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RwUInt32 exitCode; \ + RxPipeline *fromPipeline = _rxExecCtxGlobal.pipeline; /* save */ \ + _rxEmbeddedPacketBetweenPipelines(fromPipeline, \ + toPipeline); \ + _rxExecCtxGlobal.pipeline = toPipeline; /* modify */ \ + exitCode = \ + toPipeline->nodes[0].nodeDef->nodeMethods.nodeBody( \ + &toPipeline->nodes[0], &(_rxExecCtxGlobal.params)); \ + if ( FALSE == exitCode ) _rxExecCtxGlobal.exitCode = exitCode; \ + _rxExecCtxGlobal.pipeline = fromPipeline; /* restore */ \ + } \ + if ( toPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + toPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(toPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +#define rxPacketFetchMacro(_node) \ + ( ((_rxExecCtxGlobal.pipeline)->embeddedPacketState == rxPKST_PENDING) ?\ + ((_rxExecCtxGlobal.pipeline)->embeddedPacketState = rxPKST_INUSE, \ + (_rxExecCtxGlobal.pipeline)->embeddedPacket) : \ + (NULL) ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/d3d8/nodeD3D8SubmitNoLight.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2define.h ---*/ + +/** + * \ingroup rwcoregeneric + * \typedef RxNodeOutput + * typedef for a reference to an output of a pipeline node */ +typedef RwUInt32 *RxNodeOutput; + +/** + * \ingroup rwcoregeneric + * \typedef RxNodeInput + * typedef for a reference to the input of a pipeline node */ +typedef RxPipelineNode *RxNodeInput; + +/** + * \ingroup rwcoregeneric + * \typedef RxLockedPipe + * typedef for a reference to a locked pipeline + */ +typedef RxPipeline RxLockedPipe; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +/* PIPELINENODE API */ + +extern RxNodeOutput +RxPipelineNodeFindOutputByName(RxPipelineNode *node, + const RwChar *outputname); + +extern RxNodeOutput +RxPipelineNodeFindOutputByIndex(RxPipelineNode *node, + RwUInt32 outputindex); + +extern RxNodeInput +RxPipelineNodeFindInput(RxPipelineNode *node); + +extern RxNodeDefinition * +RxPipelineNodeCloneDefinition(RxPipelineNode *node, + RxClusterDefinition *cluster2add); + +extern RxPipeline * +RxPipelineNodeRequestCluster(RxPipeline *pipeline, + RxPipelineNode *node, + RxClusterDefinition *clusterDef); + +extern RxPipeline * +RxPipelineNodeReplaceCluster(RxPipeline *pipeline, + RxPipelineNode *node, + RxClusterDefinition *oldClusterDef, + RxClusterDefinition *newClusterDef); + +extern void * +RxPipelineNodeGetInitData(RxPipelineNode *node); + +extern void * +RxPipelineNodeCreateInitData(RxPipelineNode *node, + RwUInt32 size); + +/* PIPELINE MANIPULATION API */ + +extern RxPipeline * +RxPipelineClone(RxPipeline *pipeline); + +extern RxPipelineNode * +RxPipelineFindNodeByName(RxPipeline *pipeline, + const RwChar *name, + RxPipelineNode *start, + RwInt32 *nodeIndex); + +extern RxPipelineNode * +RxPipelineFindNodeByIndex(RxPipeline *pipeline, + RwUInt32 nodeindex); + +extern RxLockedPipe * +RxPipelineLock(RxPipeline *pipeline); + +extern RxPipeline * +RxLockedPipeUnlock(RxLockedPipe *pipeline); + + +extern RxLockedPipe * +RxLockedPipeAddFragment(RxLockedPipe *pipeline, + RwUInt32 *firstIndex, + RxNodeDefinition *nodeDef0, + ...); + + +extern RxPipeline * +RxLockedPipeReplaceNode(RxLockedPipe *pipeline, + RxPipelineNode *node, + RxNodeDefinition *nodeDef); + +extern RxPipeline * +RxLockedPipeDeleteNode(RxLockedPipe *pipeline, + RxPipelineNode *node); + + +extern RxPipeline * +RxLockedPipeSetEntryPoint(RxLockedPipe *pipeline, + RxNodeInput in); + + +extern RxPipelineNode * +RxLockedPipeGetEntryPoint(RxLockedPipe *pipeline); + + +extern RxPipeline * +RxLockedPipeAddPath(RxLockedPipe *pipeline, + RxNodeOutput out, + RxNodeInput in); + +extern RxPipeline * +RxLockedPipeDeletePath(RxLockedPipe *pipeline, + RxNodeOutput out, + RxNodeInput in); + + +extern RxPipeline * +RxPipelineInsertDebugNode(RxPipeline *pipeline, + RxPipelineNode *before, + RxPipelineNode *after, + RxNodeDefinition *debugNode); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2altmdl.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeTransform.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetTransform(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeSubmitTriangle.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetSubmitTriangle(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeSubmitLine.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetSubmitLine(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeScatter.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetScatter(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeClone.h ---*/ + +typedef struct RxPacketCacheCluster RxPacketCacheCluster; + +/** + * \ingroup rwcoregeneric + * \struct RxPacketCacheCluster + * structure containing a cache of an \ref RxCluster's + * within an \ref RxPacketCache + */ +struct RxPacketCacheCluster +{ + RwUInt32 slot; /**< A \ref RwUInt32 index into the \ref RxPacketCache's + * array of RxPacketCacheCluster's */ + RwUInt16 flags; /**< A cache of the original cluster's flags */ + RwUInt16 stride; /**< A cache of the original cluster's stride */ + void *data; /**< A cache of the original cluster's data */ + RwUInt32 numAlloced; /**< A cache of the original cluster's numAlloced */ + RwUInt32 numUsed; /**< A cache of the original cluster's numUsed */ + RxPipelineCluster *clusterRef; /**< A cache of the original cluster's \ref RxPipelineCluster */ +}; +typedef struct RxPacketCache RxPacketCache; + +/** + * \ingroup rwcoregeneric + * \struct RxPacketCache + * structure containing a cache of a \ref RxPacket */ +struct RxPacketCache +{ + RwUInt16 packetFlags; /**< A cache of the original packet's flags */ + RwUInt16 pad[1]; /**< Alignment padding */ + RwUInt32 numClusters; /**< The number of present clusters in the + * original packet when it was cloned */ + RwBool lastCloneDone;/**< Once the cache has been cloned by \ref RxPacketCacheClone + * with (lastClone == TRUE), it should not be used again! */ + RwUInt32 pad2[1]; /**< Alignment padding */ + RxPacketCacheCluster clusters[1]; /**< An array of \ref RxPacketCacheCluster's, + * extending beyond 1 element */ +}; + + +typedef struct RxNodeCloneInitData RxNodeCloneInitData; +/** + * \ingroup rwcoregeneric + * \struct RxNodeCloneInitData + * structure with which to initialize + * clone a \ref RxNodeDefinition, + * through \ref RxNodeDefinitionCloneCreate and + * set up cloned \ref RxPipelineNode modes, through + * \ref RxPipelineNodeCloneDefineModes */ +struct RxNodeCloneInitData +{ + RwUInt32 numModes; /**< Specifies the number of modes in + which the node should operate */ + RwUInt32 numOutputs; /**< Specifies the number of outputs of this + Clone node, which is also the maximum + number of outputs to which any one mode + may dispatch packets */ + RwUInt32 *modeSizes; /**< Specifies the number of outputs to which + each mode dispatches packets */ + RwUInt32 **modes; /**< An array of numModes pointers to arrays + (of length numOutputs) specifying the + outputs, in order, to which each mode + should dispatch packets (output zero is + the first output) */ +}; + +/** + * \ingroup rwcoregeneric + * \struct RxNodeCloneData + * structure which is the private + * data of Clone nodes \ref RxPipelineNode */ +typedef struct RxNodeCloneData RxNodeCloneData; +struct RxNodeCloneData +{ + RwBool optimized; /**< \ref RwBool specifying whether \ref RxPipelineNodeCloneOptimize + * has been run on this \ref RxPipelineNode yet */ + RwUInt32 currentMode; /**< \ref RwUInt32 The current mode of operation */ + RxNodeCloneInitData *data;/**< A pointer to \ref RxNodeCloneInitData data + * specifying the modes of operation */ +}; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionCloneCreate(RxNodeCloneInitData *data); +extern RwBool RxPipelineNodeCloneDefineModes( + RxPipeline *pipeline, + RxPipelineNode *node, + RxNodeCloneInitData *data); +extern RwBool RxNodeDefinitionCloneDestroy(RxNodeDefinition *def); +extern RwBool RxPipelineNodeCloneOptimize(RxPipeline *pipeline, + RxPipelineNode *node); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeImmStash.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetImmStash(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeImmRenderSetup.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetImmRenderSetup(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeImmMangleTriangleIndices.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetImmMangleTriangleIndices(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeImmMangleLineIndices.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetImmMangleLineIndices(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeImmInstance.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetImmInstance(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeCullTriangle.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition * RxNodeDefinitionGetCullTriangle(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeClipTriangle.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetClipTriangle(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/nodeClipLine.h ---*/ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RxNodeDefinition *RxNodeDefinitionGetClipLine(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d8texdic.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d8rendst.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d8raster.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d8device.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d8convrt.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/d3d82drend.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/ssematml.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/cpuext.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/palquant.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/datblkcb.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/baraster.h ---*/ + +/**************************************************************************** + Defines + */ + +/** + * \ingroup datatypes + * \ref RwRasterLockMode represents the options available for locking + * a raster so that it may be modified (see API function \ref RwRasterLock). An + * application may wish to write to the raster, read from the raster or + * simultaneously write and read a raster (rwRASTERLOCKWRITE | rwRASTERLOCKREAD). + */ +enum RwRasterLockMode +{ + rwRASTERLOCKWRITE = 0x01, /** + *
  • The pixel color format corresponding to one of the following values:- + *
      + *
    • rwRASTERFORMAT1555 + *
    • rwRASTERFORMAT565 + *
    • rwRASTERFORMAT4444 + *
    • rwRASTERFORMATLUM8 + *
    • rwRASTERFORMAT8888 + *
    • rwRASTERFORMAT888 + *
    • rwRASTERFORMAT16 + *
    • rwRASTERFORMAT24 + *
    • rwRASTERFORMAT32 + *
    • rwRASTERFORMAT555 + *
    + * This value may be masked out of the raster format using + * rwRASTERFORMATPIXELFORMATMASK. + *
  • The palette depth if the raster is palettized:- + *
      + *
    • rwRASTERFORMATPAL4 + *
    • rwRASTERFORMATPAL8 + *
    + * In these cases, the color format refers to that of the palette. + *
  • Flag rwRASTERFORMATMIPMAP. Set if the raster contains mipmap levels. + *
  • Flag rwRASTERFORMATAUTOMIPMAP. Set if the mipmap levels were generated + * automatically by RenderWare. + * + */ +enum RwRasterFormat +{ + rwRASTERFORMATDEFAULT = 0x0000, /* Whatever the hardware likes best */ + + rwRASTERFORMAT1555 = 0x0100, /**<16 bits - 1 bit alpha, 5 bits red, green and blue */ + rwRASTERFORMAT565 = 0x0200, /**<16 bits - 5 bits red and blue, 6 bits green */ + rwRASTERFORMAT4444 = 0x0300, /**<16 bits - 4 bits per component */ + rwRASTERFORMATLUM8 = 0x0400, /**width) + +#define RwRasterGetHeightMacro(_raster) \ + ((_raster)->height) + +#define RwRasterGetStrideMacro(_raster) \ + ((_raster)->stride) + +#define RwRasterGetDepthMacro(_raster) \ + ((_raster)->depth) + +#define RwRasterGetFormatMacro(_raster) \ + ((((_raster)->cFormat) & (rwRASTERFORMATMASK >> 8)) << 8) + +#define RwRasterGetTypeMacro(_raster) \ + (((_raster)->cType) & rwRASTERTYPEMASK) + +#define RwRasterGetParentMacro(_raster) \ + ((_raster)->parent) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwRasterGetWidth(_raster) \ + RwRasterGetWidthMacro(_raster) + +#define RwRasterGetHeight(_raster) \ + RwRasterGetHeightMacro(_raster) + +#define RwRasterGetStride(_raster) \ + RwRasterGetStrideMacro(_raster) + +#define RwRasterGetDepth(_raster) \ + RwRasterGetDepthMacro(_raster) + +#define RwRasterGetFormat(_raster) \ + RwRasterGetFormatMacro(_raster) + +#define RwRasterGetType(_raster) \ + RwRasterGetTypeMacro(_raster) + +#define RwRasterGetParent(_raster) \ + RwRasterGetParentMacro(_raster) + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Creating destroying rasters */ +extern RwRaster *RwRasterCreate(RwInt32 width, RwInt32 height, + RwInt32 depth, RwInt32 flags); +extern RwBool RwRasterDestroy(RwRaster * raster); + +/* Pulling info out of raster structure */ + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwInt32 RwRasterGetWidth(const RwRaster *raster); +extern RwInt32 RwRasterGetHeight(const RwRaster *raster); +extern RwInt32 RwRasterGetStride(const RwRaster *raster); +extern RwInt32 RwRasterGetDepth(const RwRaster *raster); +extern RwInt32 RwRasterGetFormat(const RwRaster *raster); +extern RwInt32 RwRasterGetType(const RwRaster *raster); +extern RwRaster *RwRasterGetParent(const RwRaster *raster); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +extern RwRaster *RwRasterGetOffset(RwRaster *raster, + RwInt16 *xOffset, RwInt16 *yOffset); + +extern RwInt32 RwRasterGetNumLevels(RwRaster * raster); + +extern RwRaster *RwRasterSubRaster(RwRaster * subRaster, + RwRaster * raster, RwRect * rect); + +extern RwRaster *RwRasterRenderFast(RwRaster * raster, RwInt32 x, + RwInt32 y); +extern RwRaster *RwRasterRender(RwRaster * raster, RwInt32 x, + RwInt32 y); +extern RwRaster *RwRasterRenderScaled(RwRaster * raster, + RwRect * rect); + +/* Raster rendering context */ +extern RwRaster *RwRasterPushContext(RwRaster * raster); +extern RwRaster *RwRasterPopContext(void); +extern RwRaster *RwRasterGetCurrentContext(void); + +/* Clearing rasters */ +extern RwBool RwRasterClear(RwInt32 pixelValue); +extern RwBool RwRasterClearRect(RwRect * rpRect, + RwInt32 pixelValue); + +/* Displaying rasters */ +extern RwRaster *RwRasterShowRaster(RwRaster * raster, void *dev, + RwUInt32 flags); + +/* Locking and releasing */ +extern RwUInt8 *RwRasterLock(RwRaster * raster, RwUInt8 level, + RwInt32 lockMode); +extern RwRaster *RwRasterUnlock(RwRaster * raster); +extern RwUInt8 *RwRasterLockPalette(RwRaster * raster, + RwInt32 lockMode); +extern RwRaster *RwRasterUnlockPalette(RwRaster * raster); + +/* Attaching toolkits */ +extern RwInt32 RwRasterRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwRasterGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwRasterValidatePlugins(const RwRaster * raster); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/drvmodel.h ---*/ +#ifndef D3D8_DRVMODEL_H +#define D3D8_DRVMODEL_H + +#if (defined(__ICL)) +/* Avoid voluminous + * 'warning #344: typedef name has already been declared (with same type)' + * warnings from MS include files + */ +#pragma warning( disable : 344 ) +#endif /* (defined(__ICL)) */ + + +#include + +#if (defined(RWDEBUG)) +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#define ERR_WRAP(A) (_rwRePrintErrorDDD3D((A), __FILE__, __LINE__)) +#endif /* (defined(RWDEBUG)) */ + +#if (!defined(ERR_WRAP)) +#define ERR_WRAP(A) (A) +#endif /* (!defined(ERR_WRAP)) */ + +/**************************************************************************** + Defines + */ + +/* Set true depth information (for fogging, eg) */ +#define RwIm2DVertexSetCameraX(vert, camx) /* Nothing */ +#define RwIm2DVertexSetCameraY(vert, camy) /* Nothing */ +#define RwIm2DVertexSetCameraZ(vert, camz) /* Nothing */ + +#define RwIm2DVertexSetRecipCameraZ(vert, recipz) ((vert)->rhw = recipz) + +#define RwIm2DVertexGetCameraX(vert) (cause an error) +#define RwIm2DVertexGetCameraY(vert) (cause an error) +#define RwIm2DVertexGetCameraZ(vert) (cause an error) +#define RwIm2DVertexGetRecipCameraZ(vert) ((vert)->rhw) + +/* Set screen space coordinates in a device vertex */ +#define RwIm2DVertexSetScreenX(vert, scrnx) ((vert)->x = (scrnx)) +#define RwIm2DVertexSetScreenY(vert, scrny) ((vert)->y = (scrny)) +#define RwIm2DVertexSetScreenZ(vert, scrnz) ((vert)->z = (scrnz)) +#define RwIm2DVertexGetScreenX(vert) ((vert)->x) +#define RwIm2DVertexGetScreenY(vert) ((vert)->y) +#define RwIm2DVertexGetScreenZ(vert) ((vert)->z) + +/* Set texture coordinates in a device vertex */ +#define RwIm2DVertexSetU(vert, texU, recipz) ((vert)->u = (texU)) +#define RwIm2DVertexSetV(vert, texV, recipz) ((vert)->v = (texV)) +#define RwIm2DVertexGetU(vert) ((vert)->u) +#define RwIm2DVertexGetV(vert) ((vert)->v) + +/* Modify the luminance stuff */ +#define RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + (((RwFastRealToUInt32(alpha)) << 24) | \ + ((RwFastRealToUInt32(red)) << 16) | \ + ((RwFastRealToUInt32(green)) << 8) | \ + ((RwFastRealToUInt32(blue))))) + +#define RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + ((((RwUInt32)(alpha)) << 24) | \ + (((RwUInt32)(red)) << 16) | \ + (((RwUInt32)(green)) << 8) | \ + (((RwUInt32)(blue))))) + +#define RwIm2DVertexGetRed(vert) \ + (((vert)->emissiveColor >> 16) & 0xFF) + +#define RwIm2DVertexGetGreen(vert) \ + (((vert)->emissiveColor >> 8) & 0xFF) + +#define RwIm2DVertexGetBlue(vert) \ + ((vert)->emissiveColor & 0xFF) + +#define RwIm2DVertexGetAlpha(vert) \ + (((vert)->emissiveColor >> 24) & 0xFF) + +#define RwIm2DVertexCopyRGBA(dst, src) \ + ((dst)->emissiveColor = (src)->emissiveColor) + +/* Clipper stuff */ + +#define RwIm2DVertexClipRGBA(o, i, n, f) \ +MACRO_START \ +{ \ + const RwInt32 _factor = \ + (RwFastRealToUInt32(i * (RwReal)(255))) & 255; \ + \ + (o)->emissiveColor = \ + (((((RwIm2DVertexGetAlpha(f) - RwIm2DVertexGetAlpha(n)) * \ + _factor) >> 8) + RwIm2DVertexGetAlpha(n)) << 24) | \ + (((((RwIm2DVertexGetRed(f) - RwIm2DVertexGetRed(n)) * \ + _factor) >> 8) + RwIm2DVertexGetRed(n)) << 16) | \ + (((((RwIm2DVertexGetGreen(f) - RwIm2DVertexGetGreen(n)) * \ + _factor) >> 8) + RwIm2DVertexGetGreen(n)) << 8) | \ + (((((RwIm2DVertexGetBlue(f) - RwIm2DVertexGetBlue(n)) * \ + _factor) >> 8) + RwIm2DVertexGetBlue(n))); \ +} \ +MACRO_STOP + +/* LEGACY-SUPPORT macros */ +#define RWIM2DVERTEXSetCameraX(vert, camx) RwIm2DVertexSetCameraX(vert, camx) +#define RWIM2DVERTEXSetCameraY(vert, camy) RwIm2DVertexSetCameraY(vert, camy) +#define RWIM2DVERTEXSetCameraZ(vert, camz) RwIm2DVertexSetCameraZ(vert, camz) +#define RWIM2DVERTEXSetRecipCameraZ(vert, recipz) \ + RwIm2DVertexSetRecipCameraZ(vert, recipz) +#define RWIM2DVERTEXGetCameraX(vert) RwIm2DVertexGetCameraX(vert) +#define RWIM2DVERTEXGetCameraY(vert) RwIm2DVertexGetCameraY(vert) +#define RWIM2DVERTEXGetCameraZ(vert) RwIm2DVertexGetCameraZ(vert) +#define RWIM2DVERTEXGetRecipCameraZ(vert) RwIm2DVertexGetRecipCameraZ(vert) +#define RWIM2DVERTEXSetScreenX(vert, scrnx) RwIm2DVertexSetScreenX(vert, scrnx) +#define RWIM2DVERTEXSetScreenY(vert, scrny) RwIm2DVertexSetScreenY(vert, scrny) +#define RWIM2DVERTEXSetScreenZ(vert, scrnz) RwIm2DVertexSetScreenZ(vert, scrnz) +#define RWIM2DVERTEXGetScreenX(vert) RwIm2DVertexGetScreenX(vert) +#define RWIM2DVERTEXGetScreenY(vert) RwIm2DVertexGetScreenY(vert) +#define RWIM2DVERTEXGetScreenZ(vert) RwIm2DVertexGetScreenZ(vert) +#define RWIM2DVERTEXSetU(vert, u, recipz) RwIm2DVertexSetU(vert, u, recipz) +#define RWIM2DVERTEXSetV(vert, v, recipz) RwIm2DVertexSetV(vert, v, recipz) +#define RWIM2DVERTEXGetU(vert) RwIm2DVertexGetU(vert) +#define RWIM2DVERTEXGetV(vert) RwIm2DVertexGetV(vert) +#define RWIM2DVERTEXSetRealRGBA(vert, red, green, blue, alpha) \ + RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) +#define RWIM2DVERTEXSetIntRGBA(vert, red, green, blue, alpha) \ + RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) +#define RWIM2DVERTEXGetRed(vert) RwIm2DVertexGetRed(vert) +#define RWIM2DVERTEXGetGreen(vert) RwIm2DVertexGetGreen(vert) +#define RWIM2DVERTEXGetBlue(vert) RwIm2DVertexGetBlue(vert) +#define RWIM2DVERTEXGetAlpha(vert) RwIm2DVertexGetAlpha(vert) +#define RWIM2DVERTEXCopyRGBA(dst, src) RwIm2DVertexCopyRGBA(dst, src) +#define RWIM2DVERTEXClipRGBA(o, i, n, f) RwIm2DVertexClipRGBA(o, i, n, f) + +/**************************************************************************** + Global Types + */ + +/* We use RwD3D8Vertex to drive the hardware in 2D mode */ + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwD3D8Vertex + * D3D8 vertex structure definition for 2D geometry + */ +typedef struct RwD3D8Vertex RwD3D8Vertex; +/** + * \ingroup rwcoredriverd3d8 + * \struct RwD3D8Vertex + * D3D8 vertex structure definition for 2D geometry + */ +struct RwD3D8Vertex +{ + RwReal x; /**< Screen X */ + RwReal y; /**< Screen Y */ + RwReal z; /**< Screen Z */ + RwReal rhw; /**< Reciprocal of homogeneous W */ + + RwUInt32 emissiveColor; /**< Vertex color */ + + RwReal u; /**< Texture coordinate U */ + RwReal v; /**< Texture coordinate V */ +}; + +/* Define types used */ + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwIm2DVertex + * Typedef for a RenderWare Graphics Immediate Mode 2D Vertex + */ +typedef RwD3D8Vertex RwIm2DVertex; + +/* LEGACY-SUPPORT macro */ +/** + * \ingroup rwcoredriverd3d8 + * \def RWIM2DVERTEX + * RWIM2DVERTEX is a legacy macro for RwIm2DVertex + */ +#define RWIM2DVERTEX RwIm2DVertex + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RxVertexIndex + * + * Typedef for a RenderWare Graphics PowerPipe Immediate + * Mode Vertex + */ +typedef RwUInt16 RxVertexIndex; + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwImVertexIndex + * Typedef for a RenderWare Graphics Immediate Mode Vertex. + */ +typedef RxVertexIndex RwImVertexIndex; + +/* LEGACY-SUPPORT macro */ +/** + * \ingroup rwcoredriverd3d8 + * \def RWIMVERTEXINDEX + * RWIMVERTEXINDEX is a legacy macro for RwImVertexIndex + */ +#define RWIMVERTEXINDEX RwImVertexIndex + +/** + * \ingroup rwcoredriverd3d8 + * \struct RwD3D8Metrics + * Structure containing metrics counters + */ +typedef struct +{ + RwUInt32 numRenderStateChanges; /**< Number of Render States changed */ + RwUInt32 numTextureStageStateChanges; /**< Number of Texture Stage States changed */ + RwUInt32 numMaterialChanges; /**< Number of Material changes */ + RwUInt32 numLightsChanged; /**< Number of Lights changed */ +} +RwD3D8Metrics; + +#endif /* D3D8_DRVMODEL_H */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/d3d8/pip2model.h ---*/ + + + + + +/**************************************************************************** + Global Defines + */ + +#define RXHEAPPLATFORMDEFAULTSIZE (1 << 12) /* 4k */ + +/**************************************************************************** + Global Types + */ + +/* We use D3D8 formats for the instanced versions, to allow hardware T&L */ + +/** + * \ingroup corep2d3d8 + * \typedef RxObjSpace3DVertex + * Typedef for an RxObjSpace3DVertex. + */ +typedef struct RxObjSpace3DVertex RxObjSpace3DVertex; + +/** + * \ingroup corep2d3d8 + * \struct RxObjSpace3DVertex + * Structure representing object space vertex. + */ +struct RxObjSpace3DVertex +{ + RwV3d objVertex; /**< position */ + RwV3d objNormal; /**< normal */ + RwUInt32 color; /**< emissive color*/ + RwReal u; /**< u */ + RwReal v; /**< v */ +}; + +/* This vertex is non truncatable */ +#define RxObjSpace3DVertexNoUVsNoNormalsSize (sizeof(RxObjSpace3DVertex)) +#define RxObjSpace3DVertexNoUVsSize (sizeof(RxObjSpace3DVertex)) +#define RxObjSpace3DVertexFullSize (sizeof(RxObjSpace3DVertex)) + +/** + * \ingroup corep2d3d8 + * \typedef RxObjSpace3DLitVertex + * Typedef for an RxObjSpace3DLitVertex. + */ +typedef RxObjSpace3DVertex RxObjSpace3DLitVertex; + +/** + * \ingroup corep2d3d8 + * \typedef RwIm3DVertex + * Typedef for an RwIm3DVertex. + */ +typedef RxObjSpace3DLitVertex RwIm3DVertex; + +/* LEGACY-SUPPORT macro */ +#define RWIM3DVERTEX RwIm3DVertex +typedef RwIm2DVertex RxScrSpace2DVertex; + +/**************************************************************************** + Object-space 3D unlit vertex macros + */ + +/* Vertex positions */ +#define RxObjSpace3DVertexGetPos(_vert, _pos) \ + (*(_pos) = (_vert)->objVertex) +#define RxObjSpace3DVertexSetPos(_vert, _pos) \ + ((_vert)->objVertex = *(_pos)) + +/* Pre-lighting colours */ +#define RxObjSpace3DVertexGetPreLitColor(_vert, _col) \ +MACRO_START \ +{ \ + (_col)->alpha = (RwUInt8)((_vert)->color >> 24) & 0xFF; \ + (_col)->red = (RwUInt8)((_vert)->color >> 16) & 0xFF; \ + (_col)->green = (RwUInt8)((_vert)->color >> 8) & 0xFF; \ + (_col)->blue = (RwUInt8)((_vert)->color ) & 0xFF; \ +} \ +MACRO_STOP + +#define RxObjSpace3DVertexSetPreLitColor(_vert, _col) \ + ((_vert)->color = (((RwUInt32)(_col)->alpha) << 24) | \ + (((RwUInt32)(_col)->red) << 16) | \ + (((RwUInt32)(_col)->green) << 8) | \ + (((RwUInt32)(_col)->blue) )) + +/* This uses the same slot as color (they are mutually exclusive) */ +#define RxObjSpace3DVertexGetColor RxObjSpace3DVertexGetPreLitColor + +/* Normals */ +#define RxObjSpace3DVertexGetNormal(_vert, _normal) \ + (*(_normal) = (_vert)->objNormal) +#define RxObjSpace3DVertexSetNormal(_vert, _normal) \ + ((_vert)->objNormal = *(_normal)) + +/* Us and Vs */ +#define RxObjSpace3DVertexGetU(_vert) \ + ((_vert)->u) +#define RxObjSpace3DVertexGetV(_vert) \ + ((_vert)->v) +#define RxObjSpace3DVertexSetU(_vert, _imu) \ + ((_vert)->u = (_imu)) +#define RxObjSpace3DVertexSetV(_vert, _imv) \ + ((_vert)->v = (_imv)) + +/**************************************************************************** + Object-space 3D lit vertex macros + */ + +/* Vertex positions */ +#define RxObjSpace3DLitVertexGetPos(_vert, _pos) \ + (*(_pos) = (_vert)->objVertex) +#define RxObjSpace3DLitVertexSetPos(_vert, _pos) \ + ((_vert)->objVertex = *(_pos)) + +/* Vertex colours */ +#define RxObjSpace3DLitVertexGetColor(_vert, _col) \ +MACRO_START \ +{ \ + (_col)->red = ((_vert)->color >> 16) & 0xFF; \ + (_col)->green = ((_vert)->color >> 8) & 0xFF; \ + (_col)->blue = ((_vert)->color ) & 0xFF; \ + (_col)->alpha = ((_vert)->color >> 24) & 0xFF; \ +} \ +MACRO_STOP +#define RxObjSpace3DLitVertexSetColor(_vert, _col) \ + ((_vert)->color = (((RwUInt32)(_col)->alpha) << 24) | \ + (((RwUInt32)(_col)->red) << 16) | \ + (((RwUInt32)(_col)->green) << 8) | \ + (((RwUInt32)(_col)->blue) )) + +/* Us and Vs */ +#define RxObjSpace3DLitVertexGetU(_vert) \ + ((_vert)->u) +#define RxObjSpace3DLitVertexGetV(_vert) \ + ((_vert)->v) +#define RxObjSpace3DLitVertexSetU(_vert, _imu) \ + ((_vert)->u = (_imu)) +#define RxObjSpace3DLitVertexSetV(_vert, _imv) \ + ((_vert)->v = (_imv)) + +/* LEGACY-SUPPORT for old objvert names - NB does NOT guarantee the + * app will work, because the old IM3DVERTEX macros are NOT correctly + * abstracted - 'Get' will return pointers to RwV3ds inside the + * ObjVert, but you can't assume there are any RwV3ds inside an + * opaque vertex type */ + +#define RwIm3DVertexSetU RxObjSpace3DLitVertexSetU +#define RwIm3DVertexSetV RxObjSpace3DLitVertexSetV +#define RwIm3DVertexGetNext(_vert) ((_vert) + 1) + +#define RwIm2DCameraVertexSetU(_devvert, _camvert, _u, _recipz) \ +MACRO_START \ +{ \ + RwReal _uTmp = _u; \ + _camvert->u = _uTmp; \ + RwIm2DVertexSetU(_devvert, _uTmp, _recipz); \ +} \ +MACRO_STOP +#define RwIm2DCameraVertexSetV(_devvert, _camvert, _v, _recipz) \ +MACRO_START \ +{ \ + RwReal _vTmp = _v; \ + _camvert->v = _vTmp; \ + RwIm2DVertexSetV(_devvert, _vTmp, _recipz); \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetPos(_vert, _imx, _imy, _imz) \ +MACRO_START \ +{ \ + (_vert)->objVertex.x = _imx; \ + (_vert)->objVertex.y = _imy; \ + (_vert)->objVertex.z = _imz; \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetNormal(vert, imx, imy, imz) \ +MACRO_START \ +{ \ + RwV3d packed; \ + packed.x = imx; \ + packed.y = imy; \ + packed.z = imz; \ + RxObjSpace3DVertexSetNormal(vert, &packed); \ +} \ +MACRO_STOP + +#define RwIm3DVertexSetRGBA(_vert, _r, _g, _b, _a) \ +MACRO_START \ +{ \ + ((_vert)->color = ((_a) << 24) | \ + ((_r) << 16) | \ + ((_g) << 8) | \ + ((_b))); \ +} \ +MACRO_STOP + +#define RwIm3DVertexGetPos(_vert) (&((_vert)->objVertex)) +#define RwIm3DVertexGetNormal(vert) (&((vert)->objNormal)) + +#define RwIm3DVertexCopyRGBA(_dst, _src) (((_dst)->color) = ((_src)->color)) + +/* LEGACY-SUPPORT macros */ +#define RWIM2DCAMERAVERTEXSetU(_devvert, _camvert, _u, _recipz) \ + RwIm2DCameraVertexSetU(_devvert, _camvert, _u, _recipz) +#define RWIM2DCAMERAVERTEXSetV(_devvert, _camvert, _v, _recipz) \ + RwIm2DCameraVertexSetV(_devvert, _camvert, _v, _recipz) +#define RWIM3DVERTEXGetNext(vert) RwIm3DVertexGetNext(vert) +#define RWIM3DVERTEXSetPos(vert, imx, imy, imz) RwIm3DVertexSetPos(vert, imx, imy, imz) +#define RWIM3DVERTEXGetPos(vert) RwIm3DVertexGetPos(vert) +#define RWIM3DVERTEXSetU(vert, imu) RwIm3DVertexSetU(vert, imu) +#define RWIM3DVERTEXSetV(vert, imv) RwIm3DVertexSetV(vert, imv) +#define RWIM3DVERTEXSetRGBA(vert, r, g, b, a) RwIm3DVertexSetRGBA(vert, r, g, b, a) +#define RWIM3DVERTEXSetNormal(vert, imx, imy, imz) RwIm3DVertexSetNormal(vert, imx, imy, imz) +#define RWIM3DVERTEXCopyRGBA(dst,src) RwIm3DVertexCopyRGBA(dst,src) +#define RXOBJSPACE3DVERTEXGetPos(_vert, _pos) \ + RxObjSpace3DVertexGetPos(_vert, _pos) +#define RXOBJSPACE3DVERTEXSetPos(_vert, _pos) \ + RxObjSpace3DVertexSetPos(_vert, _pos) +#define RXOBJSPACE3DVERTEXGetPreLitColor(_vert, _col) \ + RxObjSpace3DVertexGetPreLitColor(_vert, _col) +#define RXOBJSPACE3DVERTEXSetPreLitColor(_vert, _col) \ + RxObjSpace3DVertexSetPreLitColor(_vert, _col) +#define RXOBJSPACE3DVERTEXGetColor RxObjSpace3DVertexGetColor +#define RXOBJSPACE3DVERTEXGetNormal(_vert, _normal) \ + RxObjSpace3DVertexGetNormal(_vert, _normal) +#define RXOBJSPACE3DVERTEXSetNormal(_vert, _normal) \ + RxObjSpace3DVertexSetNormal(_vert, _normal) +#define RXOBJSPACE3DVERTEXGetU(_vert) RxObjSpace3DVertexGetU(_vert) +#define RXOBJSPACE3DVERTEXGetV(_vert) RxObjSpace3DVertexGetV(_vert) +#define RXOBJSPACE3DVERTEXSetU(_vert, _imu) \ + RxObjSpace3DVertexSetU(_vert, _imu) +#define RXOBJSPACE3DVERTEXSetV(_vert, _imv) \ + RxObjSpace3DVertexSetV(_vert, _imv) +#define RXOBJSPACE3DLITVERTEXGetPos(vert, pos) \ + RxObjSpace3DLitVertexGetPos(vert, pos) +#define RXOBJSPACE3DLITVERTEXSetPos(vert, pos) \ + RxObjSpace3DLitVertexSetPos(vert, pos) +#define RXOBJSPACE3DLITVERTEXGetColor(vert, col) \ + RxObjSpace3DLitVertexGetColor(vert, col) +#define RXOBJSPACE3DLITVERTEXSetColor(vert, col) \ + RxObjSpace3DLitVertexSetColor(vert, col) +#define RXOBJSPACE3DLITVERTEXGetU(vert) \ + RxObjSpace3DLitVertexGetU(vert) +#define RXOBJSPACE3DLITVERTEXGetV(vert) \ + RxObjSpace3DLitVertexGetV(vert) +#define RXOBJSPACE3DLITVERTEXSetU(vert, imu) \ + RxObjSpace3DLitVertexSetU(vert, imu) +#define RXOBJSPACE3DLITVERTEXSetV(vert, imv) \ + RxObjSpace3DLitVertexSetV(vert, imv) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2renderstate.h ---*/ + +/** + * \ingroup rwcoregeneric + * RxRenderStateFlag + * Flags used in the \ref RxRenderStateVector structure */ +enum RxRenderStateFlag +{ + rxRENDERSTATEFLAG_TEXTUREPERSPECTIVE = 0x00000001, /**stride = (_stride)), (_image)) + +#define RwImageSetPixelsMacro(_image, _pixels) \ + (((_image)->cpPixels = (_pixels)), (_image)) + +#define RwImageSetPaletteMacro(_image, _palette) \ + (((_image)->palette = (_palette)), (_image)) + +#define RwImageGetWidthMacro(_image) \ + ((_image)->width) + +#define RwImageGetHeightMacro(_image) \ + ((_image)->height) + +#define RwImageGetDepthMacro(_image) \ + ((_image)->depth) + +#define RwImageGetStrideMacro(_image) \ + ((_image)->stride) + +#define RwImageGetPixelsMacro(_image) \ + ((_image)->cpPixels) + +#define RwImageGetPaletteMacro(_image) \ + ((_image)->palette) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwImageSetStride(_image, _stride) \ + RwImageSetStrideMacro(_image, _stride) + +#define RwImageSetPixels(_image, _pixels) \ + RwImageSetPixelsMacro(_image, _pixels) + +#define RwImageSetPalette(_image, _palette) \ + RwImageSetPaletteMacro(_image, _palette) + +#define RwImageGetWidth(_image) \ + RwImageGetWidthMacro(_image) + +#define RwImageGetHeight(_image) \ + RwImageGetHeightMacro(_image) + +#define RwImageGetDepth(_image) \ + RwImageGetDepthMacro(_image) + +#define RwImageGetStride(_image) \ + RwImageGetStrideMacro(_image) + +#define RwImageGetPixels(_image) \ + RwImageGetPixelsMacro(_image) + +#define RwImageGetPalette(_image) \ + RwImageGetPaletteMacro(_image) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* Creating and destroying */ +extern RwImage *RwImageCreate(RwInt32 width, RwInt32 height, + RwInt32 depth); +extern RwBool RwImageDestroy(RwImage * image); + + /* Allocating */ +extern RwImage *RwImageAllocatePixels(RwImage * image); +extern RwImage *RwImageFreePixels(RwImage * image); + + /* Converting images */ +extern RwImage *RwImageCopy(RwImage * destImage, + const RwImage * sourceImage); + + /* Resizing images */ +extern RwImage *RwImageResize(RwImage * image, RwInt32 width, + RwInt32 height); + + /* Producing masks ! */ +extern RwImage *RwImageApplyMask(RwImage * image, + const RwImage * mask); +extern RwImage *RwImageMakeMask(RwImage * image); + + /* Helper functions */ +extern RwImage *RwImageReadMaskedImage(const RwChar * imageName, + const RwChar * maskname); +extern RwImage *RwImageRead(const RwChar * imageName); +extern RwImage *RwImageWrite(RwImage * image, + const RwChar * imageName); + + /* Setting and getting the default path for images */ +extern RwChar *RwImageGetPath(void); +extern const RwChar *RwImageSetPath(const RwChar * path); + + /* Setting */ +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +extern RwImage *RwImageSetStride(RwImage * image, RwInt32 stride); +extern RwImage *RwImageSetPixels(RwImage * image, RwUInt8 * pixels); +extern RwImage *RwImageSetPalette(RwImage * image, RwRGBA * palette); + + /* Getting */ +extern RwInt32 RwImageGetWidth(const RwImage * image); +extern RwInt32 RwImageGetHeight(const RwImage * image); +extern RwInt32 RwImageGetDepth(const RwImage * image); +extern RwInt32 RwImageGetStride(const RwImage * image); +extern RwUInt8 *RwImageGetPixels(const RwImage * image); +extern RwRGBA *RwImageGetPalette(const RwImage * image); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + /* Get device dependent pixel value */ +extern RwUInt32 RwRGBAToPixel(RwRGBA * rgbIn, RwInt32 rasterFormat); +extern RwRGBA *RwRGBASetFromPixel(RwRGBA * rgbOut, + RwUInt32 pixelValue, + RwInt32 rasterFormat); + + /* Gamma correction */ +extern RwBool RwImageSetGamma(RwReal gammaValue); +extern RwReal RwImageGetGamma(void); +extern RwImage *RwImageGammaCorrect(RwImage * image); + + /* Adding and removing gamma correction */ +extern RwRGBA *RwRGBAGammaCorrect(RwRGBA * rgb); + + /* Attaching toolkits */ +extern RwInt32 RwImageRegisterPlugin(RwInt32 size, RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwImageGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwImageValidatePlugins(const RwImage * image); + +extern RwBool RwImageRegisterImageFormat(const RwChar * extension, + RwImageCallBackRead + imageRead, + RwImageCallBackWrite + imageWrite); + + /* Finding an extension for an image to load */ +extern const RwChar *RwImageFindFileType(const RwChar * imageName); + + /* Reading and writing images to streams */ +extern RwInt32 RwImageStreamGetSize(const RwImage * image); +extern RwImage *RwImageStreamRead(RwStream * stream); +extern const RwImage *RwImageStreamWrite(const RwImage * image, + RwStream * stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/batextur.h ---*/ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rwTEXDICTIONARY 6 + +/* Mipmap Name generation - maximum number of RwChar characters which can + * be appended to the root name. + */ +#define rwTEXTUREMIPMAPNAMECHARS 16 + +/* We define texture names to be a maximum of 16 ISO chars */ +#define rwTEXTUREBASENAMELENGTH 32 + +#define rwTEXTUREFILTERMODEMASK 0x000000FF +#define rwTEXTUREADDRESSINGUMASK 0x00000F00 +#define rwTEXTUREADDRESSINGVMASK 0x0000F000 +#define rwTEXTUREADDRESSINGMASK (rwTEXTUREADDRESSINGUMASK | \ + rwTEXTUREADDRESSINGVMASK) + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup datatypes + * \typedef RwTexDictionary + * is a texture dictionary containing textures. + * This should be considered an opaque type. + * Use the RwTexDictionary API functions to access. + */ +typedef struct RwTexDictionary RwTexDictionary; + +#if (!defined(DOXYGEN)) +struct RwTexDictionary +{ + RwObject object; /* Homogeneous type */ + RwLinkList texturesInDict; /* List of textures in dictionary */ + RwLLLink lInInstance; /* Link list of all dicts in system */ +}; +/* Information is entirely device dependent */ +#endif /* (!defined(DOXYGEN)) */ + + +/* Parent is the dictionary */ + +/** + * \ingroup datatypes + * \typedef RwTexture + * is a texture object. + * This should be considered an opaque type. + * Use the RwTexture API functions to access. + */ +typedef struct RwTexture RwTexture; + +#if (!defined(DOXYGEN)) +struct RwTexture +{ + RwRaster *raster; /** pointer to RwRaster with data */ + RwTexDictionary *dict; /* Dictionary this texture is in */ + RwLLLink lInDictionary; /* List of textures in this dictionary */ + + RwChar name[rwTEXTUREBASENAMELENGTH]; /* Name of the texture */ + RwChar mask[rwTEXTUREBASENAMELENGTH]; /* Name of the textures mask */ + + /* 31 [xxxxxxxx xxxxxxxx vvvvuuuu ffffffff] 0 */ + RwUInt32 filterAddressing; /* Filtering & addressing mode flags */ + + RwInt32 refCount; /* Reference count, surprisingly enough */ +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup datatypes + * \ref RwTextureCallBackRead + * represents the function used by \ref RwTextureRead to read the specified + * texture from a disk file. This function should return a pointer to the + * texture to indicate success. + * + * \param name Pointer to a string containing the name of + * the texture to read. + * + * \param maskName Pointer to a string containing the name + * of the mask to read and apply to the texture. + * + * \return Pointer to the texture + * + * \see RwTextureSetReadCallBack + * \see RwTextureGetReadCallBack + */ +typedef RwTexture *(*RwTextureCallBackRead)(const RwChar *name, + const RwChar *maskName); + +/** + * \ingroup datatypes + * \ref RwTextureCallBack + * represents the function called from \ref RwTexDictionaryForAllTextures + * for all textures in a given texture dictionary. This function should + * return the current texture to indicate success. The callback may return + * NULL to terminate further callbacks on the texture dictionary. + * + * \param texture Pointer to the current texture. + * + * \param pData User-defined data pointer. + * + * \return Pointer to the current texture + * + * \see RwTexDictionaryForAllTextures + */ +typedef RwTexture *(*RwTextureCallBack)(RwTexture *texture, void *pData); + + +/** + * \ingroup datatypes + * \ref RwTexDictionaryCallBack + * represents the function called from \ref RwTexDictionaryForAllTexDictionaries + * for all texture dictionaries that currently exist. This function should + * return the current texture dictionary to indicate success. The callback may + * return NULL to terminate further callbacks on the texture dictionary. It may + * safely destroy the current texture dictionary without adversely affecting + * the iteration process. + * + * \param dict Pointer to the current texture dictionary. + * + * \param pData User-defined data pointer. + * + * \return Pointer to the current texture dictionary + * + * \see RwTexDictionaryForAllTexdictionaries + */ +typedef RwTexDictionary *(*RwTexDictionaryCallBack)(RwTexDictionary *dict, void *data); + + +/** + * \ingroup datatypes + * \ref RwTextureCallBackMipmapGeneration + * is the callback function supplied to \ref RwTextureSetMipmapGenerationCallBack + * and returned from \ref RwTextureGetMipmapGenerationCallBack. + * + * The supplied function will be passed a pointer to a raster and an image. + * The raster is the target for the generated mipmap levels and the image + * provides the base for their generation. + * + * \param raster Pointer to raster, the target for generated mipmap levels + * \param image Pointer to image, used to generate mipmap levels. + * + * \return + * Returns a pointer to the raster if successful or NULL if an error occurred. + * + * \see RwTextureSetMipmapGenerationCallBack + * \see RwTextureGetMipmapGenerationCallBack + * \see RwTextureSetAutoMipmapping + * \see RwTextureGetAutoMipmapping + */ +typedef RwRaster *(*RwTextureCallBackMipmapGeneration)(RwRaster * raster, + RwImage * image); + +/** + * \ingroup datatypes + * \ref RwTextureCallBackMipmapName + * is the callback function supplied to \ref RwTextureSetMipmapNameCallBack and + * returned from \ref RwTextureGetMipmapNameCallBack. + * + * The supplied function will be passed a pointer to a root name, a maskName, a mipmap + * level and a format. The function returns TRUE if successful and the root name will have been + * modified to equal the mipmap name. + * + * \param name Pointer to a string containing the root name of the texture. The + * mipmap level name is put here. + * \param maskName Pointer to a string containing the root mask name of the texture or + * NULL if no mask name is required. + * \param mipLevel A value equal to the mipmap level for which the name is required. + * \param format A value describing the mipmapping mode. A combination of the bit + * flags rwRASTERFORMATMIPMAP and rwRASTERFORMATAUTOMIPMAP. + * + * \return + * Returns TRUE if the name is generated successfully or FALSE if an error occurred. + * + * \see RwTextureGenerateMipmapName + * \see RwTextureSetMipmapNameCallBack + * \see RwTextureGetMipmapNameCallBack + * \see RwTextureSetAutoMipmapping + * \see RwTextureGetAutoMipmapping + */ +typedef RwBool (*RwTextureCallBackMipmapName)(RwChar *name, + RwChar *maskName, + RwUInt8 mipLevel, + RwInt32 format); + +/**************************************************************************** + raster) + +#define RwTextureAddRefMacro(_tex) \ + (((_tex)->refCount++), (_tex)) + +#define RwTextureAddRefVoidMacro(_tex) \ +MACRO_START \ +{ \ + (_tex)->refCount++; \ +} \ +MACRO_STOP + +#define RwTextureGetNameMacro(_tex) \ + ((_tex)->name) + +#define RwTextureGetMaskNameMacro(_tex) \ + ((_tex)->mask) + +#define RwTextureGetDictionaryMacro(_tex) \ + ((_tex)->dict) + +#define RwTextureSetFilterModeMacro(_tex, _filtering) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREFILTERMODEMASK) | \ + (((RwUInt32)(_filtering)) & rwTEXTUREFILTERMODEMASK)), \ + (_tex)) + +#define RwTextureGetFilterModeMacro(_tex) \ + ((RwTextureFilterMode)((_tex)->filterAddressing & \ + rwTEXTUREFILTERMODEMASK)) + +#define RwTextureSetAddressingMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGMASK) | \ + (((((RwUInt32)(_addressing)) << 8) & rwTEXTUREADDRESSINGUMASK) | \ + ((((RwUInt32)(_addressing)) << 12) & rwTEXTUREADDRESSINGVMASK))), \ + (_tex)) + +#define RwTextureSetAddressingUMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGUMASK) | \ + (((RwUInt32)(_addressing) << 8) & rwTEXTUREADDRESSINGUMASK)), \ + (_tex)) + +#define RwTextureSetAddressingVMacro(_tex, _addressing) \ + (((_tex)->filterAddressing = \ + ((_tex)->filterAddressing & ~rwTEXTUREADDRESSINGVMASK) | \ + (((RwUInt32)(_addressing) << 12) & rwTEXTUREADDRESSINGVMASK)), \ + (_tex)) + +#define RwTextureGetAddressingMacro(_tex) \ + (((((_tex)->filterAddressing & rwTEXTUREADDRESSINGUMASK) >> 8) == \ + (((_tex)->filterAddressing & rwTEXTUREADDRESSINGVMASK) >> 12)) ? \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGVMASK) >> 12)) : \ + rwTEXTUREADDRESSNATEXTUREADDRESS) + +#define RwTextureGetAddressingUMacro(_tex) \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGUMASK) >> 8)) + +#define RwTextureGetAddressingVMacro(_tex) \ + ((RwTextureAddressMode)(((_tex)->filterAddressing & \ + rwTEXTUREADDRESSINGVMASK) >> 12)) + + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwTextureGetRaster(_tex) \ + RwTextureGetRasterMacro(_tex) + +#define RwTextureAddRef(_tex) \ + RwTextureAddRefMacro(_tex) + +#define RwTextureGetName(_tex) \ + RwTextureGetNameMacro(_tex) + +#define RwTextureGetMaskName(_tex) \ + RwTextureGetMaskNameMacro(_tex) + +#define RwTextureGetDictionary(_tex) \ + RwTextureGetDictionaryMacro(_tex) + +#define RwTextureSetFilterMode(_tex, _filtering) \ + RwTextureSetFilterModeMacro(_tex, _filtering) + +#define RwTextureGetFilterMode(_tex) \ + RwTextureGetFilterModeMacro(_tex) + +#define RwTextureSetAddressing(_tex, _addressing) \ + RwTextureSetAddressingMacro(_tex, _addressing) + +#define RwTextureSetAddressingU(_tex, _addressing) \ + RwTextureSetAddressingUMacro(_tex, _addressing) + +#define RwTextureSetAddressingV(_tex, _addressing) \ + RwTextureSetAddressingVMacro(_tex, _addressing) + +#define RwTextureGetAddressing(_tex) \ + RwTextureGetAddressingMacro(_tex) + +#define RwTextureGetAddressingU(_tex) \ + RwTextureGetAddressingUMacro(_tex) + +#define RwTextureGetAddressingV(_tex) \ + RwTextureGetAddressingVMacro(_tex) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* Reading mip maps */ + + /* Setting mip mapping states */ +extern RwBool RwTextureSetMipmapping(RwBool enable); +extern RwBool RwTextureGetMipmapping(void); +extern RwBool RwTextureSetAutoMipmapping(RwBool enable); +extern RwBool RwTextureGetAutoMipmapping(void); + + /* Setting and getting the mipmap generation function */ +extern RwBool +RwTextureSetMipmapGenerationCallBack(RwTextureCallBackMipmapGeneration + callback); +extern RwTextureCallBackMipmapGeneration +RwTextureGetMipmapGenerationCallBack(void); + + /* Setting and getting the mipmap file name generation function */ +extern RwBool +RwTextureSetMipmapNameCallBack(RwTextureCallBackMipmapName callback); +extern RwTextureCallBackMipmapName RwTextureGetMipmapNameCallBack(void); + + /* Generating mipmaps for a raster */ +extern RwBool RwTextureGenerateMipmapName(RwChar * name, + RwChar * maskName, + RwUInt8 mipLevel, + RwInt32 format); +extern RwBool RwTextureRasterGenerateMipmaps(RwRaster * raster, + RwImage * image); + + /* LEGACY-SUPPORT mip mapping */ +extern RwBool _rwTextureSetAutoMipMapState(RwBool enable); +extern RwBool _rwTextureGetAutoMipMapState(void); + + /* Setting and getting the callback function */ +extern RwTextureCallBackRead RwTextureGetReadCallBack(void); +extern RwBool RwTextureSetReadCallBack(RwTextureCallBackRead + fpCallBack); + + /* Texture and mask names */ +extern RwTexture *RwTextureSetName(RwTexture * texture, + const RwChar * name); +extern RwTexture *RwTextureSetMaskName(RwTexture * texture, + const RwChar * maskName); + + /* Creating/destroying dictionaries */ +extern RwTexDictionary *RwTexDictionaryCreate(void); +extern RwBool RwTexDictionaryDestroy(RwTexDictionary * dict); + + /* Textures */ +extern RwTexture *RwTextureCreate(RwRaster * raster); +extern RwBool RwTextureDestroy(RwTexture * texture); + + /* Setting and getting texture map rasters */ +extern RwTexture *RwTextureSetRaster(RwTexture * texture, + RwRaster * raster); + + /* Dictionary access */ +extern RwTexture *RwTexDictionaryAddTexture(RwTexDictionary * dict, + RwTexture * texture); +extern RwTexture *RwTexDictionaryRemoveTexture(RwTexture * texture); +extern RwTexture *RwTexDictionaryFindNamedTexture(RwTexDictionary * + dict, + const RwChar * name); + + /* Reading a texture */ +extern RwTexture *RwTextureRead(const RwChar * name, + const RwChar * maskName); + + /* Setting the current dictionary */ +extern RwTexDictionary *RwTexDictionaryGetCurrent(void); +extern RwTexDictionary *RwTexDictionarySetCurrent(RwTexDictionary * dict); + + /* Enumerating textures */ +extern const RwTexDictionary *RwTexDictionaryForAllTextures(const + RwTexDictionary + * dict, + RwTextureCallBack + fpCallBack, + void *pData); + + /* Enumerating the texture dictionaries currently in the system */ +extern RwBool RwTexDictionaryForAllTexDictionaries( + RwTexDictionaryCallBack fpCallBack, void *pData); + + + /* Attaching toolkits */ +extern RwInt32 RwTextureRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwTexDictionaryRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy + copyCB); +extern RwInt32 RwTextureGetPluginOffset(RwUInt32 pluginID); +extern RwInt32 RwTexDictionaryGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwTextureValidatePlugins(const RwTexture * texture); +extern RwBool RwTexDictionaryValidatePlugins(const RwTexDictionary * + dict); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) +/* Textures */ +extern RwRaster *RwTextureGetRaster(const RwTexture *texture); +extern RwTexture *RwTextureAddRef(RwTexture *texture); + +/* Texture and mask names */ +extern RwChar *RwTextureGetName(RwTexture *texture); +extern RwChar *RwTextureGetMaskName(RwTexture *texture); + +/* Get owner dictionary */ +extern RwTexDictionary *RwTextureGetDictionary(RwTexture *texture); + +/* Filtering */ +extern RwTexture *RwTextureSetFilterMode(RwTexture *texture, + RwTextureFilterMode filtering); + +extern RwTextureFilterMode RwTextureGetFilterMode(const RwTexture *texture); + +/* Addressing */ +extern RwTexture *RwTextureSetAddressing(RwTexture *texture, + RwTextureAddressMode addressing); +extern RwTexture *RwTextureSetAddressingU(RwTexture *texture, + RwTextureAddressMode addressing); +extern RwTexture *RwTextureSetAddressingV(RwTexture *texture, + RwTextureAddressMode addressing); + +extern RwTextureAddressMode RwTextureGetAddressing(const RwTexture *texture); +extern RwTextureAddressMode RwTextureGetAddressingU(const RwTexture *texture); +extern RwTextureAddressMode RwTextureGetAddressingV(const RwTexture *texture); + +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define RwTextureSetAutoMipMapState(_enable) \ + _rwTextureSetAutoMipMapState(_enable) + +#define RwTextureGetAutoMipMapState() \ + _rwTextureGetAutoMipMapState() + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/p2stdcls.h ---*/ + +/* + * Current: + * + * wait on Simon for instructions to do cluster renaming thing, + * or go thru and change all cluster type names and cluster + * names (add CSL?) + * + */ + +/* CamVerts.csl */ + +/* clip flags */ + +/** + * \ingroup rwcoregeneric + * \ref RwClipFlag + * Flags specifying the clipping status of a vertex + */ +enum RwClipFlag +{ + rwXLOCLIP = 0x01, /**col.red = (r)); \ + ((camvert)->col.green = (g)); \ + ((camvert)->col.blue = (b)); \ + ((camvert)->col.alpha = (a)); \ +} \ +MACRO_STOP + +#define RxCamSpace3DVertexAddRGBA(camvert, r, g, b, a) \ +MACRO_START \ +{ \ + ((camvert)->col.red += (r)); \ + ((camvert)->col.green += (g)); \ + ((camvert)->col.blue += (b)); \ + ((camvert)->col.alpha += (a)); \ +} \ +MACRO_STOP + +/* LEGACY-SUPPORT macros */ +#define RXCAMSPACE3DVERTEXSetRGBA(camvert, r, g, b, a) \ + RxCamSpace3DVertexSetRGBA(camvert, r, g, b, a) +#define RXCAMSPACE3DVERTEXAddRGBA(camvert, r, g, b, a) \ + RxCamSpace3DVertexAddRGBA(camvert, r, g, b, a) + +/* MeshState.csl */ + + +/** + * \ingroup rwcoregeneric + * \ref RxGeometryFlag + * Flags describing geometry properties + */ +enum RxGeometryFlag +{ + rxGEOMETRY_TRISTRIP = 0x01, /**=1000) +# pragma pack(push, 1) +# endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +typedef struct RxVStep RxVStep; +/** + * \ingroup rwcoregeneric + * \struct RxVStep + * Structure used by the RxClVStep cluster. + * To use the step values in the RxClVStep cluster, start at the beginning + * of the RxVStep and vertex arrays and proceed as follows: (a) Process one + * vertex, (b) Skip 'step' vertices, (c) Increment the cursor of the RxClVStep + * cluster. Repeat (a)-(c) until the entire vertex array has been processed. + * If the RxVStep array contains valid data, you should not have to bounds-check + * its cursor. + */ +struct RxVStep +{ + RwUInt8 step; /**< \ref RwUInt8 The number of vertices after the current one + * which can be skipped in lighting and other calculations because, + * for example, they belong only to back-facing triangles */ +}; + +#if (defined(_MSC_VER)) +# if (_MSC_VER>=1000) +# pragma pack(pop) +# endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +/* CamNorms.csl */ +/** + * \ingroup rwcoregeneric + * \typedef RxCamNorm + * typedef for \ref RwV3d used by the RxClVStep cluster */ +typedef RwV3d RxCamNorm; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Uses the RxObjSpace3DVertex type (see pipmodel.h) */ +extern RxClusterDefinition RxClObjSpace3DVertices; +/* Uses the RxCamSpace3DVertex type */ +extern RxClusterDefinition RxClCamSpace3DVertices; +/* Uses the RxScrSpace2DVertex type (see pipmodel.h) */ +extern RxClusterDefinition RxClScrSpace2DVertices; +/* Uses the RxInterp type */ +extern RxClusterDefinition RxClInterpolants; +/* Uses the RxMeshStateVector type */ +extern RxClusterDefinition RxClMeshState; +/* Uses the RxRenderStateVector type (p2renderstate.c/h) */ +extern RxClusterDefinition RxClRenderState; +/* Uses the RxVertexIndex type */ +extern RxClusterDefinition RxClIndices; +/* Uses the RxScatter type */ +extern RxClusterDefinition RxClScatter; +/* Uses the RxUV type */ +extern RxClusterDefinition RxClUVs; +/* Uses the RxVStep type */ +extern RxClusterDefinition RxClVSteps; +/* Uses the RwRGBAReal type */ +extern RxClusterDefinition RxClRGBAs; +/* Uses the RxCamNorm type */ +extern RxClusterDefinition RxClCamNorms; + +/* Uses the RxTriPlane type. + * NOTE: this is currently not used in any nodes that ship with the SDK */ +extern RxClusterDefinition RxClTriPlanes; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/baim3d.h ---*/ + +/** + * \ingroup datatypes + * RwIm3DTransformFlags + * The bit-field type RwIm3DTransformFlags + * specifies options available for controlling execution of the 3D immediate + * mode pipeline (see API function \ref RwIm3DTransform):*/ +enum RwIm3DTransformFlags +{ + rwIM3D_VERTEXUV = 1, /**modelling) +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) +#define RwFrameGetMatrix(_f) RwFrameGetMatrixMacro(_f) +#endif + + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Finding what is attached to a frame */ +extern RwFrame * +RwFrameForAllObjects(RwFrame * frame, + RwObjectCallBack callBack, + void *data); + +/* Matrix operations */ +extern RwFrame * +RwFrameTranslate(RwFrame * frame, + const RwV3d * v, + RwOpCombineType combine); + +extern RwFrame * +RwFrameRotate(RwFrame * frame, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combine); + +extern RwFrame * +RwFrameScale(RwFrame * frame, + const RwV3d * v, + RwOpCombineType combine); + +extern RwFrame * +RwFrameTransform(RwFrame * frame, + const RwMatrix * m, + RwOpCombineType combine); + +extern RwFrame * +RwFrameOrthoNormalize(RwFrame * frame); + +extern RwFrame * +RwFrameSetIdentity(RwFrame * frame); + +/* Cloning */ +extern RwFrame * +RwFrameCloneHierarchy(RwFrame * root); + +/* Destruction */ +extern RwBool +RwFrameDestroyHierarchy(RwFrame * frame); + +/* Building a frame */ +extern RwFrame * +RwFrameForAllChildren(RwFrame * frame, + RwFrameCallBack callBack, + void *data); + +extern RwFrame * +RwFrameRemoveChild(RwFrame * child); + +extern RwFrame * +RwFrameAddChild(RwFrame * parent, + RwFrame * child); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwFrame * +RwFrameGetParent(const RwFrame * frame); +#endif + +/* Getting the root */ +extern RwFrame * +RwFrameGetRoot(const RwFrame * frame); + +/* Getting Matrices */ +extern RwMatrix * +RwFrameGetLTM(RwFrame * frame); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) +extern RwMatrix * +RwFrameGetMatrix(RwFrame * frame); +#endif + +/* Elements */ +extern RwFrame * +RwFrameUpdateObjects(RwFrame * frame); + +/* Creating destroying frames */ +extern RwFrame * +RwFrameCreate(void); + +extern RwBool +RwFrameInit(RwFrame *frame); + +extern RwBool +RwFrameDeInit(RwFrame *frame); + +extern RwBool +RwFrameDestroy(RwFrame * frame); + +/* internal function used by Create and Init */ +extern void +_rwFrameInit(RwFrame *frame); + +/* internal function used by Destroy and DeInit */ +extern void +_rwFrameDeInit(RwFrame *frame); + +/* Finding a frames state */ +extern RwBool +RwFrameDirty(const RwFrame * frame); + +/* Find the amount of frames in a hierarchy */ +extern RwInt32 +RwFrameCount(RwFrame * frame); + +/* Plugins */ +extern RwBool +RwFrameSetStaticPluginsSize(RwInt32 size); + +extern RwInt32 +RwFrameRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor constructCB, + RwPluginObjectDestructor destructCB, + RwPluginObjectCopy copyCB); + +extern RwInt32 +RwFrameGetPluginOffset(RwUInt32 pluginID); + +extern RwBool +RwFrameValidatePlugins(const RwFrame * frame); + +/* Cloning */ +extern RwFrame * +_rwFrameCloneAndLinkClones(RwFrame * root); + +extern +RwFrame * +_rwFramePurgeClone(RwFrame *root); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compatibility macros */ + +#define rwFrameGetParent(frame) \ + _rwFrameGetParent(frame) + +#define rwFrameInit(frame) \ + _rwFrameInit(frame) + +#define rwFrameDeInit(frame) \ + _rwFrameDeInit(frame) + +#define rwFrameCloneAndLinkClones(root) \ + _rwFrameCloneAndLinkClones(root) + +#define rwFramePurgeClone(root) \ + _rwFramePurgeClone(root) + +#define rwFrameClose(instance, offset, size) \ + _rwFrameClose(instance, offset, size) + +#define rwFrameOpen(instance, offset, size) \ + _rwFrameOpen(instance, offset, size) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/batypehf.h ---*/ + +typedef struct RwObjectHasFrame RwObjectHasFrame; +typedef RwObjectHasFrame * (*RwObjectHasFrameSyncFunction)(RwObjectHasFrame *object); +struct RwObjectHasFrame +{ + RwObject object; + RwLLLink lFrame; + RwObjectHasFrameSyncFunction sync; +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Frames */ +extern void _rwObjectHasFrameSetFrame(void *object, RwFrame *frame); +extern void _rwObjectHasFrameReleaseFrame(void *object); + +/* ObjectHASFRAME METHODS */ +#define rwObjectHasFrameInitialize(o, type, subtype, syncFunc) \ +MACRO_START \ +{ \ + rwObjectInitialize(o, type, subtype); \ + ((RwObjectHasFrame *)o)->sync = syncFunc; \ +} \ +MACRO_STOP + +#define rwObjectHasFrameSync(o) \ + ((RwObjectHasFrame *)(o))->sync(o) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compatibility macros */ + +#define rwObjectHasFrameSetFrame(object, frame) \ + _rwObjectHasFrameSetFrame(object, frame) +#define rwObjectHasFrameReleaseFrame(object) \ + _rwObjectHasFrameReleaseFrame(object) + + + +/*--- Automatically derived from: C:/daily/rwsdk/src/basync.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/babintex.h ---*/ +/**************************************************************************** + Global types + */ +typedef struct rpTextureChunkInfo RwTextureChunkInfo; +struct rpTextureChunkInfo +{ + RwTextureFilterMode filtering; + RwTextureAddressMode addressingU; + RwTextureAddressMode addressingV; +}; + +/* Bit flags defining properties of textures when stream */ +enum RwTextureStreamFlags +{ + rwNATEXTURESTREAMFLAG = 0x00, + rwTEXTURESTREAMFLAGSUSERMIPMAPS = 0x01, + rwTEXTURESTREAMFLAGSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwTextureStreamFlags RwTextureStreamFlags; +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Texture binary format */ +extern RwInt32 +RwTextureRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwTextureSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwUInt32 +RwTextureStreamGetSize(const RwTexture *texture); + +extern RwTexture * +RwTextureStreamRead(RwStream *stream); + +extern const RwTexture * +RwTextureStreamWrite(const RwTexture *texture, + RwStream *stream); + +/* Texture dictionary binary format */ +extern RwInt32 +RwTexDictionaryRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwTexDictionarySetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + +extern RwUInt32 +RwTexDictionaryStreamGetSize(const RwTexDictionary *texDict); + +extern RwTexDictionary +*RwTexDictionaryStreamRead(RwStream *stream); + +extern const RwTexDictionary * +RwTexDictionaryStreamWrite(const RwTexDictionary *texDict, + RwStream *stream); + +extern RwTextureChunkInfo * +_rwTextureChunkInfoRead(RwStream *stream, + RwTextureChunkInfo *textureChunkInfo, + RwInt32 *bytesRead); + +/* Compatibility macro */ + +#define RwTextureChunkInfoRead(_stream, _textureChunkInfo, _bytesRead) \ + _rwTextureChunkInfoRead(_stream, _textureChunkInfo, _bytesRead) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babinfrm.h ---*/ +/**************************************************************************** + Global types + */ + +typedef struct rwFrameList rwFrameList; +struct rwFrameList +{ + RwFrame **frames; + RwInt32 numFrames; +}; + +/**************************************************************************** + Global Variables + */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Frame binary format */ + +extern RwInt32 +RwFrameRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); + +extern RwInt32 +RwFrameSetStreamAlwaysCallBack(RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); + + +extern rwFrameList * +_rwFrameListInitialize(rwFrameList *frameList, + RwFrame *frame); + +extern RwBool +_rwFrameListFindFrame(const rwFrameList *frameList, + const RwFrame *frame, + RwInt32 *npIndex); + +extern rwFrameList * +_rwFrameListDeinitialize(rwFrameList *frameList); + +extern RwUInt32 +_rwFrameListStreamGetSize(const rwFrameList *frameList); + +extern rwFrameList * +_rwFrameListStreamRead(RwStream *stream, + rwFrameList *fl); + +extern const rwFrameList * +_rwFrameListStreamWrite(const rwFrameList *frameList, + RwStream *stream); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Comparibility macros */ + +#define rwFrameListInitialize(frameList,frame) \ + _rwFrameListInitialize(frameList,frame) + +#define rwFrameListFindFrame(frameList, frame, index) \ + _rwFrameListFindFrame(frameList, frame, index) + +#define rwFrameListDeinitialize(frameList) \ + _rwFrameListDeinitialize(frameList) + +#define rwFrameListStreamGetSize(frameList) \ + _rwFrameListStreamGetSize(frameList) + +#define rwFrameListStreamRead(stream, fl) \ + _rwFrameListStreamRead(stream, fl) + +#define rwFrameListStreamWrite(frameList, stream) \ + _rwFrameListStreamWrite(frameList, stream) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/babbox.h ---*/ +/**************************************************************************** + Global types + */ + +typedef struct RwBBox RwBBox; +/** + * \ingroup datatypes + * \struct RwBBox + * This type represents a 3D axis-aligned bounding-box + * specified by the positions of two corners which lie on a diagonal. + * Typically used to specify a world bounding-box when the world is created + * + * \param sup Supremum vertex (contains largest values) + * \param inf Infimum vertex (contains smallest values) + * + * \see RpWorldCreate + */ +struct RwBBox +{ + /* Must be in this order */ + RwV3d sup; /**< Supremum vertex. */ + RwV3d inf; /**< Infimum vertex. */ +}; + +#if (!defined(RwBBoxAssign)) +#define RwBBoxAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwBBoxAssign)) */ + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +extern RwBBox *RwBBoxCalculate(RwBBox *boundBox, + const RwV3d *verts, + RwInt32 numVerts); +extern RwBBox *RwBBoxInitialize(RwBBox *boundBox, + const RwV3d *vertex); +extern RwBBox *RwBBoxAddPoint(RwBBox *boundBox, + const RwV3d *vertex); +extern RwBool RwBBoxContainsPoint(const RwBBox *boundBox, + const RwV3d *vertex); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/bacamera.h ---*/ + +/**************************************************************************** + Defines + */ + +/* Type ID */ +#define rwCAMERA 4 + + + +/**************************************************************************** + viewOffset)) + +#define RwCameraSetRasterMacro(_camera, _raster) \ + (((_camera)->frameBuffer = (_raster)), (_camera)) + +#define RwCameraSetRasterVoidMacro(_camera, _raster) \ +MACRO_START \ +{ \ + (_camera)->frameBuffer = (_raster); \ +} \ +MACRO_STOP + +#define RwCameraGetRasterMacro(_camera) \ + ((_camera)->frameBuffer) + +#define RwCameraSetZRasterMacro(_camera, _raster) \ + (((_camera)->zBuffer = (_raster)), (_camera)) + +#define RwCameraSetZRasterVoidMacro(_camera, _raster) \ +MACRO_START \ +{ \ + (_camera)->zBuffer = (_raster); \ +} \ +MACRO_STOP + +#define RwCameraGetZRasterMacro(_camera) \ + ((_camera)->zBuffer) + +#define RwCameraGetNearClipPlaneMacro(_camera) \ + ((_camera)->nearPlane) + +#define RwCameraGetFarClipPlaneMacro(_camera) \ + ((_camera)->farPlane) + +#define RwCameraSetFogDistanceMacro(_camera, _distance) \ + (((_camera)->fogPlane = (_distance)), (_camera)) + +#define RwCameraGetFogDistanceMacro(_camera) \ + ((_camera)->fogPlane) + +#define RwCameraGetCurrentCameraMacro() \ + ((RwCamera *)RWSRCGLOBAL(curCamera)) + +#define RwCameraGetProjectionMacro(_camera) \ + ((_camera)->projectionType) + +#define RwCameraGetViewWindowMacro(_camera) \ + (&((_camera)->viewWindow)) + +#define RwCameraGetViewMatrixMacro(_camera) \ + (&((_camera)->viewMatrix)) + +#define RwCameraSetFrameMacro(_camera, _frame) \ + (_rwObjectHasFrameSetFrame((_camera), (_frame)), (_camera)) + +#define RwCameraSetFrameVoidMacro(_camera, _frame) \ +MACRO_START \ +{ \ + _rwObjectHasFrameSetFrame((_camera), (_frame)); \ +} \ +MACRO_STOP + + +#define RwCameraGetFrameMacro(_camera) \ + ((RwFrame *)rwObjectGetParent((_camera))) + +#if !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +#define RwCameraGetViewOffset(_camera) \ + RwCameraGetViewOffsetMacro(_camera) + +#define RwCameraSetRaster(_camera, _raster) \ + RwCameraSetRasterMacro(_camera, _raster) + +#define RwCameraGetRaster(_camera) \ + RwCameraGetRasterMacro(_camera) + +#define RwCameraSetZRaster(_camera, _raster) \ + RwCameraSetZRasterMacro(_camera, _raster) + +#define RwCameraGetZRaster(_camera) \ + RwCameraGetZRasterMacro(_camera) + +#define RwCameraGetNearClipPlane(_camera) \ + RwCameraGetNearClipPlaneMacro(_camera) + +#define RwCameraGetFarClipPlane(_camera) \ + RwCameraGetFarClipPlaneMacro(_camera) + +#define RwCameraSetFogDistance(_camera, _distance) \ + RwCameraSetFogDistanceMacro(_camera, _distance) + +#define RwCameraGetFogDistance(_camera) \ + RwCameraGetFogDistanceMacro(_camera) + +#define RwCameraGetCurrentCamera() \ + RwCameraGetCurrentCameraMacro() + +#define RwCameraGetProjection(_camera) \ + RwCameraGetProjectionMacro(_camera) + +#define RwCameraGetViewWindow(_camera) \ + RwCameraGetViewWindowMacro(_camera) + +#define RwCameraGetViewMatrix(_camera) \ + RwCameraGetViewMatrixMacro(_camera) + +#define RwCameraSetFrame(_camera, _frame) \ + RwCameraSetFrameMacro(_camera, _frame) + +#define RwCameraGetFrame(_camera) \ + RwCameraGetFrameMacro(_camera) + +#endif /* !(defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup datatypes + * RwCameraClearMode + * Camera clear flags */ +enum RwCameraClearMode +{ + rwCAMERACLEARIMAGE = 0x1, /** used for the frustum callback stuff */ + RwUInt16 renderFrame; + RwUInt16 pad; + + /* The clip-planes making up the viewing frustum */ + RwFrustumPlane frustumPlanes[6]; + RwBBox frustumBoundBox; + + /* Points on the tips of the view frustum */ + RwV3d frustumCorners[8]; +}; +#endif /* (!defined(DOXYGEN)) */ + +/** + * \ingroup datatypes + * \typedef RwCameraCallBack + * \ref RwCameraCallBack type represents a function called from any camera + * iterator that may be implemented in plugins. This function should return a + * pointer to the current camera to indicate success. The callback may return + * NULL to terminate further callbacks on other cameras. + * + * \param camera Pointer to the current camera, supplied by iterator. + * \param data Pointer to developer-defined data structure. + */ +typedef RwCamera *(*RwCameraCallBack)(RwCamera *camera, void *data); + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + /* Rendering */ +extern RwCamera *RwCameraBeginUpdate(RwCamera * camera); +extern RwCamera *RwCameraEndUpdate(RwCamera * camera); + +extern RwCamera *RwCameraClear(RwCamera * camera, RwRGBA * colour, + RwInt32 clearMode); + +/* Displaying results */ +extern RwCamera *RwCameraShowRaster(RwCamera * camera, void *pDev, + RwUInt32 flags); + +/* Creation and destruction */ +extern RwBool RwCameraDestroy(RwCamera * camera); +extern RwCamera *RwCameraCreate(void); +extern RwCamera *RwCameraClone(RwCamera * camera); + +/* Offset */ +extern RwCamera *RwCameraSetViewOffset(RwCamera *camera, + const RwV2d *offset); + +/* View window */ +extern RwCamera *RwCameraSetViewWindow(RwCamera *camera, + const RwV2d *viewWindow); + +/* Projection */ +extern RwCamera *RwCameraSetProjection(RwCamera *camera, + RwCameraProjection projection); + +/* Clip planes */ +extern RwCamera *RwCameraSetNearClipPlane(RwCamera *camera, RwReal nearClip); +extern RwCamera *RwCameraSetFarClipPlane(RwCamera *camera, RwReal farClip); + +/* Attaching toolkits */ +extern RwInt32 RwCameraRegisterPlugin(RwInt32 size, + RwUInt32 pluginID, + RwPluginObjectConstructor + constructCB, + RwPluginObjectDestructor + destructCB, + RwPluginObjectCopy copyCB); +extern RwInt32 RwCameraGetPluginOffset(RwUInt32 pluginID); +extern RwBool RwCameraValidatePlugins(const RwCamera * camera); + +/* Frustum testing */ +extern RwFrustumTestResult RwCameraFrustumTestSphere(const RwCamera * + camera, + const RwSphere * + sphere); + +#if (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) + +/* Offset */ +extern const RwV2d *RwCameraGetViewOffset(const RwCamera *camera); + +/* Rasters */ +extern RwCamera *RwCameraSetRaster(RwCamera *camera, RwRaster *raster); +extern RwRaster *RwCameraGetRaster(const RwCamera *camera); +extern RwCamera *RwCameraSetZRaster(RwCamera *camera, RwRaster *zRaster); +extern RwRaster *RwCameraGetZRaster(const RwCamera *camera); + +/* Clip planes */ +extern RwReal RwCameraGetNearClipPlane(const RwCamera *camera); +extern RwReal RwCameraGetFarClipPlane(const RwCamera *camera); +extern RwCamera *RwCameraSetFogDistance(RwCamera *camera, RwReal fogDistance); +extern RwReal RwCameraGetFogDistance(const RwCamera *camera); + +extern RwCamera *RwCameraGetCurrentCamera(void); + +/* Projection */ +extern RwCameraProjection RwCameraGetProjection(const RwCamera *camera); + +/* View window */ +extern const RwV2d *RwCameraGetViewWindow(const RwCamera *camera); + +extern RwMatrix *RwCameraGetViewMatrix(RwCamera *camera); + +/* Frames */ +extern RwCamera *RwCameraSetFrame(RwCamera *camera, RwFrame *frame); +extern RwFrame *RwCameraGetFrame(const RwCamera *camera); +#endif /* (defined(RWDEBUG) || defined(RWSUPPRESSINLINE)) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/barwtyp.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/bacamval.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/bapipe.h ---*/ + +struct rwPipeGlobals +{ + RwFreeList *pipesFreeList; /* Save mallocs, use a freelist */ + RxRenderStateVector defaultRenderState; + RwLinkList allPipelines; /* Unused as of yet, meant to be used to keep track of all + * created pipelines (for CBs and maybe cleanup) */ + RwUInt32 maxNodesPerPipe; /* Initialised from _rxPipelineMaxNodes at startup. Used to + * allow conservative, single allocations during pipelock */ + + /* NOTE: Rw and RpWorld PowerPipe globals kept together for simplicity */ + + /* The current default pipelines (used if pipe == NULL for an object) */ + RxPipeline *currentAtomicPipeline; + RxPipeline *currentWorldSectorPipeline; + RxPipeline *currentMaterialPipeline; + /* Generic C-based pipes that run on all platforms + * - these are set as the current pipes at startup unless + * platform-specific pipes (below) are created */ + RxPipeline *genericAtomicPipeline; + RxPipeline *genericWorldSectorPipeline; + RxPipeline *genericMaterialPipeline; + /* Platforms that have their own non-generic pipelines + * (OPENGL, D3D7, SKY2, KAMUI2, DOLPHIN) put them here: */ + RxPipeline *platformAtomicPipeline; + RxPipeline *platformWorldSectorPipeline; + RxPipeline *platformMaterialPipeline; +#if (defined(SKY2_DRVMODEL_H)) + /* We have extra flavours of pipe under SKY2. + * PS2All and PS2AllMat are the defaults. + * - see RpWorldSectorSkyGetPS2AllPipeline, etc */ + RxPipeline *ps2ManagerAtomicPipeline; + RxPipeline *allInOneAtomicPipeline; + RxPipeline *vanillaAtomicPipeline; + RxPipeline *ps2ManagerWorldSectorPipeline; + RxPipeline *allInOneWorldSectorPipeline; + RxPipeline *vanillaWorldSectorPipeline; + RxPipeline *vanillaMaterialPipeline; +#endif /* (SKY2_DRVMODEL_H) */ + +}; + +typedef struct rwPipeGlobals rwPipeGlobals; + +#define RXPIPELINEGLOBAL(var) (RWPLUGINOFFSET(rwPipeGlobals, RwEngineInstance, _rxPipelineGlobalsOffset)->var) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwInt32 _rxPipelineGlobalsOffset; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/common/imrascnv.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/babincam.h ---*/ +/**************************************************************************** + Global types + */ + +/* Camera stream format */ + +/** + * \ingroup datatypes + * \typedef RwCameraChunkInfo + * + * \ref RwCameraChunkInfo is typedef'd to a structure that holds camera + * data. This should be considered an opaque type. Use the RwCamera + * API functions to access it. + */ + +typedef struct rwStreamCamera RwCameraChunkInfo; +typedef struct rwStreamCamera rwStreamCamera; +struct rwStreamCamera +{ + RwV2d viewWindow; + RwV2d viewOffset; + RwReal nearPlane, farPlane; + RwReal fogPlane; + RwUInt32 projection; +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Camera binary format */ +extern RwInt32 RwCameraRegisterPluginStream(RwUInt32 pluginID, + RwPluginDataChunkReadCallBack readCB, + RwPluginDataChunkWriteCallBack writeCB, + RwPluginDataChunkGetSizeCallBack getSizeCB); +extern RwInt32 RwCameraSetStreamAlwaysCallBack( + RwUInt32 pluginID, + RwPluginDataChunkAlwaysCallBack alwaysCB); +extern RwUInt32 RwCameraStreamGetSize(const RwCamera *camera); +extern RwCamera *RwCameraStreamRead(RwStream *stream); +extern const RwCamera *RwCameraStreamWrite(const RwCamera *camera, + RwStream *stream); +extern RwCameraChunkInfo * RwCameraChunkInfoRead(RwStream *stream, + RwCameraChunkInfo *cameraChunkInfo, + RwInt32 *bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWCORE_H */ diff --git a/rwsdk/include/d3d8/rwplcore.h b/rwsdk/include/d3d8/rwplcore.h new file mode 100644 index 00000000..152261cc --- /dev/null +++ b/rwsdk/include/d3d8/rwplcore.h @@ -0,0 +1,6080 @@ +/******************************************/ +/* */ +/* RenderWare(TM) Graphics Library */ +/* */ +/******************************************/ + +/* + * This file is a product of Criterion Software Ltd. + * + * This file is provided as is with no warranties of any kind and is + * provided without any obligation on Criterion Software Ltd. + * or Canon Inc. to assist in its use or modification. + * + * Criterion Software Ltd. and Canon Inc. will not, under any + * circumstances, be liable for any lost revenue or other damages + * arising from the use of this file. + * + * Copyright (c) 1999. Criterion Software Ltd. + * All Rights Reserved. + */ + +/************************************************************************* + * + * Filename: + * Automatically Generated on: Wed Jul 10 10:45:00 2002 + * + ************************************************************************/ + +#ifndef RWPLCORE_H +#define RWPLCORE_H + +/*--- System Header Files ---*/ +#include +#include +#include +#include + + +/*--- Automatically derived from: C:/daily/rwsdk/os/win/ostypes.h ---*/ +#ifndef WIN_OSTYPES_H +#define WIN_OSTYPES_H + +#define rwLITTLEENDIAN /* This is a little endian machine */ + +typedef long RwFixed; +typedef int RwInt32; +typedef unsigned int RwUInt32; +typedef short RwInt16; +typedef unsigned short RwUInt16; +typedef unsigned char RwUInt8; +typedef signed char RwInt8; + +#ifdef RWUNICODE +typedef wchar_t RwChar; +#else /* RWUNICODE */ +typedef char RwChar; +#endif /* RWUNICODE */ +typedef float RwReal; +typedef RwInt32 RwBool; + +#ifdef _MSC_VER +typedef __int64 RwInt64; +typedef unsigned __int64 RwUInt64; +#define RWZERO64 ((RwUInt64)0) +#else /* _MSC_VER */ + +typedef struct _RwUInt64 RwUInt64; +typedef struct _RwInt64 RwInt64; + +/* We'll do it with structures (can't do maths on these, but OK for allocation): */ +#ifdef rwBIGENDIAN +struct _RwUInt64 +{ + RwUInt32 top; + RwUInt32 bottom; +}; + +struct _RwInt64 +{ + RwInt32 top; + RwUInt32 bottom; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct _RwUInt64 +{ + RwUInt32 bottom; + RwUInt32 top; +}; + +struct _RwInt64 +{ + RwUInt32 bottom; + RwInt32 top; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ + +#define RWZERO64 { (RwUInt32)0, (RwUInt32)0 } +#endif /* _MSC_VER */ + +typedef struct _RwUInt128 RwUInt128; +typedef struct _RwInt128 RwInt128; + +/* We'll do it with structures + * (can't do maths on these, but OK for allocation): */ +#ifdef rwBIGENDIAN +struct _RwUInt128 +{ + RwUInt64 top; + RwUInt64 bottom; +}; + +struct _RwInt128 +{ + RwInt64 top; + RwUInt64 bottom; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct _RwUInt128 +{ + RwUInt64 bottom; + RwUInt64 top; +}; + +struct _RwInt128 +{ + RwUInt64 bottom; + RwInt64 top; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ + +#define RWZERO128 { RWZERO64, RWZERO64 } + +/* Limits of types */ +#define RwInt32MAXVAL 0x7FFFFFFF +#define RwInt32MINVAL 0x80000000 +#define RwUInt32MAXVAL 0xFFFFFFFF +#define RwUInt32MINVAL 0x00000000 +#define RwRealMAXVAL (RwReal)(3.40282347e+38) +#define RwRealMINVAL (RwReal)(1.17549435e-38) +#define RwInt16MAXVAL 0x7FFF +#define RwInt16MINVAL 0x8000 +#define RwUInt16MAXVAL 0xFFFF +#define RwUInt16MINVAL 0x0000 + +/* Structure alignment */ +#define RWALIGN(type, x) type /* nothing */ +#define rwMATRIXALIGNMENT sizeof(RwUInt32) +#define rwFRAMEALIGNMENT sizeof(RwUInt32) +#define rwV4DALIGNMENT sizeof(RwUInt32) + +#if (defined(_MSC_VER)) + +#if (defined(RWVERBOSE)) +#include +#pragma comment (lib , "advapi32.LIB") /* Registry functions */ + +/* + * registry code + */ + +#if (defined(RpWinRegGetDWordValue)) +#undef RpWinRegGetDWordValue +#endif /* (defined(RpWinRegGetDWordValue)) */ + +#define RpWinRegGetDWordValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = ((ERROR_SUCCESS == _status) && (REG_DWORD == _type)); \ + \ + if ((_result)) \ + { \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, \ + (BYTE *) (_val), &_size); \ + (_result) = (ERROR_SUCCESS == _status); \ + } \ +} \ +MACRO_STOP + +#if (defined(RpWinRegGetBinaryValue)) +#undef RpWinRegGetBinaryValue +#endif /* (defined(RpWinRegGetBinaryValue)) */ + +#define RpWinRegGetBinaryValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = \ + ((ERROR_SUCCESS == _status) && \ + (REG_BINARY == _type) && (0 < _size)); \ + \ + if ((_result)) \ + { \ + *(_val) = RwMalloc(sizeof(BYTE) * _size); \ + (_result) = (NULL != *(_val)); \ + \ + if ((_result)) \ + { \ + \ + _status = \ + RegQueryValueEx((_hKey), \ + (_name), 0, &_type, \ + (BYTE *) * (_val), &_size); \ + (_result =) (ERROR_SUCCESS == _status); \ + \ + if (!(_result)) \ + { \ + RwFree(*(_val)); \ + *(_val) = NULL; \ + } \ + \ + } \ + \ + } \ +} \ +MACRO_STOP + +#if (defined(RpWinRegGetStringValue)) +#undef RpWinRegGetStringValue +#endif /* (defined(RpWinRegGetStringValue)) */ + +#define RpWinRegGetStringValue(_result, _hKey, _name, _val) \ +MACRO_START \ +{ \ + DWORD _size; \ + DWORD _type; \ + LONG _status; \ + \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, NULL, &_size); \ + (_result) = \ + ((ERROR_SUCCESS == _status) && \ + (REG_SZ == _type) && (0 < _size)); \ + \ + if ((_result)) \ + { \ + \ + *(_val) = RwMalloc(sizeof(TCHAR) * _size); \ + (_result) = (NULL != *(_val)); \ + \ + if ((_result)) \ + { \ + _status = \ + RegQueryValueEx((_hKey), (_name), 0, &_type, \ + (BYTE *) * (_val), &_size); \ + (_result) = (ERROR_SUCCESS == _status); \ + \ + if (!(_result)) \ + { \ + RwFree(*(_val)); \ + *(_val) = NULL; \ + } \ + } \ + } \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#define RpWinRegCloseKey(hKey) \ +MACRO_START \ +{ \ + RegCloseKey(hKey); \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#define RpWinRegOpenMachineKey(result) \ +MACRO_START \ +{ \ + static const TCHAR RenderWareKey[] = \ + "Software\\Criterion\\RenderWare"; \ + DWORD disposition; \ + LONG status = \ + RegCreateKeyEx(HKEY_LOCAL_MACHINE, RenderWareKey, 0, \ + REG_NONE, REG_OPTION_NON_VOLATILE, \ + KEY_READ | KEY_WRITE, \ + NULL, &result, &disposition); \ + \ + if (status != ERROR_SUCCESS) \ + { \ + result = NULL; \ + } \ +} \ +MACRO_STOP + +/* ------------------------------------------------------------------- */ + +#if (defined(RWGETWINREGDWORD)) +#undef RWGETWINREGDWORD +#endif /* (defined(RWGETWINREGDWORD)) */ + +#define RWGETWINREGDWORD(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetDWordValue(success, hKey, match, \ + &result); \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(RWGETWINREGBINARY)) +#undef RWGETWINREGBINARY +#endif /* (defined(RWGETWINREGBINARY)) */ + +#define RWGETWINREGBINARY(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + result = NULL; \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetBinaryValue(success, hKey, match, \ + &result, NULL); \ + \ + if (!success) \ + result = NULL; \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(RWGETWINREGSTRING)) +#undef RWGETWINREGSTRING +#endif /* (defined(RWGETWINREGSTRING)) */ + +#define RWGETWINREGSTRING(result, match) \ +MACRO_START \ +{ \ + HKEY hKey; \ + \ + result = NULL; \ + RpWinRegOpenMachineKey(hKey); \ + if (hKey) \ + { \ + RwBool success; \ + \ + RpWinRegGetStringValue(success, hKey, match, \ + &result); \ + \ + if (!success) \ + result = NULL; \ + \ + RpWinRegCloseKey(hKey); \ + } \ +} \ +MACRO_STOP + +#if (defined(_DEBUG)) + +#if (defined(RWREGSETBREAKALLOC)) +#undef RWREGSETBREAKALLOC +#endif /* (defined(RWREGSETBREAKALLOC)) */ + +#define RWREGSETBREAKALLOC(_name) \ +MACRO_START \ +{ \ + char _message[256]; \ + long _lBreakAlloc = -1; \ + \ + RWGETWINREGDWORD(_lBreakAlloc, _name); \ + \ + RWCRTSETBREAKALLOC(_lBreakAlloc); \ + \ + _snprintf(_message, sizeof(_message), \ + "%s(%d): RWCRTSETBREAKALLOC(%ld)\n", \ + __FILE__, __LINE__, \ + _lBreakAlloc); \ + OutputDebugString(_message); \ + \ +} \ +MACRO_STOP + +#if (defined(RWREGSETDEBUGTRACE)) +#undef RWREGSETDEBUGTRACE +#endif /* (defined(RWREGSETDEBUGTRACE)) */ + +#define RWREGSETDEBUGTRACE(_name) \ +MACRO_START \ +{ \ + char _message[256]; \ + long _lDebugtrace = 0; \ + \ + RWGETWINREGDWORD(_lDebugtrace, _name); \ + \ + RwDebugSetTraceState(_lDebugtrace); \ + \ + _snprintf(_message, sizeof(_message), \ + "%s(%d): RwDebugSetTraceState(%ld)\n", \ + __FILE__, __LINE__, \ + _lDebugtrace); \ + OutputDebugString(_message); \ + \ +} \ +MACRO_STOP + +#if (defined(_CRTDBG_FLAGS)) +#undef _CRTDBG_FLAGS +#endif /* (defined(_CRTDBG_FLAGS)) */ + +#define _CRTDBG_FLAGS \ +( _CRTDBG_ALLOC_MEM_DF || /* Turn on the debug heap allocations \ + * and use the memory block identifiers. \ + * This is the only flag that's on by default. */ \ + _CRTDBG_CHECK_ALWAYS_DF || /* Check and validate all memory \ + * on each allocation and deallocation request. \ + * Setting this flag on is what catches the \ + * under and overwrites \ + * so it is very important to \ + * get it turned on. */ \ + _CRTDBG_CHECK_CRT_DF || /* Include _CRT_BLOCK memory allocations \ + * in all leak detection and state differences. */ \ + _CRTDBG_DELAY_FREE_MEM_DF || /* Instead of truly freeing memory, \ + * keep the block allocated and \ + * in the internal heap list. \ + * The blocks are filled with the value0xDD \ + * so you know the memory is freed when \ + * looking at it in the debugger. \ + * By also not freeing the memory, \ + * this can help provide stress \ + * conditions for the program. */ \ + _CRTDBG_LEAK_CHECK_DF) /* Do memory leak checking at \ + * the end of the program. */ + +#endif /* (defined(_DEBUG)) */ +#endif /* (defined(RWVERBOSE)) */ + +#include +/* + * Keep true calls to these functions since + * some x86 runtime libraries do not support _CIpow() etc + */ +#pragma function( acos, asin, cosh, fmod, pow, sinh , tanh ) + +#if (!defined(RWINT32FROMFLOAT)) + +static __inline RwInt32 +int32fromreal(RwReal x) +{ + RwInt16 savemode; + RwInt16 workmode; + RwInt32 res; + + _asm + { + fnstcw savemode ; get fpu mode + fld dword ptr[x] ; load rwreal x + + mov ax,savemode ; put fpu mode in register + or ah,0ch ; or-in truncate mode + + mov workmode,ax ; make ready to set fpu mode + fldcw workmode ; set fpu to truncate mode + fistp dword ptr[res]; store the rwint32eger result + fldcw savemode ; restore fpu mode + } + + return res; +} +#define RwInt32FromRealMacro(x) int32fromreal(x) + +#endif /* (!defined(RWINT32FROMFLOAT)) */ + +#if (!defined(NOASM)) +static __inline RwUInt32 +RwFastRealToUInt32(RwReal x) +{ + RwUInt32 res; + + __asm FLD DWord Ptr[x]; + __asm FISTP DWord Ptr[res]; + + return(res); +} +#endif /* (defined(NOASM)) */ + +#endif /* (defined(_MSC_VER)) */ + +#endif /* WIN_OSTYPES_H */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bamath.h ---*/ + +/**************************************************************************** + Defines + */ + +#if (!defined(RwInt32FromRealMacro)) +#define RwInt32FromRealMacro(x) \ + ((RwInt32)(x)) +#endif /* (!defined(RwInt32FromRealMacro)) */ + +#if (!defined(RwFastRealToUInt32)) +#define RwFastRealToUInt32(_x) \ + ((RwUInt32)RwInt32FromRealMacro(((RwReal)(_x)))) +#endif /* (!defined(RwFastRealToUInt32)) */ + +/* + * Ensure inclusion of prototypes for single precison maths functions + * e.g. from + * /usr/local/sce/ee/gcc/ee/include/math.h + * /Program Files/Intel/Compiler4.0/include/mathf.h + */ + +#if (defined(__ICL)) + +#if (defined(RWVERBOSE)) + +/* + * See + * http://www.eskimo.com/~scs/C-faq/q11.17.html + */ + +#define _STRINGIFY(X) #X +#define _STRINGIFY_EXP(X) _STRINGIFY(X) + +#pragma message ("Intel Compiler Version " _STRINGIFY_EXP(__ICL) ":" __FILE__ "(" _STRINGIFY_EXP(__LINE__) ")\n") +#pragma comment ( user, "comment:" "Intel Compiler Version " _STRINGIFY_EXP(__ICL) ":" __FILE__ "(" _STRINGIFY_EXP(__LINE__) ")\n") + +#endif /* (defined(RWVERBOSE)) */ + +#if (400 <= __ICL) +#if (defined(__cplusplus)) +#define _INC_MATH +#endif /* (defined(__cplusplus)) */ +#include +#else /* (400 < __ICL) */ +#undef RW_USE_SPF +#endif /* (400 < __ICL) */ + +#endif /* (defined(__ICL)) */ + +#include + +#define _RW_C1 ( (float) 4.1666667908e-02 ) +#define _RW_C2 ( (float)-1.3888889225e-03 ) +#define _RW_C3 ( (float) 2.4801587642e-05 ) +#define _RW_C4 ( (float)-2.7557314297e-07 ) +#define _RW_C5 ( (float) 2.0875723372e-09 ) +#define _RW_C6 ( (float)-1.1359647598e-11 ) +#define _RW_S1 ( (float)-1.6666667163e-01 ) +#define _RW_S2 ( (float) 8.3333337680e-03 ) +#define _RW_S3 ( (float)-1.9841270114e-04 ) +#define _RW_S4 ( (float) 2.7557314297e-06 ) +#define _RW_S5 ( (float)-2.5050759689e-08 ) +#define _RW_S6 ( (float) 1.5896910177e-10 ) +#define _RW_one ( (float) 1.0000000000e+00 ) +#define _RW_pS0 ( (float) 1.6666667163e-01 ) +#define _RW_pS1 ( (float)-3.2556581497e-01 ) +#define _RW_pS2 ( (float) 2.0121252537e-01 ) +#define _RW_pS3 ( (float)-4.0055535734e-02 ) +#define _RW_pS4 ( (float) 7.9153501429e-04 ) +#define _RW_pS5 ( (float) 3.4793309169e-05 ) +#define _RW_pi ( (float) 3.1415925026e+00 ) +#define _RW_pi_tol ( (float) 0.0312500000e+00 ) +#define _RW_pio2_hi ( (float) 1.5707962513e+00 ) +#define _RW_pio2_lo ( (float) 7.5497894159e-08 ) +#define _RW_qS1 ( (float)-2.4033949375e+00 ) +#define _RW_qS2 ( (float) 2.0209457874e+00 ) +#define _RW_qS3 ( (float)-6.8828397989e-01 ) +#define _RW_qS4 ( (float) 7.7038154006e-02 ) + +#define RwCosMinusPiToPiMacro(result, x) \ +MACRO_START \ +{ \ + const float z = x * x; \ + const float r = ( z * (_RW_C1 + \ + z * (_RW_C2 + \ + z * (_RW_C3 + \ + z * (_RW_C4 + \ + z * (_RW_C5 + \ + z * _RW_C6)))))); \ + result = (_RW_one - ((float) 0.5 * z - (z * r ))); \ +} \ +MACRO_STOP + +#define RwSinMinusPiToPiMacro(result, x) \ +do \ +{ \ + const float z = x * x; \ + const float v = z * x; \ + const float r = ( _RW_S2 + \ + z * (_RW_S3 + \ + z * (_RW_S4 + \ + z * (_RW_S5 + \ + z * _RW_S6))) ); \ + result = x + v * (_RW_S1 + z * r); \ +} \ +while(0) + +typedef union _rwIEEEFloatShapeType _rwIEEEFloatShapeType; +union _rwIEEEFloatShapeType +{ + float value; + unsigned int word; +}; + +#define _RW_GET_FLOAT_WORD(i,d) \ +do { \ + _rwIEEEFloatShapeType gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define _RW_SET_FLOAT_WORD(d,i) \ +do { \ + _rwIEEEFloatShapeType sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +#define RwIEEEACosfMacro(result, x) \ +do \ +{ \ + float z, p, q, r, w, s, c, df; \ + int hx, ix; \ + \ + _RW_GET_FLOAT_WORD(hx, x); \ + ix = hx & 0x7fffffff; \ + if (ix >= 0x3f800000) \ + { /* |x|>=1 */ \ + if (hx > 0) \ + { \ + /* acos(1) = 0 */ \ + result = (0.0); \ + } \ + else \ + { \ + /* acos(-1)= _RW_pi */ \ + result = (_RW_pi + (float) 2.0 * _RW_pio2_lo); \ + } \ + \ + } \ + else if (ix < 0x3f000000) \ + { /* |x| < 0.5 */ \ + if (ix <= 0x23000000) \ + { \ + /*if |x|<2**-57 */ \ + result = (_RW_pio2_hi + _RW_pio2_lo); \ + } \ + else \ + { \ + z = x * x; \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + \ + z * (_RW_qS3 + z * _RW_qS4))); \ + r = p / q; \ + result = (_RW_pio2_hi - (x - (_RW_pio2_lo - x * r))); \ + } \ + \ + } \ + else if (hx < 0) \ + { /* x < -0.5 */ \ + z = (_RW_one + x) * (float) 0.5; \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + z * (_RW_qS3 + z * _RW_qS4))); \ + rwSqrtMacro(&s, z); \ + r = p / q; \ + w = r * s - _RW_pio2_lo; \ + result = (_RW_pi - (float) 2.0 * (s + w)); \ + } \ + else \ + { /* x > 0.5 */ \ + int idf; \ + \ + z = (_RW_one - x) * (float) 0.5; \ + rwSqrtMacro(&s, z); \ + df = s; \ + _RW_GET_FLOAT_WORD(idf, df); \ + _RW_SET_FLOAT_WORD(df, idf & 0xfffff000); \ + c = (z - df * df) / (s + df); \ + p = z * (_RW_pS0 + \ + z * (_RW_pS1 + \ + z * (_RW_pS2 + \ + z * (_RW_pS3 + \ + z * (_RW_pS4 + z * _RW_pS5))))); \ + q = _RW_one + z * (_RW_qS1 + \ + z * (_RW_qS2 + z * (_RW_qS3 + z * _RW_qS4))); \ + r = p / q; \ + w = r * s + c; \ + result = ((float) 2.0 * (df + w)); \ + } \ +} \ +while(0) + +#if (defined(RW_USE_SPF)) + +#define RwACos(_x) acosf(_x) +#define RwACosh(_x) acoshf(_x) +#define RwASin(_x) asinf(_x) +#define RwASinh(_x) asinhf(_x) + +#if (!defined(__ICL)) +/* + * No SPF version in + * Program Files/Intel/compilerXXX/include/mathf.h + * of atan2() + */ +#define RwATan2(_x, _y) atan2f(_x, _y) +#endif /* (!defined(__ICL)) */ + +#define RwATan(_x) atanf(_x) +#define RwATanh(_x) atanhf(_x) +#define RwCabs() cabsf() +#define RwCbrt(_x) cbrtf(_x) +#define RwCeil(_x) ceilf(_x) +#define RwCopysign(_x, _y) copysignf(_x, _y) +#define RwCos(_x) cosf(_x) +#define RwCosh(_x) coshf(_x) +#define RwDrem(_x, _y) dremf(_x, _y) +#define RwErfc(_x) erfcf(_x) +#define RwErf(_x) erff(_x) +#define RwExp(_x) expf(_x) +#define RwExpm1(_x) expm1f(_x) +#define RwFinite(_x) finitef(_x) +#define RwIlogb(_x) ilogbf(_x) +#define RwIsinf(_x) isinff(_x) +#define RwIsnan(_x) isnanf(_x) +#define RwFabs(_x) fabsf(_x) +#define RwFloor(_x) floorf(_x) +#define RwFmod(_x, _y) fmodf(_x, _y) +#define RwFrexp(_x, _iptr) frexpf(_x, _iptr) +#define RwGamma(_x) gammaf(_x) +#define RwGammaf_(_x, _iptr) gammaf_r(_x, _iptr) +#define RwHypot(_x, _y) hypotf(_x, _y) +#define RwInfinity() infinityf() +#define RwJ0(_x) j0f(_x) +#define RwJ1(_x) j1f(_x) +#define RwJn(_i, _x) jnf(_i, _x) +#define RwLdexp(_x, _i) ldexpf(_x, _i) +#define RwLgamma(_x) lgammaf(_x) +#define RwLgammaf_(_x, _iptr) lgammaf_r(_x, _iptr) +#define RwLog10(_x) log10f(_x) +#define RwLog1p(_x) log1pf(_x) +#define RwLog(_x) logf(_x) +#define RwModf(_x, _y) modff(_x, _y) +#define RwNan() nanf() +#define RwNextafter(_x, _y) nextafterf(_x, _y) +#define RwPow(_x, _y) powf(_x, _y) +#define RwRemainder(_x, _y) remainderf(_x, _y) +#define RwRint(_x) rintf(_x) +#define RwScalbn(_x, _i) scalbnf(_x, _i) +#define RwSin(_x) sinf(_x) +#define RwSinh(_x) sinhf(_x) +/* rwSqrtMacro/rwInvSqrtMacro are overloaded in drvmodel.h + * (if they are at all) and wrapped as func/macro below */ +#define RwTan(_x) tanf(_x) +#define RwTanh(_x) tanhf(_x) +#define RwY0(_x) y0f(_x) +#define RwY1(_x) y1f(_x) +#define RwYn(_i, _x) ynf(_i, _x) + +#endif /* (defined(RW_USE_SPF)) */ + +#if (!defined(RwACos)) +#define RwACos(_x) acos(_x) +#endif /* (!defined(RwACos)) */ +#if (!defined(RwACosh)) +#define RwACosh(_x) acosh(_x) +#endif /* (!defined(RwACosh)) */ +#if (!defined(RwASin)) +#define RwASin(_x) asin(_x) +#endif /* (!defined(RwASin)) */ +#if (!defined(RwASinh)) +#define RwASinh(_x) asinh(_x) +#endif /* (!defined(RwASinh)) */ +#if (!defined(RwATan2)) +#define RwATan2(_x, _y) atan2(_x, _y) +#endif /* (!defined(RwATan2)) */ +#if (!defined(RwATan)) +#define RwATan(_x) atan(_x) +#endif /* (!defined(RwATan)) */ +#if (!defined(RwATanh)) +#define RwATanh(_x) atanh(_x) +#endif /* (!defined(RwATanh)) */ +#if (!defined(RwCabs)) +#define RwCabs() cabs() +#endif /* (!defined(RwCabs)) */ +#if (!defined(RwCbrt)) +#define RwCbrt(_x) cbrt(_x) +#endif /* (!defined(RwCbrt)) */ +#if (!defined(RwCeil)) +#define RwCeil(_x) ceil(_x) +#endif /* (!defined(RwCeil)) */ +#if (!defined(RwCopysign)) +#define RwCopysign(_x, _y) copysign(_x, _y) +#endif /* (!defined(RwCopysign)) */ +#if (!defined(RwCos)) +#define RwCos(_x) cos(_x) +#endif /* (!defined(RwCos)) */ +#if (!defined(RwCosh)) +#define RwCosh(_x) cosh(_x) +#endif /* (!defined(RwCosh)) */ +#if (!defined(RwDrem)) +#define RwDrem(_x, _y) drem(_x, _y) +#endif /* (!defined(RwDrem)) */ +#if (!defined(RwErfc)) +#define RwErfc(_x) erfc(_x) +#endif /* (!defined(RwErfc)) */ +#if (!defined(RwEr)) +#define RwEr(_x) erf(_x) +#endif /* (!defined(RwEr)) */ +#if (!defined(RwExp)) +#define RwExp(_x) exp(_x) +#endif /* (!defined(RwExp)) */ +#if (!defined(RwExpm1)) +#define RwExpm1(_x) expm1(_x) +#endif /* (!defined(RwExpm1)) */ +#if (!defined(RwFinite)) +#define RwFinite(_x) finite(_x) +#endif /* (!defined(RwFinite)) */ +#if (!defined(RwIlogb)) +#define RwIlogb(_x) ilogb(_x) +#endif /* (!defined(RwIlogb)) */ +#if (!defined(RwIsin)) +#define RwIsin(_x) isinf(_x) +#endif /* (!defined(RwIsin)) */ +#if (!defined(RwIsnan)) +#define RwIsnan(_x) isnan(_x) +#endif /* (!defined(RwIsnan)) */ +#if (!defined(RwFabs)) +#define RwFabs(_x) fabs(_x) +#endif /* (!defined(RwFabs)) */ +#if (!defined(RwFloor)) +#define RwFloor(_x) floor(_x) +#endif /* (!defined(RwFloor)) */ +#if (!defined(RwFmod)) +#define RwFmod(_x, _y) fmod(_x, _y) +#endif /* (!defined(RwFmod)) */ +#if (!defined(RwFrexp)) +#define RwFrexp(_x, _iptr) frexp(_x, _iptr) +#endif /* (!defined(RwFrexp)) */ +#if (!defined(RwGamma)) +#define RwGamma(_x) gamma(_x) +#endif /* (!defined(RwGamma)) */ +#if (!defined(RwGammaf_)) +#define RwGammaf_(_x, _iptr) gammaf_r(_x, _iptr) +#endif /* (!defined(RwGammaf_)) */ +#if (!defined(RwHypot)) +#define RwHypot(_x, _y) hypot(_x, _y) +#endif /* (!defined(RwHypot)) */ +#if (!defined(RwInfinity)) +#define RwInfinity() infinity() +#endif /* (!defined(RwInfinity)) */ +#if (!defined(RwJ0)) +#define RwJ0(_x) j0(_x) +#endif /* (!defined(RwJ0)) */ +#if (!defined(RwJ1)) +#define RwJ1(_x) j1(_x) +#endif /* (!defined(RwJ1)) */ +#if (!defined(RwJn)) +#define RwJn(_i, _x) jn(_i, _x) +#endif /* (!defined(RwJn)) */ +#if (!defined(RwLdexp)) +#define RwLdexp(_x, _i) ldexp(_x, _i) +#endif /* (!defined(RwLdexp)) */ +#if (!defined(RwLgamma)) +#define RwLgamma(_x) lgamma(_x) +#endif /* (!defined(RwLgamma)) */ +#if (!defined(RwLgammaf_)) +#define RwLgammaf_(_x, _iptr) lgammaf_r(_x, _iptr) +#endif /* (!defined(RwLgammaf_)) */ +#if (!defined(RwLog10)) +#define RwLog10(_x) log10(_x) +#endif /* (!defined(RwLog10)) */ +#if (!defined(RwLog1p)) +#define RwLog1p(_x) log1p(_x) +#endif /* (!defined(RwLog1p)) */ +#if (!defined(RwLog)) +#define RwLog(_x) log(_x) +#endif /* (!defined(RwLog)) */ +#if (!defined(RwMod)) +#define RwMod(_x, _y) mod(_x, _y ) +#endif /* (!defined(RwMod)) */ +#if (!defined(RwNan)) +#define RwNan() nan() +#endif /* (!defined(RwNan)) */ +#if (!defined(RwNextafter)) +#define RwNextafter(_x, _y) nextafter(_x, _y) +#endif /* (!defined(RwNextafter)) */ +#if (!defined(RwPow)) +#define RwPow(_x, _y) pow(_x, _y) +#endif /* (!defined(RwPow)) */ +#if (!defined(RwRemainder)) +#define RwRemainder(_x, _y) remainder(_x, _y) +#endif /* (!defined(RwRemainder)) */ +#if (!defined(RwRint)) +#define RwRint(_x) rint(_x) +#endif /* (!defined(RwRint)) */ +#if (!defined(RwScalbn)) +#define RwScalbn(_x, _i) scalbn(_x, _i) +#endif /* (!defined(RwScalbn)) */ +#if (!defined(RwSin)) +#define RwSin(_x) sin(_x) +#endif /* (!defined(RwSin)) */ +#if (!defined(RwSinh)) +#define RwSinh(_x) sinh(_x) +#endif /* (!defined(RwSinh)) */ +#if (!defined(rwSqrt)) +/* NOTE: this is overloaded in drvmodel.h for some targets (SKY2 and XBOX atm) + * [we do in fact do overload w/ sqrtf there, if RW_USE_SPF, + * for D3D7, D3D8, OpenGL and SoftRas] */ +#define rwSqrt(_result, _x) rwSqrtMacro(_result, _x) +#endif /* (!defined(rwSqrt)) */ +#if (!defined(rwInvSqrt)) +/* NOTE: this is overloaded in drvmodel.h for some targets (SKY2 and XBOX atm) + * [we do in fact do overload w/ (1 / sqrtf) there, if RW_USE_SPF, + * for D3D7, D3D8, OpenGL and SoftRas] */ +#define rwInvSqrt(_recip, _x) rwInvSqrtMacro(_recip, _x) +#endif /* (!defined(rwInvSqrt)) */ +#if (!defined(RwTan)) +#define RwTan(_x) tan(_x) +#endif /* (!defined(RwTan)) */ +#if (!defined(RwTanh)) +#define RwTanh(_x) tanh(_x) +#endif /* (!defined(RwTanh)) */ +#if (!defined(RwY0)) +#define RwY0(_x) y0(_x) +#endif /* (!defined(RwY0)) */ +#if (!defined(RwY1)) +#define RwY1(_x) y1(_x) +#endif /* (!defined(RwY1)) */ +#if (!defined(RwYn)) +#define RwYn(_i, _x) yn(_i, _x) +#endif /* (!defined(RwYn)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/batypes.h ---*/ +#define rwLIBRARYBASEVERSION 0x31000 +#define rwLIBRARYCURRENTVERSION 0x33002 + +/* + * RWBUILDNUMBER + * This 16-bit int will be externally defined in an official build, and + * is used to construct chunk header library ID when streaming out. All + * unofficial builds will be stamped with the following:- + */ +#if !defined(RWBUILDNUMBER) +#define RWBUILDNUMBER 0xffff +#endif + +/* IMPORTANT: + * The following Doxygen comment MUST be copied into RwCore.h, + * so don't move it from here. */ + +/** + * \ingroup rwcore + * \page rwcoreoverview Core Library Overview + * + * LIBRARY: rwcore.lib + * HEADER: rwcore.h + * + * This library provides the fundamental RenderWare features. + * + * When creating a RenderWare application, this library must always be + * linked. + * + * Functionality includes: + * \li Immediate Modes (2D \ref rwim2d and 3D \ref rwim3d ) + * \li Plugin Management + * \li Base Datatypes + * \li Cameras \ref rwcamera + * \li Frames \ref rwframe + * \li the RenderWare Engine \ref rwengine + * + * RenderWare uses an object-oriented design philosophy, so this + * documentation is split across a number of objects. + * + * These objects are implemented in C, so C terminology is generally + * used, rather than C++ -- hence 'functions' instead of 'methods' and + * 'elements' instead of 'members'. + * + * If you are new to RenderWare programming, please read through the + * supplied User Guide. The RenderWare Engine \ref rwengine API is + * usually the starting point for new developers. + */ + + +#if (!defined(RWFORCEENUMSIZEINT)) +#define RWFORCEENUMSIZEINT ((RwInt32)((~((RwUInt32)0))>>1)) +#endif /* (!defined(RWFORCEENUMSIZEINT)) */ + +/* + * See + * http://www.eskimo.com/~scs/C-faq/q11.17.html + */ + +#define RW_STRINGIFY(X) #X +#define RW_STRINGIFY_EXPANDED(X) RW_STRINGIFY(X) + +/**************************************************************************** + Attributes + */ + +#if (defined(__GNUC__)) + +/* See http://www.gnu.org/software/gcc/onlinedocs/gcc_4.html#SEC91 */ + +#if (!(defined(__cplusplus) || defined(__MWERKS__) || defined(__RWUNUSED__))) +#define __RWUNUSED__ __attribute__ ((unused)) +#endif /* (!(defined(__cplusplus) || defined(__MWERKS__) || defined(__RWUNUSED__))) */ + +#if (!(defined(__RWUNUSEDRELEASE__) || defined(RWVALIDATEPARAM))) +#if (!( defined(__cplusplus) || defined(__MWERKS__) || defined(RWDEBUG))) +#define __RWUNUSEDRELEASE__ __attribute__ ((unused)) +#endif /* (!(defined(__cplusplus) || defined(__MWERKS__) || defined(RWDEBUG))) */ +#endif /* (!(defined(__RWUNUSEDRELEASE__) || defined(RWVALIDATEPARAM))) */ + +#if (!defined(__RWFORMAT__)) +#define __RWFORMAT__(_archetype, _string_index, _first_to_check) \ + __attribute__ ((format (_archetype, _string_index, _first_to_check))) +#endif /* (!defined(__RWFORMAT__)) */ + +#endif /* (defined(__GNUC__)) */ + +#if (!defined(__RWUNUSED__)) +#define __RWUNUSED__ /* No op */ +#endif /* (!defined(__RWUNUSED__)) */ + +#if (!defined(__RWUNUSEDRELEASE__)) +#define __RWUNUSEDRELEASE__ /* No op */ +#endif /* (!defined(__RWUNUSEDRELEASE__)) */ + +#if (!defined(__RWFORMAT__)) +#define __RWFORMAT__(_archetype, _string_index, _first_to_check) /* No op */ +#endif /* (!defined(__RWFORMAT__)) */ + +/**************************************************************************** + Calling conventions + */ + +#if (defined(WIN32)) +#define RWASMCALL __cdecl +#define RWASMAPI(TYPE) TYPE RWASMCALL +#endif /* (defined(WIN32)) */ + +#if (!defined(RWASMCALL)) +#define RWASMCALL /* No op */ +#endif /* (!defined(RWASMCALL)) */ + +#if (!defined(RWASMAPI)) +#define RWASMAPI(TYPE) TYPE +#endif /* (!defined(RWASMAPI)) */ + + +/* Maximum number of nested contexts */ +#define rwMAXPIPECONTEXT 10 + + +/**************************************************************************** + Macro wrappers. These are needed everywhere. + */ + +#ifndef MACRO_START +#define MACRO_START do +#endif /* MACRO_START */ + +#ifndef MACRO_STOP +#define MACRO_STOP while(0) +#endif /* MACRO_STOP */ + +/**************************************************************************** + Types needed everywhere + */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE 0 + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE !FALSE + +/**************************************************************************** + MS VC/C++ Specific + */ + +#if (defined(_MSC_VER)) +#if (_MSC_VER>=1000) + + +/* + * Check for correct compiler version + */ +#define RW_MSC_VER 1200 + +#if (0 && !defined(RW_NO_COMPILER_CHECK)) +#if (_MSC_VER != RW_MSC_VER ) +# pragma message (__FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) "):" "\n This compiler is a different version (" RW_STRINGIFY_EXPANDED(_MSC_VER) ")\n to the compiler used to build the RenderWare product libraries (" RW_STRINGIFY_EXPANDED(RW_MSC_VER) ") \n To turn off this warning please define RW_NO_COMPILER_CHECK " ) +# pragma comment ( user, "comment:" __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) "):" "\n This compiler is a different version (" RW_STRINGIFY_EXPANDED(_MSC_VER) ")\n to the compiler used to build the RenderWare product libraries (" RW_STRINGIFY_EXPANDED(RW_MSC_VER) ") \n To turn off this warning please define RW_NO_COMPILER_CHECK " ) +#endif /* (_MSC_VER != RW_MSC_VER ) */ +#endif /* (0 && !defined(RW_NO_COMPILER_CHECK)) */ + +/* + * Output some compiler messages and object file comments + */ + +#pragma comment ( compiler ) + +#pragma comment ( user, "comment:" __DATE__" " __TIME__ " - " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ")") +#pragma comment ( user, "comment:" " _MSC_VER==" RW_STRINGIFY_EXPANDED(_MSC_VER) "; _M_IX86==" RW_STRINGIFY_EXPANDED(_M_IX86)) +#if (defined(rwLIBRARYCURRENTVERSION)) +#pragma comment ( user, "comment:" "rwLIBRARYCURRENTVERSION:" RW_STRINGIFY_EXPANDED(rwLIBRARYCURRENTVERSION) ) +#endif /* (defined(rwLIBRARYCURRENTVERSION)) */ + +#if (defined(RWDEBUG) && defined(RWVERBOSE)) + +/* #include */ +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include + +#pragma message (__DATE__" " __TIME__ " - " __FILE__ "(" RW_STRINGIFY_EXPANDED(__LINE__) ")" ) +#pragma message ("_MSC_VER==" RW_STRINGIFY_EXPANDED(_MSC_VER) "; _M_IX86==" RW_STRINGIFY_EXPANDED(_M_IX86)) + +#if (defined(rwLIBRARYCURRENTVERSION)) +#pragma message ( "rwLIBRARYCURRENTVERSION:" RW_STRINGIFY_EXPANDED(rwLIBRARYCURRENTVERSION) ) +#endif /* (defined(rwLIBRARYCURRENTVERSION)) */ + +#endif /* (defined(RWDEBUG) && defined(RWVERBOSE) ) */ + +#endif /* (_MSC_VER>=1000) */ +#endif /* (defined(_MSC_VER)) */ + +/*******************/ +/* Primitive types */ +/*******************/ + +/* String construction stuff (gets us UNICODE support) */ +#ifdef RWUNICODE +#define _RWSTRING(x) L ## x +#else /* RWUNICODE */ +#define _RWSTRING(x) x +#endif /* RWUNICODE */ +#define RWSTRING(x) _RWSTRING(x) + +/* NB volatile keyword required for VC5.0 to ensure a reload - AMB */ +typedef union RwSplitBits RwSplitBits; +union RwSplitBits +{ + RwReal nReal; + volatile RwInt32 nInt; + volatile RwUInt32 nUInt; +}; + +typedef struct RwSplitFixed RwSplitFixed; + +#ifdef rwBIGENDIAN +struct RwSplitFixed +{ + RwInt16 integral; + RwUInt16 fractional; +}; + +#else /* rwBIGENDIAN */ +#ifdef rwLITTLEENDIAN +struct RwSplitFixed +{ + RwUInt16 fractional; + RwInt16 integral; +}; + +#else /* rwLITTLEENDIAN */ +#error "ENDIAN-ness undefined!" +#endif /* rwLITTLEENDIAN */ +#endif /* rwBIGENDIAN */ + +typedef union RwUnionReal RwUnionReal; +union RwUnionReal /* MSB is sign bit in any circumstance */ +{ + RwReal real; /* 4 bytes interpreted as RwReal */ + float floating; /* 4 bytes interpreted as float */ + RwFixed fixed; /* 4 bytes interpreted as 16:16 fixed */ + RwSplitFixed splitfixed; /* 4 bytes interpreted as 16:16 fixed */ +}; + +/*****************/ + +/* Complex types */ + +/*****************/ + +/** + * \ingroup datatypes + * \typedef RwV2d + * typedef for struct RwV2d + */ +typedef struct RwV2d RwV2d; +/** + * \ingroup datatypes + * \struct RwV2d + * This type represents points in a 2D space, such as device + * space, specified by the (x, y) coordinates of the point. + */ +struct RwV2d +{ + RwReal x; /**< X value*/ + RwReal y; /**< Y vlaue */ +}; + +/** + * \ingroup datatypes + * \typedef RwV3d + * typedef for struct RwV3d + */ +typedef struct RwV3d RwV3d; +/** + * \ingroup datatypes + * \struct RwV3d + * This type represents 3D points and vectors specified by + * the (x, y, z) coordinates of a 3D point or the (x, y, z) components of a + * 3D vector. + */ +struct RwV3d +{ + RwReal x; /**< X value */ + RwReal y; /**< Y value */ + RwReal z; /**< Z value */ +}; + +#define RWV4DALIGNMENT(_v4d) \ + (! (((rwV4DALIGNMENT)-1) & ((RwUInt32)(_v4d)))) + +/** + * \ingroup datatypes + * \struct RwV4d + * This type represents 4D points and vectors specified by + * the (x, y, z, w) coordinates of a 4D point or the (x, y, z, w) components of a + * 4D vector. + */ +struct RwV4d +{ + RwReal x; /**< X value */ + RwReal y; /**< Y value */ + RwReal z; /**< Z value */ + RwReal w; /**< W value */ +}; + +/** + * \ingroup datatypes + * \typedef RwV4d + * typedef for struct RwV4d + */ +typedef struct RwV4d RWALIGN(RwV4d, rwV4DALIGNMENT); + + +/** + * \ingroup datatypes + * \typedef RwRect + * typedef for struct RwRect + */ +typedef struct RwRect RwRect; +/** + * \ingroup datatypes + * \struct RwRect + * This type represents a 2D device space rectangle specified + * by the position of the top-left corner (the offset x, y) and its width (w) + * and height (h). + */ +struct RwRect +{ + RwInt32 x; /**< X value of the top-left corner */ + RwInt32 y; /**< Y value of the top-left corner */ + RwInt32 w; /**< Width of the rectangle */ + RwInt32 h; /**< Height of the rectangle */ +}; + +/** + * \ingroup datatypes + * \typedef RwSphere + * typedef for struct RwSphere + */ +typedef struct RwSphere RwSphere; +/** + * \ingroup datatypes + * \struct RwSphere + * This type represents a sphere specified by the position + * of its center and its radius + */ +struct RwSphere +{ + RwV3d center; /**< Sphere center */ + RwReal radius; /**< Sphere radius */ +}; + +#if (!defined(RwSphereAssign)) +#define RwSphereAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwSphereAssign)) */ + +/** + * \ingroup datatypes + * \typedef RwLine + * typedef for struct RwLine + */ +typedef struct RwLine RwLine; +/** + * \ingroup datatypes + * \struct RwLine + * This type represents a 3D line specified by the position + * of its start and end points. + */ +struct RwLine +{ + RwV3d start; /**< Line start */ + RwV3d end; /**< Line end */ +}; + +#if (!defined(RwLineAssign)) +#define RwLineAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwLineAssign)) */ + +/* The maximum number of texture coordinates */ +#define rwMAXTEXTURECOORDS 8 + +/** + * \ingroup datatypes + * RwTextureCoordinateIndex + * This type represents the index for texture coordinates. + */ +enum RwTextureCoordinateIndex +{ + rwNARWTEXTURECOORDINATEINDEX = 0, + rwTEXTURECOORDINATEINDEX0, + rwTEXTURECOORDINATEINDEX1, + rwTEXTURECOORDINATEINDEX2, + rwTEXTURECOORDINATEINDEX3, + rwTEXTURECOORDINATEINDEX4, + rwTEXTURECOORDINATEINDEX5, + rwTEXTURECOORDINATEINDEX6, + rwTEXTURECOORDINATEINDEX7, + rwTEXTURECOORDINATEINDEXFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwTextureCoordinateIndex RwTextureCoordinateIndex; + +/** + * \ingroup datatypes + * \typedef RwTexCoords + * typedef for struct RwTexCoords + */ +typedef struct RwTexCoords RwTexCoords; +/** + * \ingroup datatypes + * \struct RwTexCoords + * This type represents the the u and v texture + * coordinates of a particular vertex. + */ +struct RwTexCoords +{ + RwReal u; /**< U value */ + RwReal v; /**< V value */ +}; + + +/* Singley linked list macros. End marked as NULL */ + +typedef struct RwSLLink RwSLLink; /*** RwSLLink ***/ +struct RwSLLink +{ + RwSLLink *next; +}; + +#define rwSLLinkGetData(link,type,entry) \ + ((type *)(((RwUInt8 *)(link))-offsetof(type,entry))) + +#define rwSLLinkGetConstData(link,type,entry) \ + ((const type *)(((const RwUInt8 *)(link))-offsetof(type,entry))) + +#define rwSLLinkInitialize(linkvar) \ + (linkvar)->next = NULL; + +#define rwSLLinkGetNext(linkvar) \ + ((linkvar)->next) + +typedef struct RwSingleList RwSingleList; +struct RwSingleList +{ + RwSLLink link; +}; + +#define rwSingleListInitialize(list) \ + (list)->link.next= NULL; +#define rwSingleListEmpty(list) \ + (((list)->link.next)==NULL) +#define rwSingleListAddSLLink(list,linkvar) \ + ( (linkvar)->next = (list)->link.next, \ + (list)->link.next = (linkvar) ) +#define rwSingleListGetFirstSLLink(list) \ + ((list)->link.next) +#define rwSingleListGetTerminator(list) (NULL) + +/* Doubly linked list. End marked as start (its a ring) */ + +typedef struct RwLLLink RwLLLink; /*** RwLLLink ***/ +struct RwLLLink +{ + RwLLLink *next; + RwLLLink *prev; +}; + +#define rwLLLinkGetData(linkvar,type,entry) \ + ((type *)(((RwUInt8 *)(linkvar))-offsetof(type,entry))) + +#define rwLLLinkGetConstData(linkvar,type,entry) \ + ((const type *)(((const RwUInt8 *)(linkvar))-offsetof(type,entry))) + +#define rwLLLinkGetNext(linkvar) \ + ((linkvar)->next) + +#define rwLLLinkGetPrevious(linkvar) \ + ((linkvar)->prev) + +#define rwLLLinkInitialize(linkvar) \ + ( (linkvar)->prev = (RwLLLink *)NULL, \ + (linkvar)->next = (RwLLLink *)NULL ) + +#define rwLLLinkAttached(linkvar) \ + ((linkvar)->next) + +typedef struct RwLinkList RwLinkList; +struct RwLinkList +{ + RwLLLink link; +}; + +#define rwLinkListInitialize(list) \ + ( (list)->link.next = ((RwLLLink *)(list)), \ + (list)->link.prev = ((RwLLLink *)(list)) ) +#define rwLinkListEmpty(list) \ + (((list)->link.next) == (&(list)->link)) +#define rwLinkListAddLLLink(list, linkvar) \ + ( (linkvar)->next = (list)->link.next, \ + (linkvar)->prev = (&(list)->link), \ + ((list)->link.next)->prev = (linkvar), \ + (list)->link.next = (linkvar) ) +#define rwLinkListRemoveLLLink(linkvar) \ + ( ((linkvar)->prev)->next = (linkvar)->next, \ + ((linkvar)->next)->prev = (linkvar)->prev ) +#define rwLinkListGetFirstLLLink(list) \ + ((list)->link.next) +#define rwLinkListGetLastLLLink(list) \ + ((list)->link.prev) +#define rwLinkListGetTerminator(list) \ + (&((list)->link)) + +/** + * \ingroup datatypes + * \typedef RwSurfaceProperties + * typedef for struct RwSurfaceProperties + */ +typedef struct RwSurfaceProperties RwSurfaceProperties; +/** + * \ingroup datatypes + * \struct RwSurfaceProperties + * This type represents the ambient, diffuse and + * specular reflection coefficients of a particular geometry. Each coefficient + * is specified in the range 0.0 (no reflection) to 1.0 (maximum reflection). + */ +struct RwSurfaceProperties +{ + RwReal ambient; /**< ambient reflection coefficient */ + RwReal specular; /**< specular reflection coefficient */ + RwReal diffuse; /**< reflection coefficient */ +}; + +#if (!defined(RwSurfacePropertiesAssign)) +#define RwSurfacePropertiesAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwSurfacePropertiesAssign)) */ + +/********** + * Macros * + **********/ + +/* ANSI C defines the offsetof(type,member) macro; should be in */ + +/* If not, fall back to this: */ +#ifndef offsetof +#define offsetof(type, member) \ + ((size_t)((RwUInt8 *)&((type *) 0)->member - (RwUInt8 *)((type *) 0))) +#endif /* offsetof */ + +/* + * + * Numeric Macros to handle Fixed/Floating point versions of RenderWare + * + */ +#define RWFIX_MIN (1) +#define RWFIX_MAX (0x7fffffff) +#define RwFixedCast(A) (RwInt32FromRealMacro((A) * 65536.0f)) +#define RwFixedToInt(A) ((A) >> 16) +#define RwFixedToFloat(A) ((float)(((float)(A)) * (1.0f / 65536.0f))) +#define RwFixedToReal(a) ((RwReal)(((RwReal)(a)) * (1.0f / 65536.0f))) +#define RwRealToFixed(a) (RwInt32FromRealMacro((a) * 65536.0f)) +#define RwRealAbs(a) ((RwReal)((a) >= (RwReal)(0.0) ? (a) : (-(a)))) +#define RwRealMin2(a,b) ((RwReal)( ((a) <= (b)) ? (a) : (b))) +#define RwRealMax2(a,b) ((RwReal)( ((a) >= (b)) ? (a) : (b))) +#define RwRealMin3(a,b,c) RwRealMin2(a,RwRealMin2(b,c)) +#define RwRealMax3(a,b,c) RwRealMax2(a,RwRealMax2(b,c)) + +#ifndef NORWREALSHORTCUT +#define RToFixed RwRealToFixed +#define RAbs RwRealAbs +#define FxCast RwFixedCast +#define FxToInt RwFixedToInt +#define FxToFloat RwFixedToFloat +#define FxToReal RwFixedToFloat + +#endif + +#ifndef rwPI +#define rwPI ((RwReal)(3.1415926535f)) +#define rwPIOVER2 (rwPI / (RwReal)(2.0f)) +#endif +#define RWRGBALONG(r,g,b,a) \ + ((RwUInt32) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + RwPlane + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + +/* + * typedef for struct RwPlane + */ +typedef struct RwPlane RwPlane; +/* + * This type represents a plane + */ +struct RwPlane +{ + RwV3d normal; /**< Normal to the plane */ + RwReal distance; /**< Distance to plane from origin in normal direction*/ +}; + + +/**************************************************************************** + Defines + */ + +enum RwPlaneType +{ + rwXPLANE = 0, /* These are deliberately multiples of sizeof(RwReal) */ + rwYPLANE = 4, + rwZPLANE = 8, + rwPLANETYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPlaneType RwPlaneType; + +#define rwSECTORATOMIC -1 +#define rwSECTORBUILD -2 /* Only used when building a world */ + +/* vect is a RwV3d, y is the component */ +#define GETCOORD(vect,y) \ + (*(RwReal *)(((RwUInt8 *)(&((vect).x)))+(RwInt32)(y))) +#define GETCONSTCOORD(vect,y) \ + (*(const RwReal *)(((const RwUInt8 *)(&((vect).x)))+(RwInt32)(y))) +#define SETCOORD(vect,y,value) \ + (((*(RwReal *)(((RwUInt8 *)(&((vect).x)))+(RwInt32)(y))))=(value)) +#define SETCONTCOORD(vect,y,value) \ + (((*(const RwReal *) \ + (((const RwUInt8 *) \ + (&((vect).x)))+(RwInt32)(y))))=(value)) +#define GETCOORDINT(vect,y) \ + (*(RwInt32 *)(((RwUInt8 *)(&((vect).x)))+(y))) +#define GETCONSTCOORDINT(vect,y) \ + (*(const RwInt32 *)(((const RwUInt8 *)(&((vect).x)))+(y))) + + +/** + * \ingroup rwcore + * \page inttypes Integer Types + * + * RenderWare supports a number of integer types: + * + * RwInt8 8-bit signed integer. + * \li RwUInt8 8-bit unsigned integer. + * \li RwChar Character type. + * \li RwInt16 16-bit signed integer. + * \li RwUInt16 16-bit unsigned integer. + * \li RwInt32 32-bit signed integer. + * \li RwUInt32 32-bit unsigned integer. + * \li RwInt64 64-bit signed integer. + * \li RwUInt64 64-bit unsigned integer. + * \li RwInt128 128-bit signed integer. + * \li RwUInt128 128-bit unsigned integer. + * \li RwBool Boolean type (in 32 bits). + * + * These types should be used in applications in preference to the underlying + * native types. + * + * The following constants indicate the maximum and minimum values possible + * for the various RenderWare integer types: + * + * \li RwInt32MAXVAL Maximum RwInt32 value. + * \li RwInt32MINVAL Minimum RwInt32 value. + * \li RwUInt32MAXVAL Maximum RwUInt32 value. + * \li RwUInt32MINVAL Minimum RwUInt32 value. + * \li RwInt16MAXVAL Maximum RwInt16 value. + * \li RwInt16MINVAL Minimum RwInt16 value. + * \li RwUInt16MAXVAL Maximum RwUInt16 value. + * \li RwUInt16MINVAL Minimum RwUInt16 value. + * + * \see RwReal + */ + +/** + * \ingroup datatypes + * \typedef RwReal + * + * RenderWare supports a single RwReal floating-point type to aid portability + * across platforms. This type should be used in applications in preference to + * the underlying native type. + * + * The constants RwRealMAXVAL and RwRealMINVAL are provided for determining + * the maximum and minimum values possible using the RwReal type. + * + * In addition, the following macros are available for operations on RwReal + * types: + * \li RwRealMin2(a, b) Find the minimum of two RwReal values. + * \li RwRealMax2(a, b) Find the maximum of two RwReal values. + * \li RwRealMin3(a, b, c) Find the minimum of three RwReal values. + * \li RwRealMax3(a, b, c) Find the maximum of three RwReal values. + * \li RwRealAbs(x) Find the absolute value of a RwReal value. + * + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwFixed + * + * RenderWare supports a single RwFixed fixed-point type. + * + * Although popular in the days when integer mathematics was much faster than + * floating point mathematics, fixed-point math is now rarely used. It is + * provided because it is still useful for some processes. + * + * The maximum and minimum size of an RwFixed value are defined by the constants + * RWFIX_MAX and RWFIX_MIN respectively. + * + * The following macros are provided to help you work with RwFixed datatypes: + * \li RwFixedCast(x) Cast the integer portion of an RwFixed to another type. + * \li RwFixedToInt(x) Convert an RwFixed to an integer. (The fractional portion is lost.) + * \li RwFixedToFloat(x) Convert an RwFixed to a float. + * \li RwFixedToReal(x) Convert an RwFixed to an RwReal. + * \li RwRealToFixed(x) Convert an RwReal to an RwFixed. (Some precision may be lost.) + */ + +/** + * \ingroup datatypes + * \typedef RwInt8 + * + * Signed 8 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwUInt8 + * + * Unsigned 8bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwChar + * + * Character type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwInt16 + * + * Signed 16 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwUInt16 + * + * Unsigned 16 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwInt32 + * + * Signed 32 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwUInt32 + * + * Unsigned 32 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwInt64 + * + * Signed 64 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwUInt64 + * + * Unsigned 64 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwInt128 + * + * Signed 128 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwUInt128 + * + * Unsigned 128 bit integer type. + * \see \ref inttypes + */ + +/** + * \ingroup datatypes + * \typedef RwBool + * + * Boolean type. + * \see \ref inttypes + */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/batype.h ---*/ +/**************************************************************************** + Defines +*/ + +/* + * Object Types - these are used in the binary object + * representations and in the debug library. They must + * be unique. They are the old system. + */ + +#define rwID_DATABASE 0x64617462 /* datb */ + +#define MAKECHUNKID(vendorID, chunkID) (((vendorID & 0xFFFFFF) << 8) | (chunkID & 0xFF)) +#define GETOBJECTID(chunkID) (chunkID & 0xFF) +#define GETVENDORID(chunkID) ((chunkID >> 8) & 0xFFFFFF) + +/*** + *** These are the vendor IDs. A customer must reserve a vendor ID in order + *** to be able to write toolkits (this prevents clashes between toolkits). + *** We reserve some for our own use as shown below. These are all 24 bit. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + *** + *** They must all be unique. + ***/ + +enum RwPluginVendor +{ + rwVENDORID_CORE = 0x000000L, + rwVENDORID_CRITERIONTK = 0x000001L, + rwVENDORID_REDLINERACER = 0x000002L, + rwVENDORID_CSLRD = 0x000003L, + rwVENDORID_CRITERIONINT = 0x000004L, + rwVENDORID_CRITERIONWORLD = 0x000005L, + rwVENDORID_BETA = 0x000006L, + rwVENDORID_CRITERIONRM = 0x000007L, + rwVENDORID_CRITERIONRWA = 0x000008L, /* RenderWare Audio */ + rwPLUGINVENDORFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPluginVendor RwPluginVendor; + +/*** + *** These are the core objects (8 bit IDs). They must all be unique. + *** We can get away without using the MAKECHUNKID macro because the + *** vendor ID in all cases will be zero (rwVENDORID_CORE). + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ + +/* These are the internal ones. Because the core ID is 0, we can get away without + * using the MAKECHUNKID macro for the CORE chunks. + */ + +enum RwCorePluginID +{ + rwID_NAOBJECT = 0x00, + rwID_STRUCT = 0x01, + rwID_STRING = 0x02, + rwID_EXTENSION = 0x03, + rwID_CAMERA = 0x05, + rwID_TEXTURE = 0x06, + rwID_MATERIAL = 0x07, + rwID_MATLIST = 0x08, + rwID_ATOMICSECT = 0x09, + rwID_PLANESECT = 0x0A, + rwID_WORLD = 0x0B, + rwID_SPLINE = 0x0C, + rwID_MATRIX = 0x0D, + rwID_FRAMELIST = 0x0E, + rwID_GEOMETRY = 0x0F, + rwID_CLUMP = 0x10, + rwID_LIGHT = 0x12, + rwID_UNICODESTRING = 0x13, + rwID_ATOMIC = 0x14, + rwID_TEXTURENATIVE = 0x15, + rwID_TEXDICTIONARY = 0x16, + rwID_ANIMDATABASE = 0x17, + rwID_IMAGE = 0x18, + rwID_SKINANIMATION = 0x19, + rwID_GEOMETRYLIST = 0x1A, + rwID_HANIMANIMATION = 0x1B, + rwID_TEAM = 0x1C, + rwID_CROWD = 0x1D, + rwID_DMORPHANIMATION = 0x1E, + rwID_RIGHTTORENDER = 0x1f, + rwID_MTEFFECTNATIVE = 0x20, + rwID_MTEFFECTDICT = 0x21, + rwID_TEAMDICTIONARY = 0x22, + rwID_PITEXDICTIONARY = 0x23, + rwID_TOC = 0x24, + rwID_PRTSTDGLOBALDATA = 0x25, + /* Insert before MAX and increment MAX */ + rwID_COREPLUGINIDMAX = 0x26, + rwCOREPLUGINIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCorePluginID RwCorePluginID ; + +/*** + *** These are the Criterion internal plugin extensions. Use with rwVENDORID_CRITERIONINT. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ + +enum RwCriterionPluginID +{ + rwID_COREPLUGIN = 0x01, + rwID_WORLDPLUGIN = 0x02, + rwID_TOOLPLUGIN = 0x03, + rwID_TOOL2PLUGIN = 0x04, + rwCRITERIONPLUGINIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwCriterionPluginID RwCriterionPluginID; + + +/*** + *** These are the Criterion internal platform identifies. + *** + *** IMPORTANT NOTE: DO NOT UNDER ANY CIRCUMSTANCES CHANGE THESE VALUES. IF + *** YOU ARE ADDING A NEW ONE, APPEND IT! + ***/ +enum RwPlatformID +{ + rwID_PCD3D7 = 1, + rwID_PCOGL, + rwID_MAC, + rwID_PS2, + rwID_XBOX, + rwID_GAMECUBE, + rwID_SOFTRAS, + rwID_PCD3D8, + rwPLATFROMIDFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwPlatformID RwPlatformID; + + +/**************************************************************************** + Global Types + */ + +typedef struct RwObject RwObject; +/** + * \ingroup datatypes + * \struct RwObject + * This should be considered an opaque type. Use + * the RwObject API functions to access. + */ +struct RwObject +{ + RwUInt8 type; /**< Internal Use */ + RwUInt8 subType; /**< Internal Use */ + RwUInt8 flags; /**< Internal Use */ + RwUInt8 privateFlags; /**< Internal Use */ + void *parent; /**< Internal Use */ + /* Often a Frame */ +}; + +/** + * \ingroup datatypes + * \typedef RwObjectCallBack + * callback function supplied for object callback functions. + * + * \return Pointer to the current object + * + * \param object Pointer to the current object, supplied by + * iterator. + * \param data Pointer to developer-defined data structure. + * + * \see RwFrameForAllObjects + * + */ +typedef RwObject *(*RwObjectCallBack)(RwObject *object, void *data); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* TYPE METHODS */ + +/* Creation/cloning */ + +#define rwObjectCopy(d,s) \ +MACRO_START \ +{ \ + ((RwObject *)(d))->type = \ + ((const RwObject *)(s))->type; \ + ((RwObject *)(d))->subType = \ + ((const RwObject *)(s))->subType; \ + ((RwObject *)(d))->flags = \ + ((const RwObject *)(s))->flags; \ + ((RwObject *)(d))->privateFlags = \ + ((const RwObject *)(s))->privateFlags; \ + ((RwObject *)(d))->parent = \ + NULL; \ +} \ +MACRO_STOP + +#define rwObjectInitialize(o, t, s) \ +MACRO_START \ +{ \ + ((RwObject *)(o))->type = (RwUInt8)(t); \ + ((RwObject *)(o))->subType = (RwUInt8)(s); \ + ((RwObject *)(o))->flags = 0; \ + ((RwObject *)(o))->privateFlags = 0; \ + ((RwObject *)(o))->parent = NULL; \ +} \ +MACRO_STOP + +/* Debug */ +#define RwObjectGetType(o) (((const RwObject *)(o))->type) + +#define rwObjectSetType(o, t) (((RwObject *)(o))->type) = (RwUInt8)(t) + +/* Sub type */ +#define rwObjectGetSubType(o) (((const RwObject *)(o))->subType) +#define rwObjectSetSubType(o, t) (((RwObject *)(o))->subType) = (RwUInt8)(t) + +/* Flags */ +#define rwObjectGetFlags(o) (((const RwObject *)(o))->flags) +#define rwObjectSetFlags(o, f) (((RwObject *)(o))->flags) = (RwUInt8)(f) +#define rwObjectTestFlags(o, f) ((((const RwObject *)(o))->flags) & (RwUInt8)(f)) + +/* Private flags */ +#define rwObjectGetPrivateFlags(c) (((const RwObject *)(c))->privateFlags) +#define rwObjectSetPrivateFlags(c,f) (((RwObject *)(c))->privateFlags) = (RwUInt8)(f) +#define rwObjectTestPrivateFlags(c,flag) ((((const RwObject *)(c))->privateFlags) & (RwUInt8)(flag)) + +/* Hierarchy */ +#define rwObjectGetParent(object) (((const RwObject *)(object))->parent) +#define rwObjectSetParent(c,p) (((RwObject *)(c))->parent) = (void *)(p) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/os/win/osintf.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/rwstring.h ---*/ + +/**************************************************************************** + Defines + */ + +#define rwsprintf RWSRCGLOBAL(stringFuncs).vecSprintf +#define rwvsprintf RWSRCGLOBAL(stringFuncs).vecVsprintf +#define rwstrcpy RWSRCGLOBAL(stringFuncs).vecStrcpy +#define rwstrncpy RWSRCGLOBAL(stringFuncs).vecStrncpy +#define rwstrcat RWSRCGLOBAL(stringFuncs).vecStrcat +#define rwstrncat RWSRCGLOBAL(stringFuncs).vecStrncat +#define rwstrrchr RWSRCGLOBAL(stringFuncs).vecStrrchr +#define rwstrchr RWSRCGLOBAL(stringFuncs).vecStrchr +#define rwstrstr RWSRCGLOBAL(stringFuncs).vecStrstr +#define rwstrcmp RWSRCGLOBAL(stringFuncs).vecStrcmp +#define rwstricmp RWSRCGLOBAL(stringFuncs).vecStricmp +#define rwstrlen RWSRCGLOBAL(stringFuncs).vecStrlen +#define rwstrupr RWSRCGLOBAL(stringFuncs).vecStrupr +#define rwstrlwr RWSRCGLOBAL(stringFuncs).vecStrlwr +#define rwstrtok RWSRCGLOBAL(stringFuncs).vecStrtok +#define rwsscanf RWSRCGLOBAL(stringFuncs).vecSscanf + +#define rwstrdup(_result, _string) \ +do \ +{ \ + _result = ((RwChar*)NULL); \ + \ + if (((RwChar*)NULL) != (_string)) \ + { \ + _result = (RwChar *) \ + RwMalloc( (rwstrlen(_string) + 1) * \ + sizeof (RwChar) ); \ + \ + if (((RwChar*)NULL) != (_result)) \ + { \ + rwstrcpy(_result, _string); \ + } \ + } \ +} \ +while (0) + + +/**************************************************************************** + Global Types + */ + +typedef int (*vecSprintfFunc)(RwChar *buffer, + const RwChar *format, + ...) /* __RWFORMAT__(printf, 2, 3) */; +typedef int (*vecVsprintfFunc)(RwChar *buffer, + const RwChar *format, + va_list argptr); +typedef RwChar *(*vecStrcpyFunc)(RwChar *dest, + const RwChar *srce); +typedef RwChar *(*vecStrncpyFunc)(RwChar *dest, + const RwChar *srce, + size_t size); +typedef RwChar *(*vecStrcatFunc)(RwChar *dest, + const RwChar *srce); +typedef RwChar *(*vecStrncatFunc)(RwChar *dest, + const RwChar *srce, + size_t size); +typedef RwChar *(*vecStrrchrFunc)(const RwChar *string, + int findThis); +typedef RwChar *(*vecStrchrFunc)(const RwChar *string, + int findThis); +typedef RwChar *(*vecStrstrFunc)(const RwChar *string, + const RwChar *findThis); +typedef int (*vecStrcmpFunc)(const RwChar *string1, + const RwChar *string2); +typedef int (*vecStricmpFunc)(const RwChar *string1, + const RwChar *string2); +typedef size_t (*vecStrlenFunc)(const RwChar *string); +typedef RwChar *(*vecStruprFunc)(RwChar *string); +typedef RwChar *(*vecStrlwrFunc)(RwChar *string); +typedef RwChar *(*vecStrtokFunc)(RwChar *string, const RwChar *delimit); +typedef int (*vecSscanfFunc)(const RwChar *buffer, + const RwChar *format, + ...) /* __RWFORMAT__(scanf, 2, 3) */; + +typedef struct RwStringFunctions RwStringFunctions; +struct RwStringFunctions +{ + vecSprintfFunc vecSprintf ; + vecVsprintfFunc vecVsprintf; + vecStrcpyFunc vecStrcpy; + vecStrncpyFunc vecStrncpy; + vecStrcatFunc vecStrcat; + vecStrncatFunc vecStrncat; + vecStrrchrFunc vecStrrchr; + vecStrchrFunc vecStrchr; + vecStrstrFunc vecStrstr; + vecStrcmpFunc vecStrcmp; + vecStricmpFunc vecStricmp; + vecStrlenFunc vecStrlen; + vecStruprFunc vecStrupr; + vecStrlwrFunc vecStrlwr; + vecStrtokFunc vecStrtok; + vecSscanfFunc vecSscanf; +}; + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/rwdbgerr.h ---*/ +#define RWECODE(a,b) a, + +/* Construct an enum type with all the plugin error codes (for the app to use) */ +enum RwErrorCodePlugin_errcore +{ +#include "errcore.def" + rwLASTERROR_errcore = RWFORCEENUMSIZEINT +}; +typedef enum RwErrorCodePlugin_errcore RwErrorCodePlugin_errcore; + + +#undef RWECODE + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/resmem.h ---*/ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bamemory.h ---*/ +#if (defined(RWMEMDEBUG)) +#ifdef _XBOX +/* Need OutputDebugString macros */ +#include +#endif +#endif + +/**************************************************************************** + Defines + */ + +/* + * Debug fill bytes for compatibility with MSVC/C++ debug heap + * See + * \Program Files\Microsoft Visual Studio\VC98\CRT\SRC\DBGHEAP.C: + * static unsigned char _bNoMansLandFill = 0xFD; + * // fill no-man's land with this + * static unsigned char _bDeadLandFill = 0xDD; + * // fill free objects with this + * static unsigned char _bCleanLandFill = 0xCD; + * // fill new objects with this + */ + +#if (!defined(rwFREELISTNOMANSLANDFILL)) +#define rwFREELISTNOMANSLANDFILL 0xFD +#endif /* (!defined(rwFREELISTNOMANSLANDFILL)) */ + +#if (!defined(rwFREELISTDEADLANDFILL)) +#define rwFREELISTDEADLANDFILL 0xDD +#endif /* (!defined(rwFREELISTDEADLANDFILL)) */ + +#if (!defined(rwFREELISTCLEANLANDFILL)) +#define rwFREELISTCLEANLANDFILL 0xCD +#endif /* (!defined(rwFREELISTCLEANLANDFILL)) */ + +#define RWFREELISTALIGNED(_pData, _freelist) \ + (! (((RwUInt32)(_pData)) & ((_freelist)->alignmentMinusOne)) ) + +/***************************** + * REGULAR MEMORY ALLOCATION * + *****************************/ + +/** + * \ingroup rwmem + * \def RwMalloc + * RwMalloc(_s) is a macro for malloc(_s). + */ + +/** + * \ingroup rwmem + * \def RwFree + * RwFree(_p) is a macro for free(_p). + */ + +/** + * \ingroup rwmem + * \def RwCalloc + * RwCalloc(_n, _s) is a macro for calloc(_n, _s). + */ + +/** + * \ingroup rwmem + * \def RwRealloc + * RwRealloc(_p, _s) is a macro for realloc(_p, _s). + */ + +#if ( (defined(RWMEMDEBUG)) && defined(RWDEBUG) ) + +#if (!defined(RWNOFREELISTS)) +#define RWNOFREELISTS +#endif /* (!defined(RWNOFREELISTS)) */ + +#if (defined(rwPLUGIN_ID)) +#define _CLIENT_TAG \ + ( 0xFFFF & (rwPLUGIN_ID) ) +#endif /* (defined(rwPLUGIN_ID)) */ + +#if (!defined(_CLIENT_TAG)) +#define _CLIENT_TAG \ + ( 0xFFFF & (MAKECHUNKID(rwVENDORID_CRITERIONTK, 0x00) ) ) +#endif /* (!defined(_CLIENT_TAG)) */ + +# if (defined(_MSC_VER)) +# if ((_MSC_VER>=1000) && defined(_DEBUG)) + +/* Pick up _ASSERTE() macro */ +/* #include */ +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include + +#define RwMalloc(_s) \ + _malloc_dbg((_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__) + +#define RwFree(_p) \ + _free_dbg((_p), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16)) + +#define RwCalloc(_n, _s) \ + _calloc_dbg((_n), (_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__) + +#define RwRealloc(_p, _s) \ + _realloc_dbg((_p), \ + (_s), \ + _CLIENT_BLOCK | ((_CLIENT_TAG)<<16), \ + __FILE__, \ + __LINE__) + +#define RWCRTORDBGFLAG(_flag) \ + do \ + { \ + int _DbgFlag; \ + \ + _DbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ + _DbgFlag |= (_flag); \ + _CrtSetDbgFlag(_DbgFlag); \ + } while(0) + +#define VALID_HEAP_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): valid heap\n" + +#define RWCRTCHECKMEMORY() \ + do \ + { \ + int valid_heap; \ + \ + valid_heap = _CrtCheckMemory(); \ + _ASSERTE(valid_heap); \ + } while(0) + +/* + * if (valid_heap) \ + * OutputDebugString(VALID_HEAP_STR); \ + */ + +#define NO_LEAKS_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): no heap leaks found\n" + +#define RWCRTDUMPMEMORYLEAKS() \ + do \ + { \ + int leaks_found; \ + \ + leaks_found = _CrtDumpMemoryLeaks(); \ + _ASSERTE(!leaks_found); \ + if (!leaks_found) \ + OutputDebugString(NO_LEAKS_FOUND_STR); \ + } while(0) + +#define HEAP_DIFFERENCES_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): heap differences found\n" + +#define NO_DIFFERENCES_FOUND_STR \ + __FILE__##"("##RW_STRINGIFY_EXPANDED(__LINE__)##"): no heap differences found\n" + +#define RWCRTHEAPDIFFERENCESINCE(_Then) \ + do \ + { \ + /* only dump differences when \ + * there are in fact differences */ \ + _CrtMemState _Now; \ + _CrtMemState _Delta; \ + const int _DbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ + int Differences; \ + \ + _CrtMemCheckpoint(&_Now); \ + _CrtMemDifference(&_Delta, _Then, &_Now); \ + \ + (Differences) = ( ( 0 != _Delta.lCounts[_CLIENT_BLOCK] ) || \ + ( 0 != _Delta.lCounts[_NORMAL_BLOCK] ) || \ + ( (_DbgFlag & _CRTDBG_CHECK_CRT_DF) && \ + ( 0 != _Delta.lCounts[_CRT_BLOCK]) ) ); \ + \ + if ( (Differences) ) \ + { \ + /* difference detected: dump objects since _Then. */ \ + OutputDebugString(HEAP_DIFFERENCES_FOUND_STR); \ + _CrtMemDumpAllObjectsSince(_Then); \ + _CrtMemDumpStatistics(&_Delta); \ + } \ + else \ + { \ + OutputDebugString(NO_DIFFERENCES_FOUND_STR); \ + } \ + } while (0) + +#define RWCRTDBGBREAK() \ + _CrtDbgBreak() + +#define RWCRTDOFORALLCLIENTOBJECTS(_f, _c) \ + _CrtDoForAllClientObjects(_f, _c) + +#define RWCRTISMEMORYBLOCK(_p, _t, _r, _f, _l) \ + _CrtIsMemoryBlock(_p, _t, _r, _f, _l) + +#define RWCRTISVALIDHEAPPOINTER(_p) \ + _CrtIsValidHeapPointer(_p) + +#define RWCRTISVALIDPOINTER(_p, _n, _r) \ + _CrtIsValidPointer(_p, _n, _r) + +#define RWCRTMEMCHECKPOINT(_s) \ + _CrtMemCheckpoint(_s) + +#define RWCRTMEMDIFFERENCE(_s1, _s2, _s3) \ + _CrtMemDifference(_s1, _s2, _s3) + +#define RWCRTMEMDUMPALLOBJECTSSINCE(_s) \ + _CrtMemDumpAllObjectsSince(_s) + +#define RWCRTMEMDUMPSTATISTICS(_s) \ + _CrtMemDumpStatistics(_s) + +#define RWCRTSETALLOCHOOK(_f) \ + _CrtSetAllocHook(_f) + +#define RWCRTSETBREAKALLOC(_a) \ + _CrtSetBreakAlloc(_a) + +#define RWCRTSETDBGFLAG(_f) \ + _CrtSetDbgFlag(_f) + +#define RWCRTSETDUMPCLIENT(_f) \ + _CrtSetDumpClient(_f) + +#define RWCRTSETREPORTFILE(_t, _f) \ + _CrtSetReportFile(_t, _f) + +#define RWCRTSETREPORTHOOK(_f) \ + _CrtSetReportHook(_f) + +#define RWCRTSETREPORTMODE(_t, _f) \ + _CrtSetReportMode(_t, _f) + +#if (!defined(_CRTDBG_FLAGS)) +#define _CRTDBG_FLAGS \ + ( (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | \ + _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF) & \ + ~(_CRTDBG_CHECK_ALWAYS_DF |_CRTDBG_RESERVED_DF) ) +#endif /* (!defined(_CRTDBG_FLAGS)) */ + +# endif /* ((_MSC_VER>=1000) && defined(_DEBUG)) */ +# endif /* (defined(_MSC_VER)) */ + + + +#if (!defined(rwDEADPTRFILL)) +#define rwDEADPTRFILL ((void *)0xDDDDDDDD) +#endif /* (!defined(rwDEADPTRFILL)) */ + +#endif /* (defined(RWDEBUG) && (defined(RWMEMDEBUG))) */ + +#if (!defined(rwDEADPTRFILL)) +#define rwDEADPTRFILL (NULL) +#endif /* (!defined(rwDEADPTRFILL)) */ + +#if (!defined(RwMalloc)) +#define RwMalloc(_s) ((RWSRCGLOBAL(memoryFuncs).rwmalloc)((_s))) +#endif /* (!defined(RwMalloc)) */ + +#if (!defined(RwFree)) +#define RwFree(_p) ((RWSRCGLOBAL(memoryFuncs).rwfree)((_p))) +#endif /* (!defined(RwFree)) */ + +#if (!defined(RwCalloc)) +#define RwCalloc(_n, _s) ((RWSRCGLOBAL(memoryFuncs).rwcalloc)((_n), (_s))) +#endif /* (!defined(RwCalloc)) */ + +#if (!defined(RwRealloc)) +#define RwRealloc(_p, _s) ((RWSRCGLOBAL(memoryFuncs).rwrealloc)((_p),(_s))) +#endif /* (!defined(RwRealloc)) */ + +#if (!defined(RWCRTORDBGFLAG)) +#define RWCRTORDBGFLAG(_flag) /* No op */ +#endif /* (!defined(RWCRTORDBGFLAG)) */ + +#if (!defined(RWCRTCHECKMEMORY)) +#define RWCRTCHECKMEMORY() /* No Op */ +#endif /* (!defined(RWCRTCHECKMEMORY)) */ + +#if (!defined(RWCRTDBGBREAK)) +#define RWCRTDBGBREAK() /* No Op */ +#endif /* (!defined(RWCRTDBGBREAK)) */ + +#if (!defined(RWCRTDOFORALLCLIENTOBJECTS)) +#define RWCRTDOFORALLCLIENTOBJECTS(_f, _c) /* No Op */ +#endif /* (!defined(RWCRTDOFORALLCLIENTOBJECTS)) */ + +#if (!defined(RWCRTDUMPMEMORYLEAKS)) +#define RWCRTDUMPMEMORYLEAKS() /* No Op */ +#endif /* (!defined(RWCRTDUMPMEMORYLEAKS)) */ + +#if (!defined(RWCRTHEAPDIFFERENCESINCE)) +#define RWCRTHEAPDIFFERENCESINCE(_Then) /* No Op */ +#endif /* (!defined(RWCRTHEAPDIFFERENCESINCE)) */ + +#if (!defined(RWCRTISMEMORYBLOCK)) +#define RWCRTISMEMORYBLOCK(_p, _t, _r, _f, _l) (NULL != (_p)) +#endif /* (!defined(RWCRTISMEMORYBLOCK)) */ + +#if (!defined(RWCRTISVALIDHEAPPOINTER)) +#define RWCRTISVALIDHEAPPOINTER(_p) (NULL != (_p)) +#endif /* (!defined(RWCRTISVALIDHEAPPOINTER)) */ + +#if (!defined(RWCRTISVALIDPOINTER)) +#define RWCRTISVALIDPOINTER(_p, _n, _r) (NULL != (_p)) +#endif /* (!defined(RWCRTISVALIDPOINTER)) */ + +#if (!defined(RWCRTMEMCHECKPOINT)) +#define RWCRTMEMCHECKPOINT(_s) /* No Op */ +#endif /* (!defined(RWCRTMEMCHECKPOINT)) */ + +#if (!defined(RWCRTMEMDIFFERENCE)) +#define RWCRTMEMDIFFERENCE(_s1, _s2, _s3) /* No Op */ +#endif /* (!defined(RWCRTMEMDIFFERENCE)) */ + +#if (!defined(RWCRTMEMDUMPALLOBJECTSSINCE)) +#define RWCRTMEMDUMPALLOBJECTSSINCE(_s) /* No Op */ +#endif /* (!defined(RWCRTMEMDUMPALLOBJECTSSINCE)) */ + +#if (!defined(RWCRTMEMDUMPSTATISTICS)) +#define RWCRTMEMDUMPSTATISTICS(_s) (NULL) +#endif /* (!defined(RWCRTMEMDUMPSTATISTICS)) */ + +#if (!defined(RWCRTSETALLOCHOOK)) +#define RWCRTSETALLOCHOOK(_f) (NULL) +#endif /* (!defined(RWCRTSETALLOCHOOK)) */ + +#if (!defined(RWCRTSETBREAKALLOC)) +#define RWCRTSETBREAKALLOC(_a) (0) +#endif /* (!defined(RWCRTSETBREAKALLOC)) */ + +#if (!defined(RWCRTSETDBGFLAG)) +#define RWCRTSETDBGFLAG(_f) (0) +#endif /* (!defined(RWCRTSETDBGFLAG)) */ + +#if (!defined(RWCRTSETDUMPCLIENT)) +#define RWCRTSETDUMPCLIENT(_f) (NULL) +#endif /* (!defined(RWCRTSETDUMPCLIENT)) */ + +#if (!defined(RWCRTSETREPORTFILE)) +#define RWCRTSETREPORTFILE(_t, _f) (NULL) +#endif /* (!defined(RWCRTSETREPORTFILE)) */ + +#if (!defined(RWCRTSETREPORTHOOK)) +#define RWCRTSETREPORTHOOK(_f) (NULL) +#endif /* (!defined(RWCRTSETREPORTHOOK)) */ + +#if (!defined(RWCRTSETREPORTMODE)) +#define RWCRTSETREPORTMODE(_t, _f) (0) +#endif /* (!defined(RWCRTSETREPORTMODE)) */ + +#if (!defined(RWREGSETBREAKALLOC)) +#define RWREGSETBREAKALLOC(_name) /* No op */ +#endif /* (!defined(RWREGSETBREAKALLOC)) */ + +#if (!defined(RWREGSETASSERTPRINT)) +#define RWREGSETASSERTPRINT(_name) /* No op */ +#endif /* (!defined(RWREGSETASSERTPRINT)) */ + +#if (!defined(RWGETWINREGDWORD)) +#define RWGETWINREGDWORD(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGDWORD)) */ + +#if (!defined(RWGETWINREGBINARY)) +#define RWGETWINREGBINARY(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGBINARY)) */ + +#if (!defined(RWGETWINREGSTRING)) +#define RWGETWINREGSTRING(_env_var, _match) /* No op */ +#endif /* (!defined(RWGETWINREGSTRING)) */ + +#if (!defined(_CRTDBG_FLAGS)) +#define _CRTDBG_FLAGS 0x33 +#endif /* (!defined(_CRTDBG_FLAGS)) */ + +/**************************************************************************** + Global Types + */ + +typedef struct RwMemoryFunctions RwMemoryFunctions; +/** + * \ingroup datatypes + * \struct RwMemoryFunctions + * This type represents the memory functions used + * by RenderWare. By default, the standard ANSI functions are used. The + * application may install an alternative interface providing that it is ANSI + * compliant (see API function \ref RwEngineInit): + */ +struct RwMemoryFunctions +{ + /* c.f. + * Program Files/Microsoft Visual Studio/VC98/Include/MALLOC.H + */ + void *(*rwmalloc)(size_t size); /**< rwmalloc malloc */ + void (*rwfree)(void *mem); /**< rwfree free */ + void *(*rwrealloc)(void *mem, size_t newSize); /**< rwrealloc realloc */ + void *(*rwcalloc)(size_t numObj, size_t sizeObj); /**< calloc calloc */ +}; + +typedef struct RwFreeBlock RwFreeBlock; +/* + * Freelists -- from Page 131 + * Advanced Animation and Rendering Techniques + * Alan Watt and Mark Watt + * Addison-Wesley 1993, + * ISBN 0-201-54412-1: + * + * "Lastly, on a more general note concerning speedups for renderers, the + * implementor should be aware that a lot of suggestions for improving + * efficiency fall into the category of ingenious, but complex, + * algorithms for very specific contexts that may save a few microseconds + * but which make your code unreadable. A more general computer science + * perspective that takes a `global view' of the renderer can be more + * fruitful. For example, the renderer devotes a lot of time to + * allocating and deallocating chunks of memory for storing data. A lot + * of these chunks are always the same size - such as those that are + * continually required to store the data structure for fragment lists. + * Using memory management techniques that recognize this fact can yield + * considerable dividends. One such scheme would be to hold a series of + * empty lists in memory for all the commonly used data structures. An + * empty list for fragments, say, would contain a list of previously + * allocated, but no longer needed, fragment structures. When the + * renderer needs memory for a new fragment, it looks first at this empty + * list. If there is nothing there it allocates space directly, + * otherwise it takes a fragments off the end of the list and uses that. + * Conversely, when the renderer no longer needs a fragment, instead of + * freeing it, it goes onto the end of the empty list. In the authors' + * experience, replacing the naive allocate/deallocate scheme with this + * way of managing memory can result in 100% speedup. " + */ +struct RwFreeBlock +{ + RwFreeBlock *nextBlock; +}; + +typedef struct RwFreeList RwFreeList; +struct RwFreeList +{ + void **freeListStack; /* Stack of unused entries */ + void **freeListStackTop; /* Pointer to the top of the stack */ + + RwFreeBlock *firstBlock; /* Data start */ + + RwInt32 blockSize; /* Size of block in bytes */ + RwInt32 entrySize; /* Entry size */ + RwInt32 alignmentMinusOne; /* Entry alignment minus 1 */ + RwInt32 entriesPerBlock; /* Amount of space in a block */ + + RwInt32 entriesAllocated; /* Total slots allocated + * (but not necessarily being used */ + + /* All freelists */ + RwLLLink lFreeList; + +#if (defined(RWDEBUG) && !defined(DOXYGEN)) + const RwChar *fileCreate; + RwUInt32 lineCreate; +#endif /* (defined(RWDEBUG) && !defined(DOXYGEN)) */ +}; + +/** + * \ingroup datatypes + * \ref RwFreeListCallBack represents + * the function called from \ref RwFreeListForAllUsed for all used entries in a + * given free list. + * + * \param pMem Pointer to the start of the current entries. + * + * \param pData User-defined data pointer. + * + * \see RwFreeListForAllUsed + * + */ +typedef void (*RwFreeListCallBack) (void *pMem, void *pData); +typedef void *(*RwMemoryAllocFn) (RwFreeList * fl); +typedef RwFreeList *(*RwMemoryFreeFn) (RwFreeList * fl, void *pData); + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwMemoryFunctions *RwOsGetMemoryInterface(void); + +/************* + * FREELISTS * + *************/ + +/* Allocation and freeing */ +#if (defined(RWDEBUG) && !defined(DOXYGEN)) + +extern RwFreeList *_rwFreeListCreate(RwInt32 entrySize, + RwInt32 entriesPerBlock, + RwInt32 alignment, + const RwChar *fileCreate, + RwUInt32 lineCreate ); + +#define RwFreeListCreate(entrySize, entriesPerBlock, alignment) \ + _rwFreeListCreate(entrySize, \ + entriesPerBlock, \ + alignment, \ + __FILE__, \ + __LINE__) +#else /* (defined(RWDEBUG) && !defined(DOXYGEN)) */ + +extern RwFreeList *RwFreeListCreate(RwInt32 entrySize, + RwInt32 entriesPerBlock, + RwInt32 alignment); +#endif /* (defined(RWDEBUG) && !defined(DOXYGEN)) */ + +extern RwBool RwFreeListDestroy(RwFreeList * freelist); +/* Garbage collection/enumeration */ +extern RwInt32 RwFreeListPurge(RwFreeList * freelist); +extern RwFreeList *RwFreeListForAllUsed(RwFreeList * freelist, + RwFreeListCallBack + fpCallBack, void *pData); +extern RwInt32 RwFreeListPurgeAllFreeLists(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if (defined(RWDEBUG) && defined(RWNOFREELISTS) && !defined(RWKEEPFREELISTS)) + +#if ((defined(__MWERKS__) || defined(__GNUC__)) && defined(__R5900__)) + +/* + * for more on memalign, see + * http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_3.html#SEC28 + */ +#include + +#define RwFreeListAlloc(_f) \ + memalign((1 + (_f)->alignmentMinusOne), (_f)->entrySize) + +#else /* ((defined(__MWERKS__) || defined(__GNUC__)) && defined(__R5900__)) */ + +#define RwFreeListAlloc(_f) \ + RwMalloc((_f)->entrySize) + +#endif /* ((defined(__MWERKS__) || defined(__GNUC__)) && defined(__R5900__)) */ + +#define RwFreeListFree(_f, _p) \ + RwFree((_p)) + +#endif /* (defined(RWDEBUG) && defined(RWNOFREELISTS) && !defined(RWKEEPFREELISTS)) */ + +#if (!defined(RwFreeListAlloc)) +#define RwFreeListAlloc(_f) \ + RWSRCGLOBAL(memoryAlloc)(_f) +#endif /* (!defined(RwFreeListAlloc)) */ + +#if (!defined(RwFreeListFree)) +#define RwFreeListFree(_f, _p) \ + RWSRCGLOBAL(memoryFree)(_f, _p) +#endif /* (!defined(RwFreeListFree)) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bastream.h ---*/ + +/**************************************************************************** + Defines + */ + +#define rwSTREAMSTACKSIZE 512 + +/**************************************************************************** + Global Types + */ + +/** + * \ingroup datatypes + * \ref RwStreamType + * This type represents the different types of stream that + * can be used. + * See API section \ref rwstream + */ +enum RwStreamType +{ + rwNASTREAM = 0, /**=1000) && defined(_DEBUG)) + +typedef char MatrixString[1024]; + +#define RWMATRIXPRINT(_matrix) \ +MACRO_START \ +{ \ + MatrixString message; \ + MatrixString output; \ + \ + if (NULL != (_matrix)) \ + { \ + const RwV3d * const _x = &(_matrix)->right; \ + const RwV3d * const _y = &(_matrix)->up; \ + const RwV3d * const _z = &(_matrix)->at; \ + const RwV3d * const _w = &(_matrix)->pos; \ + \ + _snprintf(message, sizeof(MatrixString), \ + "[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n" \ + " [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n" \ + " %08x == flags\n", \ + _x->x, _x->y, _x->z, (RwReal) 0, \ + _y->x, _y->y, _y->z, (RwReal) 0, \ + _z->x, _z->y, _z->z, (RwReal) 0, \ + _w->x, _w->y, _w->z, (RwReal) 1, \ + (_matrix)->flags); \ + } \ + else \ + { \ + _snprintf(message, sizeof(MatrixString), \ + "NULL"); \ + } \ + \ + _snprintf(output, sizeof(MatrixString), \ + "%s(%d): %s [%p] ==\n%s\n", \ + __FILE__, __LINE__, \ + #_matrix, _matrix, message); \ + \ + OutputDebugString(RWSTRING(output)); \ +} \ +MACRO_STOP + +# endif /* ((_MSC_VER>=1000) && defined(_DEBUG)) */ +# endif /* (defined(_MSC_VER)) */ +#endif /* (defined(RWMATRIXMONITOR)) */ + +#if (!(defined(RWMATRIXPRINT))) +#define RWMATRIXPRINT(_matrix) /* No op */ +#endif /* (!(defined(RWMATRIXPRINT))) */ + +/** + * \ingroup datatypes + * enum RwOpCombineType + * This type represents a combination operator which + * can be applied to frames and matrices. + * The operator determines the order + * in which one object is combined with another + */ +enum RwOpCombineType +{ + rwCOMBINEREPLACE = 0, /**right.x = (m)->up.y = (m)->at.z = (RwReal)((1.0)); \ + (m)->right.y = (m)->right.z = (m)->up.x = (RwReal)((0.0)); \ + (m)->up.z = (m)->at.x = (m)->at.y = (RwReal)((0.0)); \ + (m)->pos.x = (m)->pos.y = (m)->pos.z = (RwReal)((0.0)); \ + rwMatrixSetFlags((m), \ + rwMatrixGetFlags(m) | \ + (rwMATRIXINTERNALIDENTITY | \ + rwMATRIXTYPEORTHONORMAL)); \ +} \ +MACRO_STOP +#endif /* (!defined(RwMatrixSetIdentityMacro)) */ + +typedef void (RWASMCALL * rwMatrixMultFn) (RwMatrix * dstMat, + const RwMatrix * matA, + const RwMatrix * matB); + +/* + * \ingroup datatypes + * \typedef RwMatrixTolerance + * Typedef for RwMatrixTolerance structure + */ +typedef struct RwMatrixTolerance RwMatrixTolerance; + +/* + * \ingroup datatypes + * \struct RwMatrixTolerance + * Holds tolerances for matrix optimizations with \ref RwMatrixOptimize + */ +struct RwMatrixTolerance +{ + RwReal Normal; + /**< Tolerance within which matrix is deemed to be normal */ + RwReal Orthogonal; + /**< Tolerance within which matrix is deemed to be orthogonal */ + RwReal Identity; + /**< Tolerance within which matrix is deemed to be identity */ +}; + + +/**************************************************************************** + Function prototypes + */ + +/* Matrix operations */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern RwBool +RwEngineGetMatrixTolerances(RwMatrixTolerance * const tolerance); + +extern RwBool +RwEngineSetMatrixTolerances(const RwMatrixTolerance * const tolerance); + +/* Update */ +#define rwMatrixSetFlags(m, flagsbit) ((m)->flags = (flagsbit)) +#define rwMatrixGetFlags(m) ((m)->flags) +#define rwMatrixTestFlags(m, flagsbit) ((m)->flags & (RwInt32)(flagsbit)) + +/* Creation/destruction */ +extern RwBool +RwMatrixDestroy(RwMatrix * mpMat); + +extern RwMatrix * +RwMatrixCreate(void); + +#ifdef RWDEBUG + +/* Functions for debug */ +extern void +RwMatrixCopy(RwMatrix * dstMatrix, const RwMatrix * srcMatrix); + +extern void +RwMatrixSetIdentity(RwMatrix * matrix); + +#else /* RWDEBUG */ + +#define RwMatrixCopy(dst, src) RwMatrixCopyMacro(dst, src) +#define RwMatrixSetIdentity(m) RwMatrixSetIdentityMacro(m) + +#endif /* RWDEBUG */ + +/* Matrix multiply */ +extern RwMatrix * +RwMatrixMultiply(RwMatrix * matrixOut, + const RwMatrix * MatrixIn1, + const RwMatrix * matrixIn2); + +extern RwMatrix * +RwMatrixTransform(RwMatrix * matrix, + const RwMatrix * transform, + RwOpCombineType combineOp); + +/* Normalise */ +extern RwMatrix * +RwMatrixOrthoNormalize(RwMatrix * matrixOut, + const RwMatrix * matrixIn); + +/* Inversion */ +extern RwMatrix * +RwMatrixInvert(RwMatrix * matrixOut, + const RwMatrix * matrixIn); + +/* Unary matrix operations */ +extern RwMatrix * +RwMatrixScale(RwMatrix * matrix, + const RwV3d * scale, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixTranslate(RwMatrix * matrix, + const RwV3d * translation, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixRotate(RwMatrix * matrix, + const RwV3d * axis, + RwReal angle, + RwOpCombineType combineOp); + +extern RwMatrix * +RwMatrixRotateOneMinusCosineSine(RwMatrix * matrix, + const RwV3d * unitAxis, + RwReal oneMinusCosine, + RwReal sine, + RwOpCombineType combineOp); + +/* Query what the matrix is */ +extern const RwMatrix *RwMatrixQueryRotate(const RwMatrix * matrix, + RwV3d * unitAxis, + RwReal * angle, + RwV3d * center); + +/* Get components */ +#ifndef RWDEBUG + +#define RwMatrixGetRight(m) (&(m)->right) +#define RwMatrixGetUp(m) (&(m)->up) +#define RwMatrixGetAt(m) (&(m)->at) +#define RwMatrixGetPos(m) (&(m)->pos) + +#else /* RWDEBUG */ + +extern RwV3d * +RwMatrixGetRight(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetUp(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetAt(RwMatrix * matrix); + +extern RwV3d * +RwMatrixGetPos(RwMatrix * matrix); + +#endif /* RWDEBUG */ + +/* Update the internal matrix state wrt its elements */ +extern RwMatrix * +RwMatrixUpdate(RwMatrix * matrix); + +/* Update the internal matrix flags wrt its elements */ +extern RwMatrix * +RwMatrixOptimize(RwMatrix * matrix, + const RwMatrixTolerance * + tolerance); + +extern RwReal +_rwMatrixDeterminant(const RwMatrix * matrix); + +extern RwReal +_rwMatrixNormalError(const RwMatrix * matrix); + +extern RwReal +_rwMatrixOrthogonalError(const RwMatrix * matrix); + +extern RwReal +_rwMatrixIdentityError(const RwMatrix * matrix); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compatibility macros */ + +#define rwMatrixSetOptimizations(optimizeFlags) \ + _rwMatrixSetOptimizations(optimizeFlags) + +#define rwMatrixSetMultFn(multMat) \ + _rwMatrixSetMultFn(multMat) + +#define rwMatrixOpen(instance, offset, size) \ + _rwMatrixOpen(instance, offset, size) + +#define rwMatrixClose(instance, offset, size) \ + _rwMatrixClose(instance, offset, size) + +/* Initialisation/deinitialisation */ +#define rwMatrixInitialize(m, t) \ +MACRO_START \ +{ \ + rwMatrixSetFlags((m), (t)); \ +} \ +MACRO_STOP + +#define rwMatrixIsNormal(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixNormalError(_matrix) ) + +#define rwMatrixIsOrthogonal(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixOrthogonalError(_matrix) ) + +#define rwMatrixIsOrthonormal(_matrix, _epsilon) \ + ( rwMatrixIsNormal(_matrix, _epsilon) && \ + rwMatrixIsOrthogonal(_matrix, _epsilon) ) + +#define rwMatrixIsOrthonormalPositive(_matrix, _epsilon) \ + ( rwMatrixIsOrthonormal(_matrix, _epsilon) && \ +( (((RwReal)1) - (_epsilon)) <= _rwMatrixDeterminant(_matrix) ) ) + +#define rwMatrixIsIdentity(_matrix, _epsilon) \ + ( (_epsilon) >= _rwMatrixIdentityError(_matrix) ) + +#define rwMatrixValidFlags(_matrix, _epsilon) \ + ( (_matrix) && /* valid pointer */ \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as identity */ \ + rwMATRIXINTERNALIDENTITY) ) || /* .. or actually is */ \ + rwMatrixIsIdentity(_matrix, _epsilon)) && \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as normal */ \ + rwMATRIXTYPENORMAL) ) || /* ... or actually is */ \ + rwMatrixIsNormal(_matrix, _epsilon)) && \ + ( ( !( rwMatrixGetFlags(_matrix) & /* not flagged as orthogonal */ \ + rwMATRIXTYPEORTHOGANAL) ) || /* ... or actually is */ \ + rwMatrixIsOrthogonal(_matrix, _epsilon)) ) + +#define rwMat01Det(_mAA) \ + ( (_mAA) ) + +#define rwMat02Det(_mAA, _mAB, \ + _mBA, _mBB) \ + ( (_mAA) * rwMat01Det(_mBB) \ + - (_mAB) * rwMat01Det(_mBA) \ + ) + +#define rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) \ + ( (_mAA) * rwMat02Det(_mBB, _mBC, \ + _mCB, _mCC) \ + - (_mAB) * rwMat02Det(_mBA, _mBC, \ + _mCA, _mCC) \ + + (_mAC) * rwMat02Det(_mBA, _mBB, \ + _mCA, _mCB) \ + ) + +#define rwMat04Det(_mAA, _mAB, _mAC, _mAD, \ + _mBA, _mBB, _mBC, _mBD, \ + _mCA, _mCB, _mCC, _mCD, \ + _mDA, _mDB, _mDC, _mDD) \ + ( (_mAA) * rwMat03Det(_mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD) \ + - (_mAB) * rwMat03Det(_mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) \ + + (_mAC) * rwMat03Det(_mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) \ + - (_mAD) * rwMat03Det(_mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) \ + ) + + +#define rwMat02Inv(_rAA, _rAB, \ + _rBA, _rBB) \ + _mAA, _mAB, \ + _mBA, _mBB) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA) = rwMat01Det(_mBB); \ + (_rAB) = -rwMat01Det(_mAB); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) ); \ + \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + \ + (_rBA) = -rwMat01Det(_mBA) * normalize; \ + (_rBB) = rwMat01Det(_mAA) * normalize; \ + } \ +} \ +MACRO_STOP + +#define rwMat03Inv(_rAA, _rAB, _rAC, \ + _rBA, _rBB, _rBC, \ + _rCA, _rCB, _rCC, \ + _mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA)= rwMat02Det(_mBB, _mBC, \ + _mCB, _mCC); \ + (_rAB)= -rwMat02Det(_mAB, _mAC, \ + _mCB, _mCC); \ + (_rAC)= rwMat02Det(_mAB, _mAC, \ + _mBB, _mBC); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) + \ + (_rAC) * (_mCA) ); \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + (_rAC) *= normalize; \ + \ + (_rBA)= -rwMat02Det(_mBA, _mBC, \ + _mCA, _mCC) * normalize ; \ + (_rBB)= rwMat02Det(_mAA, _mAC, \ + _mCA, _mCC) * normalize ; \ + (_rBC)= -rwMat02Det(_mAA, _mAC, \ + _mBA, _mBC) * normalize ; \ + \ + (_rCA)= rwMat02Det(_mBA, _mBB, \ + _mCA, _mCB) * normalize ; \ + (_rCB)= -rwMat02Det(_mAA, _mAB, \ + _mCA, _mCB) * normalize ; \ + (_rCC)= rwMat02Det(_mAA, _mAB, \ + _mBA, _mBB) * normalize ; \ + } \ + \ +} \ +MACRO_STOP + +#define rwMat04Inv(_rAA, _rAB, _rAC, _rAD, \ + _rBA, _rBB, _rBC, _rBD, \ + _rCA, _rCB, _rCC, _rCD, \ + _rDA, _rDB, _rDC, _rDD, \ + _mAA, _mAB, _mAC, _mAD, \ + _mBA, _mBB, _mBC, _mBD, \ + _mCA, _mCB, _mCC, _mCD, \ + _mDA, _mDB, _mDC, _mDD) \ +MACRO_START \ +{ \ + RwSplitBits determinant; \ + \ + (_rAA)= rwMat03Det(_mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD); \ + (_rAB)= -rwMat03Det(_mAB, _mAC, _mAD, \ + _mCB, _mCC, _mCD, \ + _mDB, _mDC, _mDD); \ + (_rAC)= rwMat03Det(_mAB, _mAC, _mAD, \ + _mBB, _mBC, _mBD, \ + _mDB, _mDC, _mDD); \ + (_rAD)= -rwMat03Det(_mAB, _mAC, _mAD, \ + _mBB, _mBC, _mBD, \ + _mCB, _mCC, _mCD); \ + \ + determinant.nReal = ( (_rAA) * (_mAA) + \ + (_rAB) * (_mBA) + \ + (_rAC) * (_mCA) + \ + (_rAD) * (_mDA) ); \ + \ + { \ + const RwReal normalize = ( (determinant.nInt != 0)? \ + (((RwReal)1)/determinant.nReal): \ + ((RwReal)1) ); \ + \ + (_rAA) *= normalize; \ + (_rAB) *= normalize; \ + (_rAC) *= normalize; \ + (_rAD) *= normalize; \ + \ + (_rBA)= -rwMat03Det(_mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBB)= rwMat03Det(_mAA, _mAC, _mAD, \ + _mCA, _mCC, _mCD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBC)= -rwMat03Det(_mAA, _mAC, _mAD, \ + _mBA, _mBC, _mBD, \ + _mDA, _mDC, _mDD) * normalize ; \ + (_rBD)= rwMat03Det(_mAA, _mAC, _mAD, \ + _mBA, _mBC, _mBD, \ + _mCA, _mCC, _mCD) * normalize ; \ + \ + (_rCA)= rwMat03Det(_mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCB)= -rwMat03Det(_mAA, _mAB, _mAD, \ + _mCA, _mCB, _mCD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCC)= rwMat03Det(_mAA, _mAB, _mAD, \ + _mBA, _mBB, _mBD, \ + _mDA, _mDB, _mDD) * normalize ; \ + (_rCD)= -rwMat03Det(_mAA, _mAB, _mAD, \ + _mBA, _mBB, _mBD, \ + _mCA, _mCB, _mCD) * normalize ; \ + \ + (_rDA)= -rwMat03Det(_mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDB)= rwMat03Det(_mAA, _mAB, _mAC, \ + _mCA, _mCB, _mCC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDC)= -rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mDA, _mDB, _mDC) * normalize ; \ + (_rDD)= rwMat03Det(_mAA, _mAB, _mAC, \ + _mBA, _mBB, _mBC, \ + _mCA, _mCB, _mCC) * normalize ; \ + } \ +} \ +MACRO_STOP + + +/*--- Automatically derived from: C:/daily/rwsdk/driver/d3d8/drvmodel.h ---*/ +#ifndef D3D8_DRVMODEL_H +#define D3D8_DRVMODEL_H + +#if (defined(__ICL)) +/* Avoid voluminous + * 'warning #344: typedef name has already been declared (with same type)' + * warnings from MS include files + */ +#pragma warning( disable : 344 ) +#endif /* (defined(__ICL)) */ + + +#include + +#if (defined(RWDEBUG)) +#if (defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) +#define _CRTDBG_MAP_ALLOC +#endif /* defined(RWMEMDEBUG) && !defined(_CRTDBG_MAP_ALLOC)) */ +#include +#define ERR_WRAP(A) (_rwRePrintErrorDDD3D((A), __FILE__, __LINE__)) +#endif /* (defined(RWDEBUG)) */ + +#if (!defined(ERR_WRAP)) +#define ERR_WRAP(A) (A) +#endif /* (!defined(ERR_WRAP)) */ + +/**************************************************************************** + Defines + */ + +/* Set true depth information (for fogging, eg) */ +#define RwIm2DVertexSetCameraX(vert, camx) /* Nothing */ +#define RwIm2DVertexSetCameraY(vert, camy) /* Nothing */ +#define RwIm2DVertexSetCameraZ(vert, camz) /* Nothing */ + +#define RwIm2DVertexSetRecipCameraZ(vert, recipz) ((vert)->rhw = recipz) + +#define RwIm2DVertexGetCameraX(vert) (cause an error) +#define RwIm2DVertexGetCameraY(vert) (cause an error) +#define RwIm2DVertexGetCameraZ(vert) (cause an error) +#define RwIm2DVertexGetRecipCameraZ(vert) ((vert)->rhw) + +/* Set screen space coordinates in a device vertex */ +#define RwIm2DVertexSetScreenX(vert, scrnx) ((vert)->x = (scrnx)) +#define RwIm2DVertexSetScreenY(vert, scrny) ((vert)->y = (scrny)) +#define RwIm2DVertexSetScreenZ(vert, scrnz) ((vert)->z = (scrnz)) +#define RwIm2DVertexGetScreenX(vert) ((vert)->x) +#define RwIm2DVertexGetScreenY(vert) ((vert)->y) +#define RwIm2DVertexGetScreenZ(vert) ((vert)->z) + +/* Set texture coordinates in a device vertex */ +#define RwIm2DVertexSetU(vert, texU, recipz) ((vert)->u = (texU)) +#define RwIm2DVertexSetV(vert, texV, recipz) ((vert)->v = (texV)) +#define RwIm2DVertexGetU(vert) ((vert)->u) +#define RwIm2DVertexGetV(vert) ((vert)->v) + +/* Modify the luminance stuff */ +#define RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + (((RwFastRealToUInt32(alpha)) << 24) | \ + ((RwFastRealToUInt32(red)) << 16) | \ + ((RwFastRealToUInt32(green)) << 8) | \ + ((RwFastRealToUInt32(blue))))) + +#define RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) \ + ((vert)->emissiveColor = \ + ((((RwUInt32)(alpha)) << 24) | \ + (((RwUInt32)(red)) << 16) | \ + (((RwUInt32)(green)) << 8) | \ + (((RwUInt32)(blue))))) + +#define RwIm2DVertexGetRed(vert) \ + (((vert)->emissiveColor >> 16) & 0xFF) + +#define RwIm2DVertexGetGreen(vert) \ + (((vert)->emissiveColor >> 8) & 0xFF) + +#define RwIm2DVertexGetBlue(vert) \ + ((vert)->emissiveColor & 0xFF) + +#define RwIm2DVertexGetAlpha(vert) \ + (((vert)->emissiveColor >> 24) & 0xFF) + +#define RwIm2DVertexCopyRGBA(dst, src) \ + ((dst)->emissiveColor = (src)->emissiveColor) + +/* Clipper stuff */ + +#define RwIm2DVertexClipRGBA(o, i, n, f) \ +MACRO_START \ +{ \ + const RwInt32 _factor = \ + (RwFastRealToUInt32(i * (RwReal)(255))) & 255; \ + \ + (o)->emissiveColor = \ + (((((RwIm2DVertexGetAlpha(f) - RwIm2DVertexGetAlpha(n)) * \ + _factor) >> 8) + RwIm2DVertexGetAlpha(n)) << 24) | \ + (((((RwIm2DVertexGetRed(f) - RwIm2DVertexGetRed(n)) * \ + _factor) >> 8) + RwIm2DVertexGetRed(n)) << 16) | \ + (((((RwIm2DVertexGetGreen(f) - RwIm2DVertexGetGreen(n)) * \ + _factor) >> 8) + RwIm2DVertexGetGreen(n)) << 8) | \ + (((((RwIm2DVertexGetBlue(f) - RwIm2DVertexGetBlue(n)) * \ + _factor) >> 8) + RwIm2DVertexGetBlue(n))); \ +} \ +MACRO_STOP + +/* LEGACY-SUPPORT macros */ +#define RWIM2DVERTEXSetCameraX(vert, camx) RwIm2DVertexSetCameraX(vert, camx) +#define RWIM2DVERTEXSetCameraY(vert, camy) RwIm2DVertexSetCameraY(vert, camy) +#define RWIM2DVERTEXSetCameraZ(vert, camz) RwIm2DVertexSetCameraZ(vert, camz) +#define RWIM2DVERTEXSetRecipCameraZ(vert, recipz) \ + RwIm2DVertexSetRecipCameraZ(vert, recipz) +#define RWIM2DVERTEXGetCameraX(vert) RwIm2DVertexGetCameraX(vert) +#define RWIM2DVERTEXGetCameraY(vert) RwIm2DVertexGetCameraY(vert) +#define RWIM2DVERTEXGetCameraZ(vert) RwIm2DVertexGetCameraZ(vert) +#define RWIM2DVERTEXGetRecipCameraZ(vert) RwIm2DVertexGetRecipCameraZ(vert) +#define RWIM2DVERTEXSetScreenX(vert, scrnx) RwIm2DVertexSetScreenX(vert, scrnx) +#define RWIM2DVERTEXSetScreenY(vert, scrny) RwIm2DVertexSetScreenY(vert, scrny) +#define RWIM2DVERTEXSetScreenZ(vert, scrnz) RwIm2DVertexSetScreenZ(vert, scrnz) +#define RWIM2DVERTEXGetScreenX(vert) RwIm2DVertexGetScreenX(vert) +#define RWIM2DVERTEXGetScreenY(vert) RwIm2DVertexGetScreenY(vert) +#define RWIM2DVERTEXGetScreenZ(vert) RwIm2DVertexGetScreenZ(vert) +#define RWIM2DVERTEXSetU(vert, u, recipz) RwIm2DVertexSetU(vert, u, recipz) +#define RWIM2DVERTEXSetV(vert, v, recipz) RwIm2DVertexSetV(vert, v, recipz) +#define RWIM2DVERTEXGetU(vert) RwIm2DVertexGetU(vert) +#define RWIM2DVERTEXGetV(vert) RwIm2DVertexGetV(vert) +#define RWIM2DVERTEXSetRealRGBA(vert, red, green, blue, alpha) \ + RwIm2DVertexSetRealRGBA(vert, red, green, blue, alpha) +#define RWIM2DVERTEXSetIntRGBA(vert, red, green, blue, alpha) \ + RwIm2DVertexSetIntRGBA(vert, red, green, blue, alpha) +#define RWIM2DVERTEXGetRed(vert) RwIm2DVertexGetRed(vert) +#define RWIM2DVERTEXGetGreen(vert) RwIm2DVertexGetGreen(vert) +#define RWIM2DVERTEXGetBlue(vert) RwIm2DVertexGetBlue(vert) +#define RWIM2DVERTEXGetAlpha(vert) RwIm2DVertexGetAlpha(vert) +#define RWIM2DVERTEXCopyRGBA(dst, src) RwIm2DVertexCopyRGBA(dst, src) +#define RWIM2DVERTEXClipRGBA(o, i, n, f) RwIm2DVertexClipRGBA(o, i, n, f) + +/**************************************************************************** + Global Types + */ + +/* We use RwD3D8Vertex to drive the hardware in 2D mode */ + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwD3D8Vertex + * D3D8 vertex structure definition for 2D geometry + */ +typedef struct RwD3D8Vertex RwD3D8Vertex; +/** + * \ingroup rwcoredriverd3d8 + * \struct RwD3D8Vertex + * D3D8 vertex structure definition for 2D geometry + */ +struct RwD3D8Vertex +{ + RwReal x; /**< Screen X */ + RwReal y; /**< Screen Y */ + RwReal z; /**< Screen Z */ + RwReal rhw; /**< Reciprocal of homogeneous W */ + + RwUInt32 emissiveColor; /**< Vertex color */ + + RwReal u; /**< Texture coordinate U */ + RwReal v; /**< Texture coordinate V */ +}; + +/* Define types used */ + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwIm2DVertex + * Typedef for a RenderWare Graphics Immediate Mode 2D Vertex + */ +typedef RwD3D8Vertex RwIm2DVertex; + +/* LEGACY-SUPPORT macro */ +/** + * \ingroup rwcoredriverd3d8 + * \def RWIM2DVERTEX + * RWIM2DVERTEX is a legacy macro for RwIm2DVertex + */ +#define RWIM2DVERTEX RwIm2DVertex + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RxVertexIndex + * + * Typedef for a RenderWare Graphics PowerPipe Immediate + * Mode Vertex + */ +typedef RwUInt16 RxVertexIndex; + +/** + * \ingroup rwcoredriverd3d8 + * \typedef RwImVertexIndex + * Typedef for a RenderWare Graphics Immediate Mode Vertex. + */ +typedef RxVertexIndex RwImVertexIndex; + +/* LEGACY-SUPPORT macro */ +/** + * \ingroup rwcoredriverd3d8 + * \def RWIMVERTEXINDEX + * RWIMVERTEXINDEX is a legacy macro for RwImVertexIndex + */ +#define RWIMVERTEXINDEX RwImVertexIndex + +/** + * \ingroup rwcoredriverd3d8 + * \struct RwD3D8Metrics + * Structure containing metrics counters + */ +typedef struct +{ + RwUInt32 numRenderStateChanges; /**< Number of Render States changed */ + RwUInt32 numTextureStageStateChanges; /**< Number of Texture Stage States changed */ + RwUInt32 numMaterialChanges; /**< Number of Material changes */ + RwUInt32 numLightsChanged; /**< Number of Lights changed */ +} +RwD3D8Metrics; + +#endif /* D3D8_DRVMODEL_H */ + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bavector.h ---*/ + +/* + * Typedef for pointer to Vector multiplication by Matrix function + */ + +typedef RwV3d *(*rwVectorMultFn) (RwV3d * pointsOut, + const RwV3d * pointsIn, + RwInt32 numPoints, + const RwMatrix * matrix); + + +/* If sqrt is overloaded for this platform, we will remove + * all the sqrt table stuff from the build entirely + * currently applies to SKY2 and XBOX - IDBS [2/11/2001] + * [and, if using the intel compiler version 400 or above, + * we will use the single-precision float "sqrtf" under + * D3D7, D3D8, OpenGL or SoftRas] */ +#if (defined(rwSqrtMacro)) +#define RWNOSQRTTABLE +#endif /* (defined(rwSqrtMacro)) */ +#if (defined(rwInvSqrtMacro)) +#define RWNOINVSQRTTABLE +#endif /* (defined(rwSqrtMacro)) */ + +#if (!defined(rwSqrtMacro)) +#define rwSqrtMacro(_root, _input) \ + ( *(_root) = _rwSqrt(_input) ) +#endif /* (!defined(rwSqrtMacro)) */ + +#if (!defined(rwInvSqrtMacro)) +#define rwInvSqrtMacro(_recip, _input) \ + ( *(_recip) = _rwInvSqrt(_input) ) +#endif /* (!defined(rwInvSqrtMacro)) */ + +#if (!defined(rwSqrtInvSqrtMacro)) +#define rwSqrtInvSqrtMacro(_root, _recip, _input) \ +MACRO_START \ +{ \ + RwReal _tmp = _input; \ + rwSqrt((_root), _tmp); \ + rwInvSqrt((_recip), _tmp); \ +} \ +MACRO_STOP +#endif /* (!defined(rwSqrtInvSqrtMacro)) */ + +/* Vector operations Macros */ + +#if (!defined(RwV2dAssignMacro)) +#define RwV2dAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwV2dAssignMacro)) */ + +#define RwV2dAddMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ( (b)->x)); \ + (o)->y = (((a)->y) + ( (b)->y)); \ +} \ +MACRO_STOP + +#define RwV2dSubMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) - ( (b)->x)); \ + (o)->y = (((a)->y) - ( (b)->y)); \ +} \ +MACRO_STOP + +#define RwV2dScaleMacro(o, i, s) \ +MACRO_START \ +{ \ + (o)->x = (((i)->x) * ( (s))); \ + (o)->y = (((i)->y) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV2dDotProductMacro(a,b) \ + (( ((((a)->x) * ( (b)->x))) + \ + ( (((a)->y) * ( (b)->y))))) \ + +#define _rwV2dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV2dDotProductMacro((_in), (_in)); \ + rwInvSqrtMacro(&(_result), length2); \ + RwV2dScaleMacro((_out), (_in), (_result)); \ +} \ +MACRO_STOP + +#define RwV2dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV2dDotProductMacro((_in), (_in)); \ + RwReal recip; \ + \ + rwSqrtInvSqrtMacro(&(_result), &recip, length2); \ + RwV2dScaleMacro((_out), (_in), recip); \ +} \ +MACRO_STOP + +#define RwV2dLengthMacro(_result, _in) \ +MACRO_START \ +{ \ + (_result) = RwV2dDotProductMacro(_in, _in); \ + rwSqrtMacro(&(_result), (_result)); \ +} \ +MACRO_STOP + +#define RwV2dLineNormalMacro(_o, _a, _b) \ +MACRO_START \ +{ \ + RwReal recip; \ + \ + (_o)->y = (((_b)->x) - ( (_a)->x)); \ + (_o)->x = (((_a)->y) - ( (_b)->y)); \ + _rwV2dNormalizeMacro(recip, _o,_o); \ +} \ +MACRO_STOP + +#define RwV2dPerpMacro(o, a) \ +MACRO_START \ +{ \ + (o)->x = -(a)->y; \ + (o)->y = (a)->x; \ +} \ +MACRO_STOP + +/* RwV3d */ + +#if (!defined(RwV3dAssignMacro)) +#define RwV3dAssignMacro(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwV3dAssignMacro)) */ + + +#define RwV3dAddMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) + ( (b)->x)); \ + (o)->y = (((a)->y) + ( (b)->y)); \ + (o)->z = (((a)->z) + ( (b)->z)); \ +} \ +MACRO_STOP + +#define RwV3dSubMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) - ( (b)->x)); \ + (o)->y = (((a)->y) - ( (b)->y)); \ + (o)->z = (((a)->z) - ( (b)->z)); \ +} \ +MACRO_STOP + +#define RwV3dScaleMacro(o, a, s) \ +MACRO_START \ +{ \ + (o)->x = (((a)->x) * ( (s))); \ + (o)->y = (((a)->y) * ( (s))); \ + (o)->z = (((a)->z) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV3dIncrementScaledMacro(o, a, s) \ +MACRO_START \ +{ \ + (o)->x += (((a)->x) * ( (s))); \ + (o)->y += (((a)->y) * ( (s))); \ + (o)->z += (((a)->z) * ( (s))); \ +} \ +MACRO_STOP + +#define RwV3dNegateMacro(o, a) \ +MACRO_START \ +{ \ + (o)->x = -(a)->x; \ + (o)->y = -(a)->y; \ + (o)->z = -(a)->z; \ +} \ +MACRO_STOP + +#define RwV3dDotProductMacro(a, b) \ + ((((( (((a)->x) * ((b)->x))) + \ + ( (((a)->y) * ((b)->y))))) + \ + ( (((a)->z) * ((b)->z))))) \ + +#define RwV3dCrossProductMacro(o, a, b) \ +MACRO_START \ +{ \ + (o)->x = \ + (( (((a)->y) * ( (b)->z))) - \ + ( (((a)->z) * ( (b)->y)))); \ + (o)->y = \ + (( (((a)->z) * ( (b)->x))) - \ + ( (((a)->x) * ( (b)->z)))); \ + (o)->z = \ + (( (((a)->x) * ( (b)->y))) - \ + ( (((a)->y) * ( (b)->x)))); \ +} \ +MACRO_STOP + +#define _rwV3dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV3dDotProductMacro(_in, _in); \ + rwInvSqrtMacro(&(_result), length2); \ + RwV3dScaleMacro(_out, _in, _result); \ +} \ +MACRO_STOP + +#define RwV3dNormalizeMacro(_result, _out, _in) \ +MACRO_START \ +{ \ + RwReal length2 = RwV3dDotProductMacro((_in), (_in)); \ + RwReal recip; \ + \ + rwSqrtInvSqrtMacro(&(_result), &recip, length2); \ + RwV3dScaleMacro((_out), (_in), recip); \ +} \ +MACRO_STOP + +#define RwV3dLengthMacro(_result, _in) \ +MACRO_START \ +{ \ + (_result) = RwV3dDotProductMacro(_in, _in); \ + rwSqrtMacro(&(_result), _result); \ +} \ +MACRO_STOP + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RwV2dAssign(o, a) RwV2dAssignMacro(o, a) +#define RwV2dAdd(o, a, b) RwV2dAddMacro(o, a, b) +#define RwV2dSub(o, a, b) RwV2dSubMacro(o, a, b) +#define RwV2dLineNormal(_o, _a, _b) RwV2dLineNormalMacro(_o, _a, _b) +#define RwV2dScale(o, i, s) RwV2dScaleMacro(o, i, s) +#define RwV2dDotProduct(a,b) RwV2dDotProductMacro(a,b) +#define RwV2dPerp(o, a) RwV2dPerpMacro(o, a) +#define RwV3dAssign(o, a) RwV3dAssignMacro(o, a) +#define RwV3dAdd(o, a, b) RwV3dAddMacro(o, a, b) +#define RwV3dSub(o, a, b) RwV3dSubMacro(o, a, b) +#define RwV3dScale(o, a, s) RwV3dScaleMacro(o, a, s) +#define RwV3dIncrementScaled(o, a, s) RwV3dIncrementScaledMacro(o, a, s) +#define RwV3dNegate(o, a) RwV3dNegateMacro(o, a) +#define RwV3dDotProduct(a, b) RwV3dDotProductMacro(a, b) +#define RwV3dCrossProduct(o, a, b) RwV3dCrossProductMacro(o, a, b) + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +#define RWRAD2DEG(_x) ((_x) * (((RwReal)180)/(rwPI))) + +#if (!defined(rw4OVERPISQ)) +#define rw4OVERPISQ ( ((RwReal)4) / ( rwPI * rwPI )) +#endif /* (!defined(rw4OVERPISQ)) */ + +#if (!defined(rwPI3)) +#define rwPI3 (rwPI * (RwReal)3) +#endif /* (!defined(rwPI3)) */ + +#if (!defined(rwPI3OVER2)) +#define rwPI3OVER2 ( rwPI3 / (RwReal)2 ) +#endif /* (!defined(rwPI3OVER2)) */ + +#if (!defined(rwPI3OVER8)) +#define rwPI3OVER8 (rwPI3 / (RwReal)8 ) +#endif /* (!defined(rwPI3OVER8)) */ + +#define RwQuadSin(_x) \ + ( rw4OVERPISQ * \ + ( ( (_x) < 0 ) ? \ + ( ( rwPI + (_x) ) * (_x) ) : \ + ( ( rwPI - (_x) ) * (_x) ) ) ) + +#define RwQuadASin(_result, _s) \ + ( rwPIOVER2 * ( ((_s)<0) ? \ + ( rwSqrtMacro((_result), 1.0f + (_s)) - 1 ) : \ + ( 1 - rwSqrtMacro((_result), 1.0f - (_s)) ) ) ) + +#define RwQuadCos(_x) \ + ( rw4OVERPISQ * \ + ( ( (_x) < -rwPIOVER2 ) ? \ + ( ( -rwPI3OVER2 - (_x) ) * ( -rwPIOVER2 - (_x) ) ) : \ + ( ( (_x) < rwPIOVER2) ? \ + ( ( rwPIOVER2 + (_x) ) * ( rwPIOVER2 - (_x) ) ) : \ + ( ( rwPIOVER2 - (_x) ) * ( rwPI3OVER2 - (_x) ) ) ) ) ) + +#define RwQuadACos(_result, _c) \ + ( rwPIOVER2 * ( ((_c)<0) ? \ + (2.0f - rwSqrtMacro((_result), 1.0f + (_c))): \ + rwSqrtMacro((_result), 1.0f - (_c))) ) + +#define RwQuadTan(_x) \ + ( rwPI3 * (_x) / ( rwPI * rwPI - (_x) * (_x) * 4.0f ) ) + +#define RwQuadATan(_result, _t) \ + ( ( rwSqrtMacro((_result), (rwPI3OVER8 * rwPI3OVER8) + \ + (_t) * (_t) * (rwPIOVER2 * rwPIOVER2) ) - rwPI3OVER8 ) \ + / ( _t) ) + +#define RwQuadATan2(_result, _s, _c) \ + ( ( rwSqrtMacro((_result), (_c) * (_c) * (rwPI3OVER8 * rwPI3OVER8) + \ + (_s) * (_s) * (rwPIOVER2 * rwPIOVER2) ) \ + - (_c) * rwPI3OVER8 ) / ( _s) ) + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Other useful stuff */ + +extern RwReal RwV3dNormalize(RwV3d * out, const RwV3d * in); +extern RwReal RwV3dLength(const RwV3d * in); + +extern RwReal RwV2dLength(const RwV2d * in); +extern RwReal RwV2dNormalize(RwV2d * out, const RwV2d * in); + +#if ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) + +extern void RwV2dAssign(RwV2d * out, + const RwV2d * ina); +extern void RwV2dAdd(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dLineNormal(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dSub(RwV2d * out, + const RwV2d * ina, const RwV2d * inb); +extern void RwV2dPerp(RwV2d * out, const RwV2d * in); +extern void RwV2dScale(RwV2d * out, + const RwV2d * in, RwReal scalar); +extern RwReal RwV2dDotProduct(const RwV2d * ina, const RwV2d * inb); + +extern void RwV3dAssign(RwV3d * out, + const RwV3d * ina); +extern void RwV3dAdd(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); +extern void RwV3dSub(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); +extern void RwV3dScale(RwV3d * out, + const RwV3d * in, RwReal scalar); +extern void RwV3dIncrementScaled(RwV3d * out, + const RwV3d * in, RwReal scalar); +extern void RwV3dNegate(RwV3d * out, const RwV3d * in); +extern RwReal RwV3dDotProduct(const RwV3d * ina, const RwV3d * inb); +extern void RwV3dCrossProduct(RwV3d * out, + const RwV3d * ina, const RwV3d * inb); + +#endif /* ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) ) */ + +/* Transform points/vectors */ +extern RwV3d *RwV3dTransformPoints(RwV3d * pointsOut, + const RwV3d * pointsIn, + RwInt32 numPoints, + const RwMatrix * matrix); +extern RwV3d *RwV3dTransformVectors(RwV3d * vectorsOut, + const RwV3d * vectorsIn, + RwInt32 numPoints, + const RwMatrix * matrix); + +/* SPI */ + +#if (!defined(RWNOSQRTTABLE)) +extern RwReal _rwSqrt(const RwReal num); +#endif /* (!defined(RWNOSQRTTABLE)) */ +#if (!defined(RWNOINVSQRTTABLE)) +extern RwReal _rwInvSqrt(const RwReal num); +#endif /* (!defined(RWNOINVSQRTTABLE)) */ + +extern RwReal _rwV3dNormalize(RwV3d * out, const RwV3d * in); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define rwVectorOpen(instance, offset, size) \ + _rwVectorOpen(instance, offset, size) + +#define rwVectorClose(instance, offset, size) \ + _rwVectorClose(instance, offset, size) + +#define rwVectorSetMultFn(multPoint,multVector) \ + _rwVectorSetMultFn(multPoint,multVector) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/balist.h ---*/ +/**************************************************************************** + Global Types + */ + +typedef struct RwSList RwSList; +struct RwSList +{ + RwUInt8 *listElements; + RwInt32 numElementsFilled; + RwInt32 numElementsAlloced; + RwInt32 entrySize; +}; + + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* SList functions */ +extern RwSList *_rwSListCreate(RwInt32 size); +extern RwBool _rwSListDestroy(RwSList *sList); +extern RwBool _rwSListDestroyArray(RwUInt8 *array); +extern void _rwSListDestroyEndEntries(RwSList *sList, RwInt32 amount); +extern RwBool _rwSListDestroyEntry(RwSList *sList, RwInt32 entry); +extern void _rwSListEmpty(RwSList *sList); +extern void *_rwSListGetArray(RwSList *sList); +extern void *_rwSListGetEntry(RwSList *sList, RwInt32 entry); +extern void *_rwSListGetNewEntry(RwSList *sList); +extern void *_rwSListGetNewEntries(RwSList *sList, RwInt32 entry); +extern RwInt32 _rwSListGetNumEntries(const RwSList *sList); +extern RwBool _rwSListReleaseArray(RwSList *sList); +extern void *_rwSListToArray(RwSList *sList); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Comparibility macros */ + +#define rwSListCreate(size) \ + _rwSListCreate(size) +#define rwSListDestroy(sList) \ + _rwSListDestroy(sList) +#define rwSListDestroyArray(array) \ + _rwSListDestroyArray(array) +#define rwSListDestroyEndEntries(sList, amount) \ + _rwSListDestroyEndEntries(sList, amount) +#define rwSListDestroyEntry(sList, entry) \ + _rwSListDestroyEntry(sList, entry) +#define rwSListEmpty(sList) \ + _rwSListEmpty(sList) +#define rwSListGetArray(sList) \ + _rwSListGetArray(sList) +#define rwSListGetEntry(sList, entry) \ + _rwSListGetEntry(sList, entry) +#define rwSListGetNewEntry(sList) \ + _rwSListGetNewEntry(sList) +#define rwSListGetNewEntries(sList, entry) \ + _rwSListGetNewEntries(sList, entry) +#define rwSListGetNumEntries(sList) \ + _rwSListGetNumEntries(sList) +#define rwSListReleaseArray(sList) \ + _rwSListReleaseArray(sList) +#define rwSListToArray(sList) \ + _rwSListToArray(sList) + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/baimmedi.h ---*/ + +/**************************************************************************** + Defines + */ + + +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + Immediate mode interface V2.0 + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +/** + * \ingroup datatypes + * RwRenderState + * This type represents the various render states that + * can be set using the API function \ref RwRenderStateSet. This function also + * takes a render state value or pointer to an object depending on the type. + * For render states that are toggles, the value should be TRUE to switch the + * state on and FALSE to turn it off. + * + * Note that many of these render states may not be supported on certain + * platforms. The \ref RwRenderStateSet functions will return FALSE in such cases. + */ +enum RwRenderState +{ + rwRENDERSTATENARENDERSTATE = 0, + rwRENDERSTATETEXTURERASTER, /**>8)+8: RWBYTEFINDMSB(a)) + +#define RWLONGFINDMSB(a) \ + (((a)&0xffff0000UL)?RWWORDFINDMSB((a)>>16)+16: RWWORDFINDMSB(a)) + +/**************************************************************************** + Defines + */ + +/* macros used to access plugin data in objects */ +#define RWPLUGINOFFSET(_type, _base, _offset) \ + ((_type *)((RwUInt8 *)(_base) + (_offset))) + +#define RWPLUGINOFFSETCONST(_type, _base, _offset) \ + ((const _type *)((const RwUInt8 *)(_base) + (_offset))) + +/* macro used to access global data structure (the root type is RwGlobals) */ +#define RWSRCGLOBAL(variable) \ + (((RwGlobals *)RwEngineInstance)->variable) + +#define RWASSERTISTYPE(_f, _t) \ + RWASSERT((((const RwObject *)(_f))->type)==(_t)) + +/**************************************************************************** + Global Types + */ + +enum RwEngineStatus +{ + rwENGINESTATUSIDLE = 0, /* This needs to be zero */ + rwENGINESTATUSINITED = 1, + rwENGINESTATUSOPENED = 2, + rwENGINESTATUSSTARTED = 3, + rwENGINESTATUSFORCEENUMSIZEINT = RWFORCEENUMSIZEINT +}; +typedef enum RwEngineStatus RwEngineStatus; + +typedef struct RwGlobals RwGlobals; +struct RwGlobals +{ +#ifdef RWDEBUG + RwDebugHandler debugFunction; /* debug string handler */ + void *debugFile; /* debug output file */ + RwInt32 debugStackDepth; /* current depth of function stack */ + RwBool debugTrace; /* is function tracing enabled */ +#endif + + /* Current entities */ + void *curCamera; /* Current camera */ + void *curWorld; /* Current World */ + + /* Checking counters */ + RwUInt16 renderFrame; /* Camera display count */ + RwUInt16 lightFrame; /* Used to ensure each light is applied only once. */ + RwUInt16 pad[2]; /* Longword align it again */ + + /* For the currently accessed device */ + RwDevice dOpenDevice; + + /* Standard renderers and functions */ + RwStandardFunc stdFunc[rwSTANDARDNUMOFSTANDARD]; + + /* All of the frames which have been updated */ + RwLinkList dirtyFrameList; + + /* The file functions */ + RwFileFunctions fileFuncs; + + /* The string functions */ + RwStringFunctions stringFuncs; + + /* The memory allocation functions */ + RwMemoryFunctions memoryFuncs; +#ifdef RWDEBUG + RwBool freeListExtraDebug; +#endif /* RWDEBUG */ + + /* virtual memory alloc/free functions */ + RwMemoryAllocFn memoryAlloc; + RwMemoryFreeFn memoryFree; + + RwMetrics *metrics; + + /* Current engine status */ + RwEngineStatus engineStatus; + + /* Resource arena init size. */ + RwUInt32 resArenaInitSize; +}; + +typedef struct RwModuleInfo RwModuleInfo; +struct RwModuleInfo +{ + RwInt32 globalsOffset; + RwInt32 numInstances; +}; + + + +/**************************************************************************** + Program wide globals + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef RWGLOBALSIZE +extern RwUInt32 ourGlobals[RWGLOBALSIZE / sizeof(RwUInt32)]; +#define RwEngineInstance ourGlobals +#else /* RWGLOBALSIZE */ +extern void *RwEngineInstance; +#endif /* RWGLOBALSIZE */ + +extern RwInt8 _rwMsbBit[]; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/baresour.h ---*/ + +#define RWRESOURCESGLOBAL(var) (RWPLUGINOFFSET(rwResourcesGlobals, \ + RwEngineInstance, resourcesModule.globalsOffset)->var) + +/** + * \ingroup datatypes + * \typedef RwResEntry + * RwResEntry object. Instanced data block in resources arena. + * This should be considered an opaque + * type. Use the RwResEntry API functions to access. + */ +typedef struct RwResEntry RwResEntry; + +/** + * \ingroup datatypes + * \typedef RwResEntryDestroyNotify + * This type represents the function + * called from \ref RwResourcesFreeResEntry (and indirectly from + * \ref RwResourcesEmptyArena) immediately before the memory used by the + * specified resources entry is released. + * + * \param resEntry Pointer to the instanced data. + */ +typedef void (*RwResEntryDestroyNotify) (RwResEntry * resEntry); + +#if (!defined(DOXYGEN)) +struct RwResEntry +{ + RwLLLink link; /**< Node in the list of resource elements */ + RwInt32 size; /**< Size of this node */ + void *owner; /**< Owner of this node */ + RwResEntry **ownerRef; /**< Pointer to pointer to this (enables de-alloc) */ + RwResEntryDestroyNotify destroyNotify; /**< This is called right before destruction */ +}; +#endif /* (!defined(DOXYGEN)) */ + +typedef struct rwResources rwResources; +struct rwResources +{ + RwInt32 maxSize; + RwInt32 currentSize; + RwInt32 reusageSize; + + void *memHeap; + + RwLinkList entriesA; + RwLinkList entriesB; + + RwLinkList *freeEntries; + RwLinkList *usedEntries; +}; + +typedef struct rwResourcesGlobals rwResourcesGlobals; +struct rwResourcesGlobals +{ + rwResources res; +}; + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Setting the resources arena size */ +extern RwBool RwResourcesSetArenaSize(RwUInt32 size); +extern RwInt32 RwResourcesGetArenaSize(void); +extern RwInt32 RwResourcesGetArenaUsage(void); +extern RwBool RwResourcesEmptyArena(void); + +/* Allocate */ +extern RwResEntry *RwResourcesAllocateResEntry(void *owner, + RwResEntry **ownerRef, + RwInt32 size, + RwResEntryDestroyNotify + destroyNotify); +/* Deallocate */ +extern RwBool RwResourcesFreeResEntry(RwResEntry * entry); +/* Mark all as unused */ +extern void _rwResourcesPurge(void); +#if ((defined(RWDEBUG)) || (defined(RWSUPPRESSINLINE))) +/* Mark as used */ +extern RwResEntry *RwResourcesUseResEntry(RwResEntry * entry); +#endif /* ((defined(RWDEBUG)) || (defined(RWSUPPRESSINLINE))) */ + +extern RwModuleInfo resourcesModule; + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#if ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) +#define RwResourcesUseResEntry(_ntry) \ + ((((_ntry)->link.next)? \ + (rwLinkListRemoveLLLink(&((_ntry)->link)), \ + rwLinkListAddLLLink(RWRESOURCESGLOBAL(res.usedEntries), \ + &((_ntry)->link))): \ + NULL), \ + (_ntry)) +#endif /* ((!defined(RWDEBUG)) && (!defined(RWSUPPRESSINLINE))) */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/bacolor.h ---*/ +/**************************************************************************** + Global Types + */ + +typedef struct RwRGBAReal RwRGBAReal; +/** + * \ingroup datatypes + * \struct RwRGBAReal + * This structure represents a RGBA color which has + * components specified as real values. + * + * A color component of an RwRGBA with the value 255 generally corresponds + * to the associated component in an RwRGBAReal with the value 1.0f. + * However, any values can be substituted to denormalize/normalize + * RwRGBAReal and create different effects. For example, while light colors + * are expressed as normalized RGBA, interesting effects can be gained using + * larger values. + * + * It should also be noted that a color component of an RwRGBA with the + * value 0 generally corresponds to the associcated component in an + * RwRGBAReal with the value 0.0. + */ +struct RwRGBAReal +{ + RwReal red; /**< red component */ + RwReal green; /**< green component */ + RwReal blue; /**< blue component */ + RwReal alpha; /**< alpha component */ +}; + +#if (!defined(RwRGBARealAssign)) +#define RwRGBARealAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwRGBARealAssign)) */ + +typedef struct RwRGBA RwRGBA; +/** + * \ingroup datatypes + * \struct RwRGBA + * This structure represents a RGBA color + * which has integer components specified in the range 0 to 255. */ +struct RwRGBA +{ + RwUInt8 red; /**< red component */ + RwUInt8 green; /**< green component */ + RwUInt8 blue; /**< blue component */ + RwUInt8 alpha; /**< alpha component */ +}; + +#if (!defined(RwRGBAAssign)) +#define RwRGBAAssign(_target, _source) \ + ( *(_target) = *(_source) ) +#endif /* (!defined(RwRGBAAssign)) */ + +#define RwRGBARealAddMacro(o,a,b) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) + ( (b)->red)); \ + (o)->green = (((a)->green) + ( (b)->green)); \ + (o)->blue = (((a)->blue) + ( (b)->blue)); \ + (o)->alpha = (((a)->alpha) + ( (b)->alpha)); \ +} \ +MACRO_STOP + +#define RwRGBARealSubMacro(o,a,b) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) - ( (b)->red)); \ + (o)->green = (((a)->green) - ( (b)->green)); \ + (o)->blue = (((a)->blue) - ( (b)->blue)); \ + (o)->alpha = (((a)->alpha) - ( (b)->alpha)); \ +} \ +MACRO_STOP + +#define RwRGBARealScaleMacro(o,a,scale) \ +MACRO_START \ +{ \ + (o)->red = (((a)->red) * ( scale)); \ + (o)->green = (((a)->green) * ( scale)); \ + (o)->blue = (((a)->blue) * ( scale)); \ + (o)->alpha = (((a)->alpha) * ( scale)); \ +} \ +MACRO_STOP + +/* Conversion macros */ +#define RwRGBAFromRwRGBARealMacro(o, i) \ +MACRO_START \ +{ \ + RwInt32 quantize; \ + \ + quantize = RwInt32FromRealMacro( ((i)->red * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->red = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->green * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->green = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->blue * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->blue = (RwUInt8) quantize; \ + quantize = RwInt32FromRealMacro( ((i)->alpha * (RwReal)255.0) \ + + (RwReal)0.5 ); \ + (o)->alpha = (RwUInt8) quantize; \ + \ +} \ +MACRO_STOP + +#define RwRGBARealFromRwRGBAMacro(o, i) \ +MACRO_START \ +{ \ + (o)->red = \ + (((RwReal)(((i)->red))) * ( (RwReal)((1.0/255.0)))); \ + (o)->green = \ + (((RwReal)(((i)->green))) * ( (RwReal)((1.0/255.0)))); \ + (o)->blue = \ + (((RwReal)(((i)->blue))) * ( (RwReal)((1.0/255.0)))); \ + (o)->alpha = \ + (((RwReal)(((i)->alpha))) * ( (RwReal)((1.0/255.0)))); \ +} \ +MACRO_STOP + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + +#if (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) + +#define RwRGBARealAdd(o,a,b) \ + RwRGBARealAddMacro(o,a,b) + +#define RwRGBARealSub(o,a,b) \ + RwRGBARealSubMacro(o,a,b) + +#define RwRGBARealScale(o,a,scale) \ + RwRGBARealScaleMacro(o,a,scale) + +#define RwRGBAFromRwRGBAReal(o, i) \ + RwRGBAFromRwRGBARealMacro(o, i) + +#define RwRGBARealFromRwRGBA(o, i) \ + RwRGBARealFromRwRGBAMacro(o, i) + +#else /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +/* Function versions for debug */ +extern void RwRGBARealAdd(RwRGBAReal *result, + const RwRGBAReal *source1, + const RwRGBAReal *source2); + +extern void RwRGBARealSub(RwRGBAReal *result, + const RwRGBAReal *source1, + const RwRGBAReal *source2); + +extern void RwRGBARealScale(RwRGBAReal *result, + const RwRGBAReal *source, + RwReal scalar); + +extern void RwRGBAFromRwRGBAReal(RwRGBA *result, + const RwRGBAReal *source); + +extern void RwRGBARealFromRwRGBA(RwRGBAReal *result, + RwRGBA *source); + +#endif /* (! ( defined(RWDEBUG) || defined(RWSUPPRESSINLINE) )) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/babinmtx.h ---*/ + +/**************************************************************************** + Global types + */ + +/* Matrix stream format */ +typedef struct rwStreamMatrix RwMatrixChunkInfo; +typedef struct rwStreamMatrix rwStreamMatrix; +struct rwStreamMatrix +{ + RwV3d right; + RwV3d up; + RwV3d at; + RwV3d pos; + RwInt32 type; +}; + + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Matrix binary format */ +extern RwUInt32 RwMatrixStreamGetSize(const RwMatrix * matrix); +extern RwMatrix *RwMatrixStreamRead(RwStream * stream, + RwMatrix * matrix); +extern const RwMatrix *RwMatrixStreamWrite(const RwMatrix * matrix, + RwStream * stream); +extern RwMatrixChunkInfo *RwMatrixChunkInfoRead(RwStream * stream, + RwMatrixChunkInfo * + matrixChunkInfo, + RwInt32 * bytesRead); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/*--- Automatically derived from: C:/daily/rwsdk/src/plcore/babinary.h ---*/ +/**************************************************************************** + Defines + */ + +#ifndef rwCHUNKHEADERSIZE +#define rwCHUNKHEADERSIZE (sizeof(RwUInt32)*3) +#endif /* rwCHUNKHEADERSIZE */ + +/* Compatibility macro */ +#define RwStreamWriteInt(_stream, _ints, _numBytes) \ + RwStreamWriteInt32(_stream, _ints, _numBytes) + +#define RwStreamReadInt(_stream, _ints, _numBytes) \ + RwStreamReadInt32(_stream, _ints, _numBytes) + +#define RwMemLittleEndian(_mem, _size) \ + RwMemLittleEndian32(_mem, _size) + +#define RwMemNative(_mem, _size) \ + RwMemNative32(_mem, _size) + +/**************************************************************************** + Global Types + */ + +typedef struct RwChunkHeaderInfo RwChunkHeaderInfo; +/** + * \ingroup datatypes + * \struct RwChunkHeaderInfo + * Holds data for a chunk header read from a + * stream with \ref RwStreamReadChunkHeaderInfo. */ +struct RwChunkHeaderInfo +{ + RwUInt32 type; /**< chunk ID - see \ref RwStreamFindChunk */ + RwUInt32 length; /**< length of the chunk data in bytes */ + RwUInt32 version; /**< version of the chunk data. + * See \ref RwEngineGetVersion. */ + RwUInt32 buildNum; /**< build number of the RenderWare libraries + * previously used to stream out the data */ + RwBool isComplex; /**< Internal Use */ +}; + +/**************************************************************************** + Function prototypes + */ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/* Chunk header stuff */ +extern RwBool RwStreamFindChunk(RwStream *stream, RwUInt32 type, + RwUInt32 *lengthOut, RwUInt32 *versionOut); + +#define RwStreamWriteChunkHeader(stream, type, size) \ + _rwStreamWriteVersionedChunkHeader( \ + stream, type, size, rwLIBRARYCURRENTVERSION, RWBUILDNUMBER) + +extern RwStream *_rwStreamWriteVersionedChunkHeader(RwStream *stream, + RwInt32 type, + RwInt32 size, + RwUInt32 version, + RwUInt32 buildNum); + +extern RwStream *RwStreamWriteReal(RwStream *stream, const RwReal *reals, + RwUInt32 numBytes); +extern RwStream *RwStreamWriteInt32(RwStream *stream, const RwInt32 *ints, + RwUInt32 numBytes); +extern RwStream *RwStreamWriteInt16(RwStream *stream, const RwInt16 *ints, + RwUInt32 numBytes); + +extern RwStream *RwStreamReadReal(RwStream *stream, RwReal *reals, + RwUInt32 numBytes); +extern RwStream *RwStreamReadInt32(RwStream *stream, RwInt32 *ints, + RwUInt32 numBytes); +extern RwStream *RwStreamReadInt16(RwStream *stream, RwInt16 *ints, + RwUInt32 numBytes); + +/* Binary Portability Functions */ +extern void *RwMemLittleEndian16(void *mem, RwUInt32 size); +extern void *RwMemLittleEndian32(void *mem, RwUInt32 size); +extern void *RwMemNative16(void *mem, RwUInt32 size); +extern void *RwMemNative32(void *mem, RwUInt32 size); +extern void *RwMemRealToFloat32(void *mem, RwUInt32 size); +extern void *RwMemFloat32ToReal(void *mem, RwUInt32 size); + +extern RwStream * +RwStreamReadChunkHeaderInfo(RwStream *stream, RwChunkHeaderInfo *chunkHeaderInfo); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RWPLCORE_H */ diff --git a/src/SurfaceTable.cpp b/src/SurfaceTable.cpp index e9ef459a..107734e4 100644 --- a/src/SurfaceTable.cpp +++ b/src/SurfaceTable.cpp @@ -1,7 +1,11 @@ #include "common.h" #include "patcher.h" +#include "Weather.h" +#include "Collision.h" #include "SurfaceTable.h" +float (*CSurfaceTable::ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS] = (float (*)[NUMADHESIVEGROUPS])0x8E29D4; + int CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) { @@ -42,3 +46,52 @@ CSurfaceTable::GetAdhesionGroup(uint8 surfaceType) default: return ADHESIVE_ROAD; } } + +float +CSurfaceTable::GetWetMultiplier(uint8 surfaceType) +{ + switch(surfaceType){ + case SURFACE_0: + case SURFACE_1: + case SURFACE_4: + case SURFACE_5: + case SURFACE_8: + case SURFACE_20: + case SURFACE_21: + case SURFACE_22: + case SURFACE_25: + case SURFACE_30: + case SURFACE_31: + return 1.0f - CWeather::WetRoads*0.25f; + + case SURFACE_2: + case SURFACE_6: + case SURFACE_7: + case SURFACE_9: + case SURFACE_10: + case SURFACE_11: + case SURFACE_12: + case SURFACE_13: + case SURFACE_14: + case SURFACE_15: + case SURFACE_16: + case SURFACE_17: + case SURFACE_23: + case SURFACE_24: + case SURFACE_26: + case SURFACE_27: + case SURFACE_28: + case SURFACE_29: + case SURFACE_32: + return 1.0f - CWeather::WetRoads*0.4f; + + default: + return 1.0f; + } +} + +float +CSurfaceTable::GetAdhesiveLimit(CColPoint &colpoint) +{ + return ms_aAdhesiveLimitTable[GetAdhesionGroup(colpoint.surfaceB)][GetAdhesionGroup(colpoint.surfaceA)]; +} diff --git a/src/SurfaceTable.h b/src/SurfaceTable.h index 556a6e04..f1ef3002 100644 --- a/src/SurfaceTable.h +++ b/src/SurfaceTable.h @@ -92,8 +92,14 @@ enum NUMADHESIVEGROUPS }; +struct CColPoint; + class CSurfaceTable { +// static float ms_aAdhesiveLimitTable[NUMADHESIVEGROUPS][NUMADHESIVEGROUPS]; + static float (*ms_aAdhesiveLimitTable)[NUMADHESIVEGROUPS]; public: static int GetAdhesionGroup(uint8 surfaceType); + static float GetWetMultiplier(uint8 surfaceType); + static float GetAdhesiveLimit(CColPoint &colpoint); }; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp new file mode 100644 index 00000000..cc8d4e8b --- /dev/null +++ b/src/audio/DMAudio.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "DMAudio.h" + +WRAPPER void cDMAudio::ReportCollision(CEntity *A, CEntity *B, uint8 surfA, uint8 surfB, float impulse, float speed) { EAXJMP(0x161684); } diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h new file mode 100644 index 00000000..8d49be27 --- /dev/null +++ b/src/audio/DMAudio.h @@ -0,0 +1,9 @@ +#pragma once + +class CEntity; + +class cDMAudio +{ +public: + static void ReportCollision(CEntity *A, CEntity *B, uint8 surfA, uint8 surfB, float impulse, float speed); +}; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp new file mode 100644 index 00000000..54491cd2 --- /dev/null +++ b/src/control/CarCtrl.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "CarCtrl.h" + +WRAPPER void CCarCtrl::SwitchVehicleToRealPhysics(CVehicle*) { EAXJMP(0x41F7F0); } \ No newline at end of file diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h new file mode 100644 index 00000000..fbe36f28 --- /dev/null +++ b/src/control/CarCtrl.h @@ -0,0 +1,9 @@ +#pragma once + +class CVehicle; + +class CCarCtrl +{ +public: + static void SwitchVehicleToRealPhysics(CVehicle*); +}; diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp index c528444e..947ac47c 100644 --- a/src/entities/Physical.cpp +++ b/src/entities/Physical.cpp @@ -10,6 +10,8 @@ #include "ParticleObject.h" #include "Particle.h" #include "SurfaceTable.h" +#include "CarCtrl.h" +#include "DMAudio.h" #include "Physical.h" void @@ -171,6 +173,145 @@ CPhysical::RemoveFromMovingList(void) } } +void +CPhysical::SetDamagedPieceRecord(uint16 piece, float impulse, CEntity *entity, CVector dir) +{ + m_nCollisionPieceType = piece; + m_fCollisionImpulse = impulse; + m_pCollidingEntity = entity; + entity->RegisterReference(&m_pCollidingEntity); + m_vecCollisionDirection = dir; +} + +void +CPhysical::AddCollisionRecord(CEntity *ent) +{ + AddCollisionRecord_Treadable(ent); + this->bHasCollided = true; + ent->bHasCollided = true; + if(IsVehicle() && ent->IsVehicle()){ + if(((CVehicle*)this)->m_nAlarmState == -1) + ((CVehicle*)this)->m_nAlarmState = 15000; + if(((CVehicle*)ent)->m_nAlarmState == -1) + ((CVehicle*)ent)->m_nAlarmState = 15000; + } + if(bUseCollisionRecords){ + int i; + for(i = 0; i < m_nCollisionRecords; i++) + if(m_aCollisionRecords[i] == ent) + return; + if(m_nCollisionRecords < PHYSICAL_MAX_COLLISIONRECORDS) + m_aCollisionRecords[m_nCollisionRecords++] = ent; + m_nLastTimeCollided = CTimer::GetTimeInMilliseconds(); + } +} + +void +CPhysical::AddCollisionRecord_Treadable(CEntity *ent) +{ + if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){ + CTreadable *t = (CTreadable*)ent; + if(t->m_nodeIndicesPeds[0] >= 0 || + t->m_nodeIndicesPeds[1] >= 0 || + t->m_nodeIndicesPeds[2] >= 0 || + t->m_nodeIndicesPeds[3] >= 0) + m_pedTreadable = t; + if(t->m_nodeIndicesCars[0] >= 0 || + t->m_nodeIndicesCars[1] >= 0 || + t->m_nodeIndicesCars[2] >= 0 || + t->m_nodeIndicesCars[3] >= 0) + m_carTreadable = t; + } +} + +bool +CPhysical::GetHasCollidedWith(CEntity *ent) +{ + int i; + if(bUseCollisionRecords) + for(i = 0; i < m_nCollisionRecords; i++) + if(m_aCollisionRecords[i] == ent) + return true; + return false; +} + +void +CPhysical::RemoveRefsToEntity(CEntity *ent) +{ + int i, j; + + for(i = 0; i < m_nCollisionRecords; i++){ + if(m_aCollisionRecords[i] == ent){ + for(j = i; j < m_nCollisionRecords-1; j++) + m_aCollisionRecords[j] = m_aCollisionRecords[j+1]; + m_nCollisionRecords--; + } + } +} + +int32 +CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints) +{ + int32 numSpheres = CCollision::ProcessColModels( + GetMatrix(), *CModelInfo::GetModelInfo(GetModelIndex())->GetColModel(), + ent->GetMatrix(), *CModelInfo::GetModelInfo(ent->GetModelIndex())->GetColModel(), + colpoints, + nil, nil); // No Lines allowed! + if(numSpheres > 0){ + AddCollisionRecord(ent); + if(!ent->IsBuilding()) // Can't this catch dummies too? + ((CPhysical*)ent)->AddCollisionRecord(this); + if(ent->IsBuilding() || ent->bIsStatic) + this->bHasHitWall = true; + } + return numSpheres; +} + +void +CPhysical::ProcessControl(void) +{ + if(!IsPed()) + m_phy_flagA8 = false; + bHasContacted = false; + bIsInSafePosition = false; + bWasPostponed = false; + bHasHitWall = false; + + if(m_status == STATUS_SIMPLE) + return; + + m_nCollisionRecords = 0; + bHasCollided = false; + m_nCollisionPieceType = 0; + m_fCollisionImpulse = 0.0f; + m_pCollidingEntity = nil; + + if(!bIsStuck){ + if(IsObject() || + IsPed() && !bPedPhysics){ + m_vecMoveSpeedAvg = (m_vecMoveSpeedAvg + m_vecMoveSpeed)/2.0f; + m_vecTurnSpeedAvg = (m_vecTurnSpeedAvg + m_vecTurnSpeed)/2.0f; + float step = CTimer::GetTimeStep() * 0.003; + if(m_vecMoveSpeedAvg.MagnitudeSqr() < step*step && + m_vecTurnSpeedAvg.MagnitudeSqr() < step*step){ + m_nStaticFrames++; + if(m_nStaticFrames > 10){ + m_nStaticFrames = 10; + bIsStatic = true; + m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); + m_vecMoveFriction = m_vecMoveSpeed; + m_vecTurnFriction = m_vecTurnSpeed; + return; + } + }else + m_nStaticFrames = 0; + } + } + ApplyGravity(); + ApplyFriction(); + ApplyAirResistance(); +} /* * Some quantities (german in parens): @@ -245,8 +386,8 @@ CPhysical::ApplySpringCollision(float f1, CVector &v, CVector &p, float f2, floa return; float step = min(CTimer::GetTimeStep(), 3.0f); float strength = -0.008f*m_fMass*2.0f*step * f1 * (1.0f-f2) * f3; - ApplyMoveForce(v.x*strength, v.y*strength, v.z*strength); - ApplyTurnForce(v.x*strength, v.y*strength, v.z*strength, p.x, p.y, p.z); + ApplyMoveForce(v*strength); + ApplyTurnForce(v*strength, p); } void @@ -798,58 +939,6 @@ CPhysical::ApplyFriction(float adhesiveLimit, CColPoint &colpoint) // ProcessCollisionSectorList // ProcessShiftSectorList -void -CPhysical::AddCollisionRecord(CEntity *ent) -{ - AddCollisionRecord_Treadable(ent); - this->bHasCollided = true; - ent->bHasCollided = true; - if(IsVehicle() && ent->IsVehicle()){ - if(((CVehicle*)this)->m_nAlarmState == -1) - ((CVehicle*)this)->m_nAlarmState = 15000; - if(((CVehicle*)ent)->m_nAlarmState == -1) - ((CVehicle*)ent)->m_nAlarmState = 15000; - } - if(bUseCollisionRecords){ - int i; - for(i = 0; i < m_nCollisionRecords; i++) - if(m_aCollisionRecords[i] == ent) - return; - if(m_nCollisionRecords < PHYSICAL_MAX_COLLISIONRECORDS) - m_aCollisionRecords[m_nCollisionRecords++] = ent; - m_nLastTimeCollided = CTimer::GetTimeInMilliseconds(); - } -} - -void -CPhysical::AddCollisionRecord_Treadable(CEntity *ent) -{ - if(ent->IsBuilding() && ((CBuilding*)ent)->GetIsATreadable()){ - CTreadable *t = (CTreadable*)ent; - if(t->m_nodeIndicesPeds[0] >= 0 || - t->m_nodeIndicesPeds[1] >= 0 || - t->m_nodeIndicesPeds[2] >= 0 || - t->m_nodeIndicesPeds[3] >= 0) - m_pedTreadable = t; - if(t->m_nodeIndicesCars[0] >= 0 || - t->m_nodeIndicesCars[1] >= 0 || - t->m_nodeIndicesCars[2] >= 0 || - t->m_nodeIndicesCars[3] >= 0) - m_carTreadable = t; - } -} - -bool -CPhysical::GetHasCollidedWith(CEntity *ent) -{ - int i; - if(bUseCollisionRecords) - for(i = 0; i < m_nCollisionRecords; i++) - if(m_aCollisionRecords[i] == ent) - return true; - return false; -} - bool CPhysical::ProcessShiftSectorList(CPtrList *lists) { @@ -1012,65 +1101,181 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists) return true; } -void -CPhysical::ProcessControl(void) +bool +CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists) { - if(!IsPed()) - m_phy_flagA8 = false; - bHasContacted = false; - bIsInSafePosition = false; - bWasPostponed = false; - bHasHitWall = false; + static CColPoint aColPoints[32]; + float radius; + CVector center; + int listtype; + CPhysical *A, *B; + int numCollisions; + int i; + float impulseA = -1.0f; + float impulseB = -1.0f; - if(m_status == STATUS_SIMPLE) - return; + A = (CPhysical*)this; - m_nCollisionRecords = 0; - bHasCollided = false; - m_nCollisionPieceType = 0; - m_fCollisionImpulse = 0.0f; - m_pCollidingEntity = nil; + radius = A->GetBoundRadius(); + A->GetBoundCentre(center); - if(!bIsStuck){ - if(IsObject() || - IsPed() && !bPedPhysics){ - m_vecMoveSpeedAvg = (m_vecMoveSpeedAvg + m_vecMoveSpeed)/2.0f; - m_vecTurnSpeedAvg = (m_vecTurnSpeedAvg + m_vecTurnSpeed)/2.0f; - float step = CTimer::GetTimeStep() * 0.003; - if(m_vecMoveSpeedAvg.MagnitudeSqr() < step*step && - m_vecTurnSpeedAvg.MagnitudeSqr() < step*step){ - m_nStaticFrames++; - if(m_nStaticFrames > 10){ - m_nStaticFrames = 10; - bIsStatic = true; - m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); - m_vecMoveFriction = m_vecMoveSpeed; - m_vecTurnFriction = m_vecTurnSpeed; - return; - } - }else - m_nStaticFrames = 0; + for(listtype = 3; listtype >= 0; listtype--){ + // Go through vehicles and objects + CPtrList *list; + switch(listtype){ + case 0: list = &lists[ENTITYLIST_VEHICLES]; break; + case 1: list = &lists[ENTITYLIST_VEHICLES_OVERLAP]; break; + case 2: list = &lists[ENTITYLIST_OBJECTS]; break; + case 3: list = &lists[ENTITYLIST_OBJECTS_OVERLAP]; break; + } + + // Find first collision in list + CPtrNode *listnode; + for(listnode = list->first; listnode; listnode = listnode->next){ + B = (CPhysical*)listnode->item; + if(B != A && + B->m_scanCode != CWorld::GetCurrentScanCode() && + B->bUsesCollision && + B->GetIsTouching(center, radius)){ + B->m_scanCode = CWorld::GetCurrentScanCode(); + numCollisions = A->ProcessEntityCollision(B, aColPoints); + if(numCollisions > 0) + goto collision; + } } } - ApplyGravity(); - ApplyFriction(); - ApplyAirResistance(); + // no collision + return false; + +collision: + + if(A->bHasContacted && B->bHasContacted){ + for(i = 0; i < numCollisions; i++){ + if(!A->ApplyCollision(B, aColPoints[i], impulseA, impulseB)) + continue; + + if(impulseA > A->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); + + if(impulseB > B->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceB, impulseB, A, aColPoints[i].normal); + + float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); + float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); + + cDMAudio::ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); + } + }else if(A->bHasContacted){ + CVector savedMoveFriction = A->m_vecMoveFriction; + CVector savedTurnFriction = A->m_vecTurnFriction; + A->m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f); + A->m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f); + A->bHasContacted = false; + + for(i = 0; i < numCollisions; i++){ + if(!A->ApplyCollision(B, aColPoints[i], impulseA, impulseB)) + continue; + + if(impulseA > A->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); + + if(impulseB > B->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceB, impulseB, A, aColPoints[i].normal); + + float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); + float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); + + cDMAudio::ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); + + if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ + A->bHasContacted = true; + B->bHasContacted = true; + } + } + + if(!A->bHasContacted){ + A->bHasContacted = true; + A->m_vecMoveFriction = savedMoveFriction; + A->m_vecTurnFriction = savedTurnFriction; + } + }else if(B->bHasContacted){ + CVector savedMoveFriction = B->m_vecMoveFriction; + CVector savedTurnFriction = B->m_vecTurnFriction; + B->m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f); + B->m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f); + B->bHasContacted = false; + + for(i = 0; i < numCollisions; i++){ + if(!A->ApplyCollision(B, aColPoints[i], impulseA, impulseB)) + continue; + + if(impulseA > A->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); + + if(impulseB > B->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceB, impulseB, A, aColPoints[i].normal); + + float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); + float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); + + cDMAudio::ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); + + if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ + A->bHasContacted = true; + B->bHasContacted = true; + } + } + + if(!B->bHasContacted){ + B->bHasContacted = true; + B->m_vecMoveFriction = savedMoveFriction; + B->m_vecTurnFriction = savedTurnFriction; + } + }else{ + for(i = 0; i < numCollisions; i++){ + if(!A->ApplyCollision(B, aColPoints[i], impulseA, impulseB)) + continue; + + if(impulseA > A->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceA, impulseA, B, aColPoints[i].normal); + + if(impulseB > B->m_fCollisionImpulse) + A->SetDamagedPieceRecord(aColPoints[i].pieceB, impulseB, A, aColPoints[i].normal); + + float turnSpeedDiff = (B->m_vecTurnSpeed - A->m_vecTurnSpeed).MagnitudeSqr(); + float moveSpeedDiff = (B->m_vecMoveSpeed - A->m_vecMoveSpeed).MagnitudeSqr(); + + cDMAudio::ReportCollision(A, B, aColPoints[i].surfaceA, aColPoints[i].surfaceB, impulseA, max(turnSpeedDiff, moveSpeedDiff)); + + if(A->ApplyFriction(B, CSurfaceTable::GetAdhesiveLimit(aColPoints[i])/numCollisions, aColPoints[i])){ + A->bHasContacted = true; + B->bHasContacted = true; + } + } + } + + if(B->m_status == STATUS_SIMPLE){ + B->m_status = STATUS_PHYSICS; + if(B->IsVehicle()) + CCarCtrl::SwitchVehicleToRealPhysics((CVehicle*)B); + } + + return true; } + STARTPATCHES InjectHook(0x4951F0, &CPhysical::Add_, PATCH_JUMP); InjectHook(0x4954B0, &CPhysical::Remove_, PATCH_JUMP); InjectHook(0x495540, &CPhysical::RemoveAndAdd, PATCH_JUMP); InjectHook(0x495F10, &CPhysical::ProcessControl_, PATCH_JUMP); + InjectHook(0x49F790, &CPhysical::ProcessEntityCollision_, PATCH_JUMP); InjectHook(0x4958F0, &CPhysical::AddToMovingList, PATCH_JUMP); InjectHook(0x495940, &CPhysical::RemoveFromMovingList, PATCH_JUMP); - InjectHook(0x497180, &CPhysical::AddCollisionRecord, PATCH_JUMP); InjectHook(0x4970C0, &CPhysical::AddCollisionRecord_Treadable, PATCH_JUMP); InjectHook(0x497240, &CPhysical::GetHasCollidedWith, PATCH_JUMP); - - InjectHook(0x49DA10, &CPhysical::ProcessShiftSectorList, PATCH_JUMP); + InjectHook(0x49F820, &CPhysical::RemoveRefsToEntity, PATCH_JUMP); #define F3 float, float, float InjectHook(0x495B10, &CPhysical::ApplyMoveSpeed, PATCH_JUMP); @@ -1088,4 +1293,7 @@ STARTPATCHES InjectHook(0x4992A0, &CPhysical::ApplyCollisionAlt, PATCH_JUMP); InjectHook(0x499BE0, (bool (CPhysical::*)(float, CColPoint&))&CPhysical::ApplyFriction, PATCH_JUMP); InjectHook(0x49A180, (bool (CPhysical::*)(CPhysical*, float, CColPoint&))&CPhysical::ApplyFriction, PATCH_JUMP); + + InjectHook(0x49DA10, &CPhysical::ProcessShiftSectorList, PATCH_JUMP); + InjectHook(0x49E790, &CPhysical::ProcessCollisionSectorList_SimpleCar, PATCH_JUMP); ENDPATCHES diff --git a/src/entities/Physical.h b/src/entities/Physical.h index 9867c33c..574238ab 100644 --- a/src/entities/Physical.h +++ b/src/entities/Physical.h @@ -82,6 +82,11 @@ public: void RemoveAndAdd(void); void AddToMovingList(void); void RemoveFromMovingList(void); + void SetDamagedPieceRecord(uint16 piece, float impulse, CEntity *entity, CVector dir); + void AddCollisionRecord(CEntity *ent); + void AddCollisionRecord_Treadable(CEntity *ent); + bool GetHasCollidedWith(CEntity *ent); + void RemoveRefsToEntity(CEntity *ent); // get speed of point p relative to entity center CVector GetSpeed(const CVector &r); @@ -126,16 +131,14 @@ public: bool ApplyFriction(CPhysical *B, float adhesiveLimit, CColPoint &colpoint); bool ApplyFriction(float adhesiveLimit, CColPoint &colpoint); - void AddCollisionRecord(CEntity *ent); - void AddCollisionRecord_Treadable(CEntity *ent); - bool GetHasCollidedWith(CEntity *ent); - bool ProcessShiftSectorList(CPtrList *ptrlists); + bool ProcessCollisionSectorList_SimpleCar(CPtrList *lists); // to make patching virtual functions possible void Add_(void) { CPhysical::Add(); } void Remove_(void) { CPhysical::Remove(); } CRect GetBoundRect_(void) { return CPhysical::GetBoundRect(); } void ProcessControl_(void) { CPhysical::ProcessControl(); } + int32 ProcessEntityCollision_(CEntity *ent, CColPoint *point) { return CPhysical::ProcessEntityCollision(ent, point); } }; static_assert(sizeof(CPhysical) == 0x128, "CPhysical: error");