Moving objects from A to B in a physics world

KP's icon

HI,

I am working on a patch where I use my mouse+dumpout information from jit.pwindow to reposition objects in a jitter world. It's getting quite messy because I'm scaling everything to match up the integers I get from the mouse-output of the pwindow with the actual positions in the 3d-world that come in floats. For instance X-axis on mouse-over is 0 to 755 (the size of the window) but X-axis in the 3d-world is something like -4.35 to 4.35. It makes everything really complicated and messy and I'm thinking there has to be a better and much more efficient way of doing this.

So my question is: Can I somehow use a jit.world with physcis but without gravity to reposition objects on the X and Y axis using the mouse to grab an object->reposition->release (and have it stay there without falling endlellsly), instead of having to use the mouseover-dumpout of the pwindow?
Another reason for wanting to do this is that I hope that it is also possible to get collision detection as well.

So far I've experimented in all manners with @kinematic 1, @dynamics 0, @gravity 0 0 0 and so on, but without any luck.
I hope there is a way to do this! :)

Best,

Rob Ramirez's icon

there are a handful of ways to move phys.bodies around in the world with mouse input. if you don't want dynamics instantiate your phys.world with @dynamics 0. you can use screentoworld prepended with sendrender to your jit.world to convert mouse screen coords to world-space coords for positioning a phys.body.

here's a basic patch that hopefully gets you going:

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

KP's icon

Fantastic! Exactly what I was looking for. Thanks a lot!!

KP's icon

Ah, but this makes it only possible to move around one object, it seems. If I want to move around several objects I have to send the mouse data to several gates that only opens and send position data to the object that I hover over (or at least something like that?). And my initial thought was that I wanted to be free of systems like that, as it seems very ineffecient compared to the easyness of for instance the phys.picker object in a world with dynamics set to 1.
The thing is that everything freezes when I set dynamics to 0. And when I set dynamics to 1, my objects start falling endlessly due to the physics. So I guess that my question is if I can somehow use phys.picker (or something alike) in a world that doesn't have gravity? I don't want my objects to react to physics. But I still want too be able to move them from A to B, by picking them up. ... I hope I make sense :)

Rob Ramirez's icon

use phys.picker to get the body name and send that to a jit.proxy object which receives the mouse position messages. you can use the mouse up/down indicator from picker to gate the mouse position messages.

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

KP's icon

Nice!! This is the perfect solution for my purpose. The other patch I did became so huge and messy. And this is so simple:-) jit.proxy seems really cool! .. A lot of stuff to delve deeper into for me! Thanks a lot, Rob.