CameraToPhysic2d

matmat's icon

Hi,
Here a cool patch for making 2d detection with physics objects....

3631.CameraToPhys2d.zip
zip
touk's icon

thx for sharing.

ćwiek's icon

great!
"phys2d" and "phys2dworld" I know it from somewhere :)
anyway thanks for sharing!

Rob Ramirez's icon

so much fun!

MRTN's icon

Thanks! This is great! Just a question, any idea why is reacting good with the poly objects but not at all with phys.mult? Also, i had problem since i enable the worldbox (couse i need it active)...

matmat's icon
Max Patch
Copy patch and select New From Clipboard in Max.

hi,
here with phys.multiple and worldbox on ...

MRTN's icon

Thanks a lot! Is there a limitation of size for multiple objects? like 0.5 in your patch? Because as soon as i change the scale from 0.5 to small cubes (for exemple 0.3) it stop reacting. Can it be they become too small for the phys to recognize them and collide? (sorry my english)

matmat's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here an another example with random scale...

MRTN's icon

Thanks a lot, now everything is getting much more clear to understand! :)

Tobias Rosenberger's icon

Thanks for this wonderful example. Recently i looked for the first time into the new physics objects, and your patch is a great help. Just a few questions if you don't mind:

- if my camera input is 16:9 instead of 4:3, do i just have to rescale the videoplane to 17.777 10 instead 13.4 10 + the jit.phys.body to 1.77 1. 1. instead 1.33 1 1 ?

- why are the dimensions of the float matrix 100 100?

- if i change the jit.expr *10 and the scale-arguments for position in the poly accordingly, i can modify the width / height of the "collision area" ?

Tobias Rosenberger's icon

and one additional question:
if i want a sound played with each new collision contact with the video matrix and use the @collisions 1 feature of jit.phys.world as in the jitter-examples phys.picker.impulse.maxpat file, i still get contact detections / sound with the videomatrix even if i put the tresh to 1.

Why is that?

4358.cam2sound.zip
zip
matmat's icon

hi tobiasros
if your camera is 16:9 you simply adjust the scale of the mesh and videoplane.
the 100*100 matrix was just for testing....
to follow the format we could set the mesh matrix to the good ratio (100*75 for 4:3....)
-yes if you change the jit.expr * you can change the "collisions area", but you can set "jit.expr @expr snorm[0] in[0] snorm[1]" too, and only use scale message to mesh for that.

For the sound collisions may be the z scale of falling bodies needs to be decreased...

hope it can help

ygreq's icon

Hey Matmat or anyone else for that matter! :)

I am trying to figure out how you made the objects disappear when reaching the bottom of the screen in the patch with poly~. I see that in later patches with jit.phys.multiple they don't anymore.

Any suggestions? Thank you!

ygreq's icon

So I realized it has to do with all the info spit out by sending getState to jit.phys.body inside the poly~ object.

The next question is how do you recreate this with jit.phys.multiple? How do you make the balls dissappear once they reach the bottom and reappear on the upper part?

Thank you so much for any suggestions!

Rob Ramirez's icon

you can either use a phys.ghost to detect when a phys.body is in a specific zone, or simply iterate the phys.multiple position matrix to determine if the position y value is less than some threshold.

once you have the name of the specific body instance you want to reset, you can use the "sendbody" or "sendbody_reset" message of phys.multiple, to set that specific body instance position, as demonstrated in this patch:

Max Patch
Copy patch and select New From Clipboard in Max.

Prone's icon


Which camera do you use for max 7.3 ?

ygreq's icon

@Prone I was testing with a movie.

@Rob Thank you so much! I will try your solution. For now I am using some forces to spray the balls back up. Looks more interesting. But definitely will need the rain effect in the future :)

Now I realized something else. There seem to work with only one type of size. If you try to get the balls bigger or smaller, they don't interact with the mesh anymore. I used dp.kinect2 Do you know what gives?

I attached the patch for you to play with ;) Follow the yellow signs!

balls_v22.maxpat
text/plain 1.18 MB

ygreq's icon

A simple question then.

How can I make the jit.phys.body with the shape 2 times bigger (width and height) and still react to the objects? Because it seems one cannot do this with this patch as of this moment.

Any suggestions anyone?