fabmax / physx-js-webidl

Javascript WASM bindings for Nvidia PhysX
MIT License
117 stars 27 forks source link

About Vehicle #18

Open lo-th opened 1 year ago

lo-th commented 1 year ago

Hello great port of 5.1 the speed up is amazing ! I see you don't expose vehicle function do you plan to add them that would be great.

fabmax commented 1 year ago

Yes I'm currently on that. The vehicle API has changed significantly compared to 4.1 so it's quite a bit of work...

lo-th commented 1 year ago

Awesome, i hope they have simplified vehicle API because it was not easy to use

lo-th commented 1 year ago

Hi happy new year thank's for adding vehicle is great i have little missing and i don't find value in doc vehicle.get_transmissionCommandState().set_targetGear(PxVehicleEngineDriveTransmissionCommandStateEnum.eAUTOMATIC_GEAR.value); eAUTOMATIC_GEAR is not exposed, what the value ?

fabmax commented 1 year ago

Hmm, I think it is exposed... Anyway, in the Nvidia docs you can click on the file name and then show source to see the actual values: https://nvidia-omniverse.github.io/PhysX/physx/5.1.2/_build/physx/latest/program_listing_file_include_vehicle2_commands_PxVehicleCommandStates.h.html#program-listing-file-include-vehicle2-commands-pxvehiclecommandstates-h

For eAUTOMATIC_GEAR it is 0xff

lo-th commented 1 year ago

ok thank's have to experiment now my car seem's go forward ? front wheel is 0 1 or 2 3 ?

i wan't control car with keyboard is with vehicle.getCommandState().setThrottle(1); // key for acceleration vehicle.getCommandState().setNbBrakes(0); vehicle.getCommandState().setSteer(0); // for turn

fabmax commented 1 year ago

The front wheels are 0 (left) and 1 (right). The vehicle is controlled via its command state (like you wrote). In order to brake you also have to add a brake command:

vehicle.getCommandState().setNbBrakes(1);
vehicle.getCommandState().set_brakes(0, brakeValue);  // brakeValue between 0.0 and 1.0
lo-th commented 1 year ago

ok i use get_wheelRigidBody1dStates(i).rotationAngle to update my wheel mesh i guess Throttle value is also between 0.0 and 1.0 ( for reverser just have to set targetGear to 0 )

do you know how change car shape to custom convex and get physics interaction with other object i look you initialisation code in java version, wheel shape now work in js is great.

lo-th commented 1 year ago

yo ok i find :) how make custom car chassis physxParams.set_physxActorShapeFlags( new PhysX.PxShapeFlags( shapeflag ) ) physxParams.set_physxActorSimulationFilterData( carQueryFilterData )

fabmax commented 1 year ago

For updating the wheels I would recommend using vehicle.getBaseState().getWheelLocalPoses(i) which also includes the suspension travel, steering etc.

lo-th commented 1 year ago

yes but getWheelLocalPoses quarternion is wrong ( position is good ) i use state.get_wheelRigidBody1dStates(i).rotationAngle // X i<2 ? command.get_steer() : 0 // Y state.get_tireCamberAngleStates(i).camberAngle // Z

fabmax commented 1 year ago

It works for me, but if the individual angles work as well that's fine as well

lo-th commented 1 year ago

yes you right new version quarternion work

lo-th commented 1 year ago

they are something strange on your java setup ( is same as original physx example ) actorShapeLocalPose is ( 0, 0.83, 1.37 ) actorCMassLocalPose is ( 0, 0.55, 1.594 ) move center of mass to front bottom ok but why move z shape local pose ? that make model only over front wheel ?