So I am trying to cook a mesh into a PxTriangleMesh. Here is my code (actually copy-pasted from the documentation):
PxTriangleMeshDesc meshDesc;
meshDesc.points.count = vertices->size();
meshDesc.points.stride = sizeof(PxVec3);
meshDesc.points.data = vertices;
meshDesc.triangles.count = vertices->size() / 3;
meshDesc.triangles.stride = 3 * sizeof(unsigned int);
meshDesc.triangles.data = indices;
assert(meshDesc.isValid());
PxDefaultMemoryOutputStream writeBuffer;
PxTriangleMeshCookingResult::Enum result;
bool status = my_cooking->cookTriangleMesh(meshDesc, writeBuffer, &result);
if (!status)
return NULL;
PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());
return p.createTriangleMesh(readBuffer);
The assert does not fail but
my_cooking->cookTriangleMesh(..)
returns the status 'false'. I would guess there's something wrong with my indices but the documentation gives very little information about what they expect me to fill in there. I am using this little OBJ-loader: https://github.com/Bly7/OBJ-Loader. Loading a simple cube returns 36 vertices and 36 indices, just like it should do.
When loading the obj, I just do this:
indices = my_loader.LoadedIndices;
I can confirm that this works perfectly fine for vertices, uvs and normals. 'indices' is defined like this:
std::vector<unsigned int> indices
- Is PhysX expecting me to fill other data into triangles.data?
- If not, why is cookTriangleMesh() not returning true?