fabmax / physx-js-webidl

Javascript WASM bindings for Nvidia PhysX
MIT License
119 stars 28 forks source link

Question - serialize #28

Open sancelot opened 9 months ago

sancelot commented 9 months ago

Hi,

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

Regards

fabmax commented 9 months ago

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.

sancelot commented 9 months ago

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);
fabmax commented 9 months ago

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.

sancelot commented 9 months ago

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: @.***>

fabmax commented 9 months ago

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).

sancelot commented 9 months ago

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.

fabmax commented 9 months ago

Yes that should work.