physx-js-webidl icon indicating copy to clipboard operation
physx-js-webidl copied to clipboard

Question - serialize

Open sancelot opened this issue 1 year ago • 7 comments

Hi,

Is there possibility to use serialization, or to debug PhysX scene ? and is Cooking available ?

Regards

sancelot avatar Jan 18 '24 17:01 sancelot

PxSerialization is available, although I never really used it. Debugging isn't really possible however (I think someone maneged to use a websocket connection to connect to the PhysX Visual Debugger in the past but that was with PhysX 4. With PhysX 5 PVD isn't really supported anymore).

The cooking functions for PxConvexMesh, PxTriangleMesh and PxHeightField are available via PxTopLevelFunctions.prototype. The old PxCooking class is deprecated and not used anymore.

fabmax avatar Jan 19 '24 21:01 fabmax

Thanks for your reply.

I gave it a try but faced to unattended issue , meshDesc polygons does not exist

let meshDesc = new this.PhysX.PxConvexMeshDesc();
  meshDesc.points.count = vertices?.length;
      meshDesc.points.stride = Object.keys(vertices[0]).length; // * 3 ? ??
      meshDesc.points.data = vertices;
      meshDesc.polygons.count = indices.length / 3;
      meshDesc.polygons.stride = 3 * Object.keys(indices[0]).length;
      meshDesc.polygons.data = indices; // Indices can be 16 or 32 bit. The strides used here assume that vertices and indices are arrays of PxVec3s and 32bit integers respectively with no gaps in the data layout.
      meshDesc.flags = this.PhysX.eCOMPUTE_CONVEX;
      console.log(this.PhysX.PxTopLevelFunctions.prototype.CreateConvexMesh);
      const convexmesh = this.PhysX.PxTopLevelFunctions.prototype.CreateConvexMesh(cookingParams, meshDesc);


sancelot avatar Jan 22 '24 15:01 sancelot

Ah yes that's true. Do you need polygons? I never had a usecase where I needed them and it works just fine with only points.

fabmax avatar Jan 22 '24 18:01 fabmax

I have already vertices and faces . I want to use it with babylonjs meshes for collide detection

Le lun. 22 janv. 2024 à 19:09, Max Thiele @.***> a écrit :

Ah yes that's true. Do you need polygons? I never had a usecase where I needed them and it works just fine with only points.

— Reply to this email directly, view it on GitHub https://github.com/fabmax/physx-js-webidl/issues/28#issuecomment-1904541513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA57O2RDTKDEKAEG26JB3DYP2TO7AVCNFSM6AAAAABCAT5662VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBUGU2DCNJRGM . You are receiving this because you authored the thread.Message ID: @.***>

sancelot avatar Jan 23 '24 01:01 sancelot

Then PxConvexMesh is probably not the right choice. This is only for small (up to 255 vertices) convex meshes (see here)

For "regular" meshes you need to use either PxTriangleMesh (but keep in mind that triangle meshes can only be static or kinematic, not fully simulated dynamic).

fabmax avatar Jan 23 '24 09:01 fabmax

you are right ,PxConvexMesh won't be a good choice in my case. I will only use collide engine, in a not very usual mode. I will teleport collide objects and detect collisions without using physics, that may lead to use the collide engine forcing some activation states.

sancelot avatar Jan 23 '24 12:01 sancelot

Yes that should work.

fabmax avatar Jan 23 '24 16:01 fabmax