#ifndef NX_COOKING_H #define NX_COOKING_H /*----------------------------------------------------------------------------*\ | | Public Interface to NovodeX Technology | | www.novodex.com | \*----------------------------------------------------------------------------*/ #include "Nxc.h" #include "Nxf.h" #include "NxArray.h" class NxUserAllocator; class NxUserOutputStream; class NxTriangleMeshDesc; class NxConvexMeshDesc; class NxStream; class NxFluidDesc; class NxTriangleMeshShape; class NxTriangle; //#ifdef NX_SUPPORT_INTERNAL_FACES class NxVec3; class NxPlane; class NxConvexMeshDesc2; //#endif enum NxPlatform { PLATFORM_PC, PLATFORM_XENON, PLATFORM_PLAYSTATION3 }; /** \brief Structure describing parameters affecting mesh cooking. @see NxSetCookingParams() NxGetCookingParams() */ struct NxCookingParams { /** \brief Target platform Should be set to the platform which you intend to load the cooked mesh data on. This allows novodex to optimize the mesh data in an appropriate way for the platform and make sure that endianess issues are accounted for correctly. */ NxPlatform targetPlatform; /** \brief Skin width for convexes Specifies the amount to inflate the convex mesh by when the new convex hull generator is used (the skinWidth is ignored when using the legacy convex hull generaror, enable with NX_CF_USE_LEGACY_COOKER). Inflating the mesh allows the user to hide interpentration errors by increasing the size of the collision mesh with respect to the size of the rendered geometry. */ float skinWidth; /** \brief Favorize speed or memory for collision structures */ bool hintCollisionSpeed; }; /** \brief Sets cooking parameters \note #NxInitCooking() sets the parameters to there default values. \param[in] params Cooking parameters \return true on success. @see NxCookingParams NxGetCookingParams() */ NX_C_EXPORT NXC_DLL_EXPORT bool NxSetCookingParams(const NxCookingParams& params); /** \brief Gets cooking parameters \return Current cooking parameters. @see NxCookingParams NxSetCookingParams() */ NX_C_EXPORT NXC_DLL_EXPORT const NxCookingParams& NxGetCookingParams(); /** \brief Checks endianness is the same between cooking & target platforms \return True if there is and endian mismatch. */ NX_C_EXPORT NXC_DLL_EXPORT bool NxPlatformMismatch(); /** \brief Initializes cooking. This must be called at least once, before any cooking method is called (otherwise cooking fails). \param[in] allocator The memory allocator to use. \param[in] outputStream The output stream to use. \return true on success. @see NxCloseCooking() */ NX_C_EXPORT NXC_DLL_EXPORT bool NxInitCooking(NxUserAllocator* allocator = NULL, NxUserOutputStream* outputStream = NULL); /** \brief Closes cooking. This must be called at the end of your app, to release cooking-related data. @see NxInitCooking() */ NX_C_EXPORT NXC_DLL_EXPORT void NxCloseCooking(); /** \brief Cooks a triangle mesh. The results are written to the stream. To create a triangle mesh object(unlike previous versions) it is necasery to first 'cook' the mesh data into a form which allows the SDK to perform efficient collision detection. NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime. NxCookConvex requires the input mesh to form a closed convex volume. This allows more efficient and robust collision detection. \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called when the application has finished using the cooking library. Example \include NxCookTriangleMesh_Example.cpp \param[in] desc The triangle mesh descriptor to read the mesh from. \param[in] stream User stream to output the cooked data. \return true on success @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() */ NX_C_EXPORT NXC_DLL_EXPORT bool NxCookTriangleMesh(const NxTriangleMeshDesc& desc, NxStream& stream); /** \brief Cooks a convex mesh. The results are written to the stream. To create a triangle mesh object(unlike previous versions) it is necasery to first 'cook' the mesh data into a form which allows the SDK to perform efficient collision detection. NxCookTriangleMesh() and NxCookConvexMesh() allow a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime. \note #NxInitCooking() must be called before attempting to cook a mesh. NxCloseCooking() should be called when the application has finished using the cooking library. Example \include NxCookConvexMesh_Example.cpp \param[in] desc The convex mesh descriptor to read the mesh from. \param[in] stream User stream to output the cooked data. \return true on success @see NxCookTriangleMesh() NxInitCooking() NxSetCookingParams() */ NX_C_EXPORT NXC_DLL_EXPORT bool NxCookConvexMesh(const NxConvexMeshDesc& desc, NxStream& stream); /** \brief Cooks a series of triangle meshes into one fluid hardware mesh. The results are written to the stream. \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with. \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is in its rest state (relaxed). \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction. \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep. \param packetSizeMultiplier This parameter controls the parallelization of the fluid. \param descArray The triangle meshes to be cooked into the fluid mesh \param stream The stream to write the results into \return true on success */ NX_C_EXPORT NXC_DLL_EXPORT bool NxCookFluidHardwareMesh(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier, NxArray& descArray, NxStream& stream); /** \brief Computes a CRC code for the fluid hardware mesh which can be used for caching. \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with. \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is in its rest state (relaxed). \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction. \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep. \param packetSizeMultiplier This parameter controls the parallelization of the fluid. \param descArray An array of triangle mesh descriptors. \return The 32bit CRC for the hardware mesh. */ NX_C_EXPORT NXC_DLL_EXPORT NxU32 NxComputeFluidHardwareMeshCRC32(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier, NxArray& descArray); /** \brief Cooks a series of world space triangles into one fluid hardware mesh. The results are written to the stream. \note The restParticlesPerMeter,kernelRadiusMultiplier(etc) parameters must match the fluid which the mesh is used with. \param restParticlesPerMeter The particle resolution given as particles per linear meter measured when the fluid is in its rest state (relaxed). \param kernelRadiusMultiplier Radius of sphere of influence for particle interaction. \param motionLimitMultiplier Maximal distance a particle is allowed to travel within one timestep. \param packetSizeMultiplier This parameter controls the parallelization of the fluid. \param descArray An array of world space triangles to build the fluid mesh from. \param tcount The number of triangles in descArray \param stream The stream to save to cooked results to \return true on success */ NX_C_EXPORT NXC_DLL_EXPORT bool NxCookFluidHardwareTriangles(NxReal restParticlesPerMeter, NxReal kernelRadiusMultiplier, NxReal motionLimitMultiplier, NxU32 packetSizeMultiplier,const NxTriangle *descArray,NxU32 tcount,NxStream& stream); /** \brief Report state of cooking memory usage. */ NX_C_EXPORT NXC_DLL_EXPORT void NxReportCooking(); //exclude from docs /// @cond //#ifdef NX_SUPPORT_INTERNAL_FACES NX_C_EXPORT NXC_DLL_EXPORT bool NxCookConvexMesh2(const NxConvexMeshDesc2& desc, NxStream& stream); NX_C_EXPORT NXC_DLL_EXPORT bool NxSliceConvex(const NxConvexMeshDesc& desc, const NxPlane& localPlane, NxConvexMeshDesc2& positivePart, NxConvexMeshDesc2& negativePart, NxVec3& offsetP, NxVec3& offsetN); NX_C_EXPORT NXC_DLL_EXPORT void NxReleaseSlicingData(); //#endif /// @endcond #endif //AGCOPYRIGHTBEGIN /////////////////////////////////////////////////////////////////////////// // Copyright © 2005 AGEIA Technologies. // All rights reserved. www.ageia.com /////////////////////////////////////////////////////////////////////////// //AGCOPYRIGHTEND