From 223aff8b3f73bb786dce5c67b83ff55208d43969 Mon Sep 17 00:00:00 2001
From: Marijn Tamis Table Of Contents
+
physx::PxVec4* particlePositions = ...; // The w component is the inverse mass of the particle
// and can be to 0 to lock the particle / make it static.
-nv::cloth::Cloth* cloth = factory->createCloth(nv::cloth::Range<physx::PxVec4>( particlePositions, & particlePositions + particleCount), *fabric);
+nv::cloth::Cloth* cloth = factory->createCloth(nv::cloth::Range<physx::PxVec4>(particlePositions, particlePositions + particleCount), *fabric);
// particlePositions can be freed here.
...
@@ -307,7 +308,7 @@ for(int i = 0; i < fabric->getNumPhases(); i++)
phases[i].mCompressionLimit = 1.0f;
phases[i].mStretchLimit = 1.0f;
}
-cloth->setPhaseConfig(nv::cloth::Range<nv::cloth::PhaseConfig>(&phases[0], &phases[0] + fabric->getNumPhases()));
+cloth->setPhaseConfig(nv::cloth::Range<nv::cloth::PhaseConfig>(phases, phases + fabric->getNumPhases()));
delete [] phases;
Note that there might be more phase of each type. @@ -361,14 +362,14 @@ for(int i = 0; i<particles.size(); i++)
Cloth instances have many properties that can be influence their behavior. +
Cloth instances have many properties that can influence their behavior. This section shows how to use some of the most common properties.
We can set the gravity acceleration vector in global space:
cloth->setGravity(physx::PxVec3(0.0f, -9.8f, 0.0f));
This vector doesn’t have to be the same as provided to the cooker.
+This vector doesn’t have to be the same as the one provided to the cooker.
Sometimes it is desirable to dampen the particle motion:
cloth->setDamping(0.5f); //0.0f is default
We can define up to 32 collision spheres per cloth:
physx::PxVec4 spheres[2] = {
+ // First 3 components of each vector is sphere center in local space and the 4th one is its radius
physx::PxVec4(0.0f, 0.0f, 0.0f, 1.0f),
physx::PxVec4(0.0f, 5.0f, 0.0f, 1.0f)
};
@@ -445,8 +447,8 @@ We can easily construct convex shapes consisting of more planes by setting more
physx::PxVec3* triangles = ...; //Get triangle data from somewhere
//We can't use indexed meshes/vertex sharing,
// each triangle is defined with its own 3 vertexes
-nv::cloth::Range<const physx::PxVec3> triangleR(&triangles[0], &triangles[0] + triangleCount * 3);
-cloth->setTriangles(triangleR, 0, cloth>getNumTriangles());
+nv::cloth::Range<const physx::PxVec3> triangleR(triangles, triangles + triangleCount * 3);
+cloth->setTriangles(triangleR, 0, cloth->getNumTriangles());
Note that the range arguments passed to setTriangles are counting whole triangles (3 PxVec3 vertexes each).
We can set the friction coefficient used for collision between cloth and collision shapes like this:
--
cgit v1.2.3