PxCooking

Defined in include/cooking/PxCooking.h

class PxCooking

Provides methods to cook (where cooking means to prepare the data and convert it to the right format potentially including the construction of acceleration structures and other support data) all kind of simulation data.

Deprecated:

Public Functions

virtual void release() = 0

Closes this instance of the interface.

This function should be called to cleanly shut down the Cooking library before application exit.

Note

This function is required to be called to release foundation usage.

virtual void setParams(const PxCookingParams &params) = 0

Sets cooking parameters.

See also

getParams()

Parameters

params[in] Cooking parameters

virtual const PxCookingParams &getParams() const = 0

Gets cooking parameters.

Returns

Current cooking parameters.

virtual bool platformMismatch() const = 0

Checks endianness is the same between cooking & target platforms.

Returns

True if there is and endian mismatch.

virtual bool cookTriangleMesh(const PxTriangleMeshDesc &desc, PxOutputStream &stream, PxTriangleMeshCookingResult::Enum *condition = NULL) const = 0

Cooks a triangle mesh.

The results are written to the stream.

To create a triangle mesh object it is necessary to first ‘cook’ the mesh data into a form which allows the SDK to perform efficient collision detection.

cookTriangleMesh() allows a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime.

Parameters
  • desc[in] The triangle mesh descriptor to read the mesh from.

  • stream[in] User stream to output the cooked data.

  • condition[out] Result from triangle mesh cooking.

Returns

true on success

virtual PxTriangleMesh *createTriangleMesh(const PxTriangleMeshDesc &desc, PxInsertionCallback &insertionCallback, PxTriangleMeshCookingResult::Enum *condition = NULL) const = 0

Cooks and creates a triangle mesh without going through a stream.

Note

This method does the same as cookTriangleMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • desc[in] The triangle mesh descriptor to read the mesh from.

  • insertionCallback[in] The insertion interface from PxPhysics.

  • condition[out] Result from triangle mesh cooking.

Returns

PxTriangleMesh pointer on success.

inline PxTriangleMesh *createTriangleMesh(const PxTriangleMeshDesc &desc) const

Cooks and creates a triangle mesh without going through a stream.

Convenience function for standalone objects.

Note

This method does the same as cookTriangleMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters

desc[in] The triangle mesh descriptor to read the mesh from.

Returns

PxTriangleMesh pointer on success.

virtual bool validateTriangleMesh(const PxTriangleMeshDesc &desc) const = 0

Verifies if the triangle mesh is valid.

Prints an error message for each inconsistency found.

The following conditions are true for a valid triangle mesh:

  1. There are no duplicate vertices (within specified vertexWeldTolerance. See PxCookingParams::meshWeldTolerance)

  2. There are no large triangles (within specified PxTolerancesScale.)

Parameters

desc[in] The triangle mesh descriptor to read the mesh from.

Returns

true if all the validity conditions hold, false otherwise.

virtual bool cookSoftBodyMesh(const PxTetrahedronMeshDesc &simulationMeshDesc, const PxTetrahedronMeshDesc &collisionMeshDesc, const PxSoftBodySimulationDataDesc &softbodyDataDesc, PxOutputStream &stream) const = 0

Cooks a softbody mesh.

The results are written to the stream.

To create a softbody mesh object it is necessary to first ‘cook’ the mesh data into a form which allows the SDK to perform efficient collision detection and to store data used during the FEM calculations.

cookSoftBodyMesh() allows a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime.

Example

Parameters
  • simulationMeshDesc[in] The tetrahedron mesh descriptor to read the simulation mesh from.

  • collisionMeshDesc[in] The tetrahedron mesh descriptor to read the collision mesh from.

  • softbodyDataDesc[in] The softbody data descriptor to read mapping information from.

  • stream[in] User stream to output the cooked data.

Returns

true on success

virtual PxSoftBodyMesh *createSoftBodyMesh(const PxTetrahedronMeshDesc &simulationMeshDesc, const PxTetrahedronMeshDesc &collisionMeshDesc, const PxSoftBodySimulationDataDesc &softbodyDataDesc, PxInsertionCallback &insertionCallback) const = 0

Cooks and creates a softbody mesh without going through a stream.

Note

This method does the same as cookSoftBodyMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • simulationMeshDesc[in] The tetrahedron mesh descriptor to read the simulation mesh from.

  • collisionMeshDesc[in] The tetrahedron mesh descriptor to read the collision mesh from.

  • softbodyDataDesc[in] The softbody data descriptor to read mapping information from.

  • insertionCallback[in] The insertion interface from PxPhysics.

Returns

PxSoftBodyMesh pointer on success.

inline PxSoftBodyMesh *createSoftBodyMesh(const PxTetrahedronMeshDesc &simulationMeshDesc, const PxTetrahedronMeshDesc &collisionMeshDesc, const PxSoftBodySimulationDataDesc &softbodyDataDesc) const

Cooks and creates a softbody mesh without going through a stream.

Convenience function for standalone objects.

Note

This method does the same as cookSoftBodyMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • simulationMeshDesc[in] The tetrahedron mesh descriptor to read the simulation mesh from.

  • collisionMeshDesc[in] The tetrahedron mesh descriptor to read the collision mesh from.

  • softbodyDataDesc[in] The softbody data descriptor to read mapping information from.

Returns

PxSoftBodyMesh pointer on success.

virtual bool cookTetrahedronMesh(const PxTetrahedronMeshDesc &meshDesc, PxOutputStream &stream) const = 0

Cooks a tetrahedron mesh.

The results are written to the stream.

To create a tetrahedron mesh object it is necessary to first ‘cook’ the mesh data into a form which allows the SDK to perform efficient collision detection.

cookTriangleMesh() allows a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime.

Example

Parameters
  • meshDesc[in] The tetrahedron mesh descriptor to read the mesh from.

  • stream[in] User stream to output the cooked data.

Returns

true on success

virtual PxTetrahedronMesh *createTetrahedronMesh(const PxTetrahedronMeshDesc &meshDesc, PxInsertionCallback &insertionCallback) const = 0

Cooks and creates a tetrahedron mesh without going through a stream.

Note

This method does the same as cookTetrahedronMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • meshDesc[in] The tetrahedron mesh descriptor to read the mesh from.

  • insertionCallback[in] The insertion interface from PxPhysics.

Returns

PxTetrahedronMesh pointer on success.

inline PxTetrahedronMesh *createTetrahedronMesh(const PxTetrahedronMeshDesc &meshDesc) const

Cooks and creates a tetrahedron mesh without going through a stream.

Convenience function for standalone objects.

Note

This method does the same as cookTetrahedronMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters

meshDesc[in] The tetrahedron mesh descriptor to read the mesh from.

Returns

PxTetrahedronMesh pointer on success.

virtual PxCollisionMeshMappingData *computeModelsMapping(PxTetrahedronMeshData &simulationMesh, const PxTetrahedronMeshData &collisionMesh, const PxSoftBodyCollisionData &collisionData, const PxBoundedData *vertexToTet = NULL) const = 0

Computes the mapping between collision and simulation mesh.

The softbody deformation is computed on the simulation mesh. To deform the collision mesh accordingly it needs to be specified how its vertices need to be placed and updated inside the deformation mesh. This method computes that embedding information.

Parameters
  • simulationMesh[in] A tetrahedral mesh that defines the shape of the simulation mesh which is used to compute the body’s deformation

  • collisionMesh[in] A tetrahedral mesh that defines the shape of the collision mesh which is used for collision detection

  • collisionData[in] A data container that contains acceleration structures and surface information of the collision mesh

  • vertexToTet[in] Optional indices (array of integers) that specifies the index of the tetrahedron in the simulation mesh that contains a collision mesh vertex. If not provided, the embedding will be computed internally. If the simulation mesh is obtained from PxTetMaker::createVoxelTetrahedronMesh, then the vertexToTet map createVoxelTetrahedronMesh returned should be used here.

Returns

PxCollisionMeshMappingData pointer that describes how the collision mesh is embedded into the simulation mesh

virtual PxCollisionTetrahedronMeshData *computeCollisionData(const PxTetrahedronMeshDesc &collisionMeshDesc) const = 0

Computes data to accelerate collision detection of tetrahedral meshes.

Computes data structures to speed up collision detection with tetrahedral meshes.

Parameters

collisionMeshDesc[in] Raw tetrahedral mesh descriptor wich will be used for collision detection

Returns

PxCollisionTetrahedronMeshData pointer that describes the collision mesh

virtual PxSimulationTetrahedronMeshData *computeSimulationData(const PxTetrahedronMeshDesc &simulationMeshDesc) const = 0

Computes data to accelerate collision detection of tetrahedral meshes.

Computes data to compute and store a softbody’s deformation using FEM.

Parameters

simulationMeshDesc[in] Raw tetrahedral mesh descriptor wich will be used for FEM simulation

Returns

PxSimulationTetrahedronMeshData pointer that describes the simulation mesh

virtual PxSoftBodyMesh *assembleSoftBodyMesh(PxTetrahedronMeshData &simulationMesh, PxSoftBodySimulationData &simulationData, PxTetrahedronMeshData &collisionMesh, PxSoftBodyCollisionData &collisionData, PxCollisionMeshMappingData &mappingData, PxInsertionCallback &insertionCallback) const = 0

Bundles all data required for softbody simulation.

Creates a container that provides everything to create a PxSoftBody

See also

PxSoftBody createSoftBody()

Parameters
  • simulationMesh[in] The geometry (tetrahedral mesh) to be used as simulation mesh

  • simulationData[in] Additional non-tetmesh data that contains mass information etc. for the simulation mesh

  • collisionMesh[in] The geometry (tetrahedral mesh) to be used for collision detection

  • collisionData[in] Additional non-tetmesh data that contains surface information, acceleration structures etc. for the simulation mesh

  • mappingData[in] Mapping that describes how the collision mesh’s vertices are embedded into the simulation mesh

  • insertionCallback[in] The insertion interface from PxPhysics.

Returns

PxSoftBodyMesh pointer that represents a softbody mesh bundling all data (simulation mesh, collision mesh etc.)

virtual PxSoftBodyMesh *assembleSoftBodyMesh(PxSimulationTetrahedronMeshData &simulationMesh, PxCollisionTetrahedronMeshData &collisionMesh, PxCollisionMeshMappingData &mappingData, PxInsertionCallback &insertionCallback) const = 0

Bundles all data required for softbody simulation.

Creates a container that provides everything to create a PxSoftBody

See also

PxSoftBody createSoftBody()

Parameters
  • simulationMesh[in] Container that provides all information about the simulation mesh (geometry, mass distribution etc.)

  • collisionMesh[in] Container that provides all information about the collision mesh (geometry, surface information, acceleration structures etc.)

  • mappingData[in] Mapping that describes how the collision mesh’s vertices are embedded into the simulation mesh

  • insertionCallback[in] The insertion interface from PxPhysics.

Returns

PxSoftBodyMesh pointer that represents a softbody mesh bundling all data (simulation mesh, collision mesh etc.)

virtual bool cookConvexMesh(const PxConvexMeshDesc &desc, PxOutputStream &stream, PxConvexMeshCookingResult::Enum *condition = NULL) const = 0

Cooks a convex mesh.

The results are written to the stream.

To create a triangle mesh object it is necessary to first ‘cook’ the mesh data into a form which allows the SDK to perform efficient collision detection.

cookConvexMesh() allows a mesh description to be cooked into a binary stream suitable for loading and performing collision detection at runtime.

Note

The number of vertices and the number of convex polygons in a cooked convex mesh is limited to 255.

Note

If those limits are exceeded in either the user-provided data or the final cooked mesh, an error is reported.

Parameters
  • desc[in] The convex mesh descriptor to read the mesh from.

  • stream[in] User stream to output the cooked data.

  • condition[out] Result from convex mesh cooking.

Returns

true on success.

virtual PxConvexMesh *createConvexMesh(const PxConvexMeshDesc &desc, PxInsertionCallback &insertionCallback, PxConvexMeshCookingResult::Enum *condition = NULL) const = 0

Cooks and creates a convex mesh without going through a stream.

Note

This method does the same as cookConvexMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • desc[in] The convex mesh descriptor to read the mesh from.

  • insertionCallback[in] The insertion interface from PxPhysics.

  • condition[out] Result from convex mesh cooking.

Returns

PxConvexMesh pointer on success

inline PxConvexMesh *createConvexMesh(const PxConvexMeshDesc &desc) const

Cooks and creates a convex mesh without going through a stream.

Convenience function for standalone objects.

Note

This method does the same as cookConvexMesh, but the produced mesh is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters

desc[in] The convex mesh descriptor to read the mesh from.

Returns

PxConvexMesh pointer on success

virtual bool validateConvexMesh(const PxConvexMeshDesc &desc) const = 0

Verifies if the convex mesh is valid.

Prints an error message for each inconsistency found.

The convex mesh descriptor must contain an already created convex mesh - the vertices, indices and polygons must be provided.

See also

cookConvexMesh()

Note

This function should be used if PxConvexFlag::eDISABLE_MESH_VALIDATION is planned to be used in release builds.

Parameters

desc[in] The convex mesh descriptor to read the mesh from.

Returns

true if all the validity conditions hold, false otherwise.

virtual bool computeHullPolygons(const PxSimpleTriangleMesh &mesh, PxAllocatorCallback &inCallback, PxU32 &nbVerts, PxVec3 *&vertices, PxU32 &nbIndices, PxU32 *&indices, PxU32 &nbPolygons, PxHullPolygon *&hullPolygons) const = 0

Computed hull polygons from given vertices and triangles.

Polygons are needed for PxConvexMeshDesc rather than triangles.

Please note that the resulting polygons may have different number of vertices. Some vertices may be removed. The output vertices, indices and polygons must be used to construct a hull.

The provided PxAllocatorCallback does allocate the out array’s. It is the user responsibility to deallocated those array’s.

Parameters
  • mesh[in] Simple triangle mesh containing vertices and triangles used to compute polygons.

  • inCallback[in] Memory allocator for out array allocations.

  • nbVerts[out] Number of vertices used by polygons.

  • vertices[out] Vertices array used by polygons.

  • nbIndices[out] Number of indices used by polygons.

  • indices[out] Indices array used by polygons.

  • nbPolygons[out] Number of created polygons.

  • hullPolygons[out] Polygons array.

Returns

true on success

virtual bool cookHeightField(const PxHeightFieldDesc &desc, PxOutputStream &stream) const = 0

Cooks a heightfield.

The results are written to the stream.

To create a heightfield object there is an option to precompute some of calculations done while loading the heightfield data.

cookHeightField() allows a heightfield description to be cooked into a binary stream suitable for loading and performing collision detection at runtime.

Parameters
  • desc[in] The heightfield descriptor to read the HF from.

  • stream[in] User stream to output the cooked data.

Returns

true on success

virtual PxHeightField *createHeightField(const PxHeightFieldDesc &desc, PxInsertionCallback &insertionCallback) const = 0

Cooks and creates a heightfield mesh and inserts it into PxPhysics.

Parameters
  • desc[in] The heightfield descriptor to read the HF from.

  • insertionCallback[in] The insertion interface from PxPhysics.

Returns

PxHeightField pointer on success

inline PxHeightField *createHeightField(const PxHeightFieldDesc &desc) const

Cooks and creates a heightfield mesh and inserts it into PxPhysics.

Convenience function for standalone objects.

Parameters

desc[in] The heightfield descriptor to read the HF from.

Returns

PxHeightField pointer on success

virtual bool cookBVH(const PxBVHDesc &desc, PxOutputStream &stream) const = 0

Cooks a bounding volume hierarchy.

The results are written to the stream.

cookBVH() allows a BVH description to be cooked into a binary stream suitable for loading and performing BVH detection at runtime.

Parameters
  • desc[in] The BVH descriptor.

  • stream[in] User stream to output the cooked data.

Returns

true on success.

inline bool cookBVHStructure(const PxBVHStructureDesc &desc, PxOutputStream &stream) const

Backward compatibility helper.

Cooks a bounding volume hierarchy. The results are written to the stream.

Deprecated:

Parameters
  • desc[in] The BVH descriptor.

  • stream[in] User stream to output the cooked data.

Returns

true on success.

virtual PxBVH *createBVH(const PxBVHDesc &desc, PxInsertionCallback &insertionCallback) const = 0

Cooks and creates a bounding volume hierarchy without going through a stream.

Note

This method does the same as cookBVH, but the produced BVH is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters
  • desc[in] The BVH descriptor.

  • insertionCallback[in] The insertion interface.

Returns

PxBVH pointer on success

inline PxBVH *createBVH(const PxBVHDesc &desc) const

Cooks and creates a bounding volume hierarchy without going through a stream.

Convenience function for standalone objects.

Note

This method does the same as cookBVH, but the produced BVH is not stored into a stream but is either directly inserted in PxPhysics, or created as a standalone object. Use this method if you are unable to cook offline.

Parameters

desc[in] The BVH descriptor.

Returns

PxBVH pointer on success

inline PxBVHStructure *createBVHStructure(const PxBVHStructureDesc &desc, PxInsertionCallback &insertionCallback) const

Backward compatibility helper.

Cooks and creates a bounding volume hierarchy without going through a stream.

Deprecated:

Parameters
  • desc[in] The BVH descriptor.

  • insertionCallback[in] The insertion interface.

Returns

PxBVH pointer on success

virtual PxInsertionCallback &getStandaloneInsertionCallback() = 0

Gets standalone object insertion interface.

This interface allows the creation of standalone objects that can exist without a PxPhysics or PxScene object.

Protected Functions

inline virtual ~PxCooking()