Notifications
Clear all

[Closed] Unknown Method: Distance between Objects

Hey everyone,

I may be burnt out from too much scripting in one day, but I can’t seem to find a method that will allow me to check the distance between two objects (editable Poly, Mesh, or standard primitive). I tried

distance <node> <node>,

but that didn’t work for editable poly objects. I’m working on a script that checks for the objects nearest/farthest from the selected object; but I can’t find a method that will return distances between any type of objects.

P.S. if possible, I’m looking for something to return bounding box information; not pivot point information! =)

Anyone know where I can find something like that?

4 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

You must be passing something wrong to the method, because a NODE is a node and does not care what geometry (or any other object class) is attached to it.

b = Box name:"MyBox" pos:[10,20,30]
convertTo b Editable_Poly

s = Sphere name:"MySphere" pos:[100,200,300]
convertTo s Editable_Poly

distance b s
distance b.pos s.pos
distance $MyBox $MySphere
distance $MyBox.pos $MySphere.pos

As for bounding box, .min and .max return WORLD-ALIGNED bounding boxes. For the actual BBox, you would have to perform a couple of matrix transformations – store the old TM, assign an identity matrix to the object, eventually apply the scaling of the old TM to the new one if you want to use it (normally, it should be [1,1,1] anyway), then measure the .min and .max and then reset the object back to the old TM, then transform the min and max values by the old TM to get the object-aligned bounding box corners. If you want all 8 corners, you could build them out of the components of the .min and .max and perform the calculation 8 times as described above. (my Advanced DVD provides some details, too)

P.P.S. For instance, I really wish I could have used <node>.max and <node>.min because it would have allowed me to get points along the bounding boxes. Is there anything like that for just plain old objects; not nodes?

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

What are “plain old objects”? All scene objects are called “Nodes”. It is the top-level node seen in TrackView, the one that hosts the PRS controllers, visibiliy track, material etc. The “base object” or the “modified object” do not exist in world space, it is the node that brings them there. Thus, you cannot measure distances between anything but nodes (or their world positions).

Ah; I see now! Bobo; again your insight has shown me the right way to do things! I’m back on the right track.

Thank you very much!