For creating a cloth in PhysX, we first require an instance of cloth fabric to be created, which basically stores the cloth particle constraints and rest values. A cloth fabric in PhysX is a type of PxClothFabric,
and to create an instance of it, we need to call the PxClothFabricCreate()
function that requires three parameters. The first parameter is a type of PxPhysics
, it is the reference of the created PhysX SDK. The second parameter is a type of PxClothMeshDesc
, which basically is a descriptor class for cloth mesh. The third parameter is a type of PxVec3
and it represents the normalized vector specifying the direction of gravity. Here, we need to fill all the description of PxClothMeshDesc
that contains the information of the cloth mesh such as cloth particles, its inverse weight, and the primitive formed by the cloth particles, which finally make the cloth mesh.
A typical example of creating a cloth fabric is given in the following code:
//Array of cloth particles...