fabmax / physx-js-webidl

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

some help about articulation #12

Closed lo-th closed 1 year ago

lo-th commented 2 years ago

Hi i need some help for articulation i know how to init / add bone but i have problem to get joint

init is

this.chain = this.useReducer ? root.world.createArticulationReducedCoordinate() : root.world.createArticulation()
// bone is 
var bone = this.chain.createLink( parent || null, transform );

joint should be joint = this.bones[ o.bone ].getInboundJoint()

on reducer i should have a PxArticulationJointReducedCoordinate but i have a PxArticulationJointBase i try joint = PhysX.TypeHelpers.prototype.articulationBaseJointToJoint( joint ) but i get a PxArticulationJoint

lo-th commented 2 years ago

in doc i have PxArticulationJoint* joint = static_cast<PxArticulationJoint*>(link->getInboundJoint()); for non reduced and PxArticulationJointReducedCoordinate* joint = static_cast<PxArticulationJointReducedCoordinate*>(link->getInboundJoint()); for reduced

fabmax commented 2 years ago

Ah I guess the cast function for reduced joint is missing in TypeHelpers. Should be easy to add (I'm not sure when I will have time to do that though).

I never tried the reduced coordinate articulations, the normal ones already were good enough (according to the doc the reduced coordinate version is more accurate and slower).

lo-th commented 2 years ago

yes i try to add typeHelpers but not work joint stay fixed reduced is more interesting because have many more option and work like standard joint

lo-th commented 2 years ago

basic articulation is for chaine or rope but reduced is for robot arm, leg, kinematic ... reduced have drive on joint and can be spherical, prismatic, revolute...

i try

TypeHelpers.prototype['articulationBaseJointToJointReduced'] = TypeHelpers.prototype.articulationBaseJointToJointReduced = /** @suppress {undefinedVars, duplicate} @this{Object} */function(baseJoint) {
  var self = this.ptr;
  if (baseJoint && typeof baseJoint === 'object') baseJoint = baseJoint.ptr;
  return wrapPointer(_emscripten_bind_TypeHelpers_articulationBaseJointToJoint_1(self, baseJoint), PxArticulationJointReducedCoordinate);
};;

now i have access of joint propriety but joint stay fixed :(

lo-th commented 2 years ago

wow that work !! i just make error in definition ( missing () at end ) joint.setJointType( PhysX[ '_emscripten_enum_PxArticulationJointTypeEnum_e'+ o.type.toUpperCase() ]() )

so just need add new TypeHelpers proto

fabmax commented 2 years ago

Alright, I added the TypeHelper function. Updated lib is available in dist directory. I haven't published it on npmjs yet in case more changes come up.