PhysX3 : how to create a displayable triangle mesh from a convex hull ? [SOLVED]

Hello

I use convexHull->saveToDesc() in PhysX 2.8 to retreive a triangle mesh (vertex buffer + index buffer) from a convex hull (stored as a vertex buffer only). In other words, I use PhysX to create triangle-based index buffers in order to display convex hulls in an editor.

How can I do the same in PhysX 3 please ?

Thanks

Finally I think I can deal with polygon data of the convex hulls :
these polygons are convex so I can easily decompose them into triangles.

Thanks

Hi,

sry for the delay.

Did you solved your problem?

Hello

I think so but I can’t be sure, because I have another serious problem : cookConvexMesh() and cookTriangleMesh() (PhysX 3) are both crashing the application when I call them. However, I’ve checked the descriptions I give to them and they seems valid …

Hi

hm. Would you show us how you initalize PhysX and how you cook your mesh?

Its much easier for us when we see your code.

Just debug your code - maybe there is somewhere an invalid pointer.

Which version of PhysX do you use?
Against which libs are you linking? (RELEASE, DEBUG, CHECKED ?)

Hello

I use Physx 3.2.4 on Vista 32 bit

Here the initialization :

{
	static PxDefaultErrorCallback errorCallback;
	static PxDefaultAllocator allocatorCallback;

	foundation=PxCreateFoundation(PX_PHYSICS_VERSION,allocatorCallback,errorCallback);
	if (foundation==NULL) return;

	profileZoneManager=&PxProfileZoneManager::createProfileZoneManager(foundation);
	if(profileZoneManager==NULL) return;

#ifdef _DEBUG
	physics=PxCreateBasePhysics(PX_PHYSICS_VERSION,*foundation,PxTolerancesScale(),true,profileZoneManager);
#else
	physics=PxCreateBasePhysics(PX_PHYSICS_VERSION,*foundation,PxTolerancesScale(),false,profileZoneManager);
#endif

	if (physics==NULL) return;

	cooking=PxCreateCooking(PX_PHYSICS_VERSION,*foundation,PxCookingParams());
	if (cooking==NULL) return;

	if (!PxInitExtensions(*physics)) return;

	PxSceneDesc sceneDesc(physics->getTolerancesScale());
	sceneDesc.gravity=PxVec3(0.0f,-9.81f,0.0f);

    cpuDispatcher=PxDefaultCpuDispatcherCreate(1);
    if (cpuDispatcher==NULL) return;
	sceneDesc.cpuDispatcher=cpuDispatcher;

	sceneDesc.filterShader=PxDefaultSimulationFilterShader;

	scene=physics->createScene(sceneDesc);
	if (scene==NULL) return;
}

physics, cooking, scene are valid pointers after the initialization.

I use the cooking methods for triangle mesh and convex hull as it is described in the user guide.

I link with CHECKED libs in debug mode, RELEASE in release mode
The crash happens in both modes.

I hope it is just something I omitted in my PhysX initialization …

Thanks

I’ve just noticed that __vfptr of physics, cooking, scene and cpuDispatcher are invalid ! (after the initialization)

Don’t worry, I called the destructor by accident, applying release at these objects … before cooking …

Thank you for your help