I have been following the user guide to try to get physics meshes into my game. Unfortunately, no matter what kind of mesh I try (convex or triangle), or the model I give it (a small poly model, or even a simple cube), cookConvexMesh() keeps failing. Here is my implementation:
// initialization in another method:
s_foundation = PxCreateFoundation(PX_PHYSICS_VERSION, s_defaultAllocatorCallback, s_defaultErrorCallback);
PxCookingParams cookparams;
cookparams.targetPlatform = PxPlatform::ePC;
s_physxCooking = PxCreateCooking(PX_PHYSICS_VERSION, *s_foundation, cookparams);
// mesh creation function
void RicochetEngine::Physics::PhysicsManager::CreateMesh(Rendering::Mesh* mesh, physx::PxConvexMesh** out)
{
PxConvexMeshDesc convex;
convex.points.count = mesh->GetVertexCount();
convex.points.stride = sizeof(PxVec3);
PxVec3* pxv = new PxVec3[mesh->GetVertexCount()];
// initializing each PxVec3 with the position stored in my own vertex format
convex.points.data = pxv;
// re_index in this case is equivalent to PxU32
convex.triangles.count = mesh->GetIndexCount();
convex.triangles.stride = sizeof(re_index);
convex.triangles.data = mesh->GetIndices();
convex.flags = PxConvexFlag::eFLIPNORMALS | PxConvexFlag::eUSE_UNCOMPRESSED_NORMALS |
PxConvexFlag::eCOMPUTE_CONVEX;
PxToolkit::MemoryOutputStream buf;
if (!s_physxCooking->cookConvexMesh(convex, buf))
{
// The function always enters this if-statement
*out = NULL;
return;
}
PxToolkit::MemoryInputData input(buf.getData(), buf.getSize());
*out = s_physicsSDK->createConvexMesh(input);
}
Whenever the function is called it always enters the if-statement mentioned above. I check the contents of the buffer passed, and it is always NULL. Any idea what might be causing the problem, or any way to get more information about whatever error is being thrown within PhysX?