Getting xyz position data from jit.phys.body while using the jit.phys.picker obj

aobenshain's icon

I've been looking through the forum and can't seem to find an answer. This may be a really stupid question but I was wondering how to go about getting the position data of an object (x y and z) when I move/throw it around using the jit.phys.picker object. I assumed there would be a way to get it from the dumpout of the Jit.phys.body object, but I haven't been able to figure it out.

Rob Ramirez's icon

send the "getposition" message to the object, and the current position attribute will be sent out the dump outlet.
this is the same as any jitter object attribute, so if this is unfamiliar to you, make sure you check the documentation on jitter attributes.

seejayjames's icon

Very helpful...wondering why the message isn't included in the pop-up menu. Is it that you can send "getposition" or whatever other attribute, and it'll be reported? That would make sense to not include them all, if that's the case.

Another question, what's the easiest way to get collision information? Does this have to be through the [dict] object, or can you get it more directly? It seemed a little confusing and I couldn't quite get it right, or very easily.

LOVE the new physics objects! Just need to figure them out... :)

Rob Ramirez's icon

yeah, that's how attributes work.
check out this page for more info:
https://cycling74.com/docs/max6/dynamic/c74_docs.html#jitterwhatareattributes

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

and yes, phys.world outputs the collisions as dictionaries.
here's a patch demonstrating how to properly iterate a collisions dictionary.
let me know if anything is unclear.

seejayjames's icon

That's great, thanks very much. I think the "dictionary-of-dictionaries" part was confusing me, I need to read up more on [dict] itself. The collisions info makes sense now.

Time to play!

Johnnyc777's icon

I may be missing something but how do you get "second order collision" data? That is data of collisions when a collision is already taking place. The dict.view object displays the first order data first and then subsequent collisions that happen at the same time are listed underneath, how do I get data from these collisions that are listed underneath?

Apologies if I'm not explaining myself too clearly but sometimes it's hard in Max! :)

Rob Ramirez's icon

hi.
i'm not entirely sure what you are asking.

if a jit.phys.world has collisons enabled, each frame it outputs a dictionary containing sub-dictionaries for every collision currently in the world. it does not matter if the collisions are new or old, the output is the same. the only indication of a collision being "old" is the duration value in that collision's dictionary.

maybe post a patch showing what you're trying and what's not working?

Joe's icon

Going back to getting the jit.phys.body position, you mentioned that a getposition message would output the current position to the dumpout. What do you need connected to the dumpout to view the position.

All the best

J

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

hi,
here an example on how to get the position of a body :

Joe's icon

You sir are a certified legend. That has solved an issue that has been bugging me for ages!

Cheers!

J

chachaching's icon

How would I get the positions of constraints in jit.phys.multiple?

Rob Ramirez's icon

you can output a 7 plane matrix containing the 3 position and 4 quaternion values of the constraints by enabling phys.multiple @constraint_matrix attribute. the following example patch demonstrates this, as well as the phys.multiple help patch:
Max 6.1/examples/jitter-examples/render/physics/phys.multiple.constraints.maxpat

chachaching's icon

think u forgot to post the patch :). Having troubles deriving that from the help file.