Js phys.world retrieve collisions in script

touk's icon

Hi

is it possible to retrieve information about the collisions made ​​between objects in javascript like the dumpout outlet in a patcher (knowing that all objects are instantiated in javascript, my 3D scene, my world etc...) I have examples like the ragdolls etc...to create objects but I did not find any solutions to retrieve collisions datas

thanks

Rob Ramirez's icon

check out the following example patch:
Max 6.1/examples/jitter-examples/render/physics/phys.world.collisions.js.maxpat

touk's icon

one more time , thanks

BUT,
I have observed that the "duration" of contact remains at 0, can someone reproduce this default or it's only me ?

Rob Ramirez's icon

ugh, yeah, that's a bug.
thanks for catching, we'll get it fixed up.

touk's icon

may be you will be able to suggest me ideas, I want to make a roll of the dice, I must determine on which side falls my cube.

During the collision report, the attribute 'normal' refers to the orientation of my item? I have to work from there?

Rob Ramirez's icon

so turns out this is a simple fix.
you must simply free the individual collision-dicts when done processing them.
so in the example javascript, add the following line at the end of the process_collisions function (line 50 or so):
subd.freepeer();

the collision normal won't tell you which side of the cube is facing up.
you should be able to determine that simply from the body's orientation (quat, rotate, or rotatexyz attributes).