Notifications
Clear all

[Closed] Calculate geometrical center of specific animated objects

Hi,

is there a way how to calculate a geometrical center of specific animated objects? What I would like to have is a dummy object which would be always on ground and aligned to this geometrical center in xy axis. For example: I have a standing biped character, dummy object is currently on ground under Bip01 (little diamond thingie), when I rotate only one arm up to side (one arm to T-Pose), dummy should automatically move somewhere between Bip01 and the hand object in xy axis (and stay on ground).

Thanks for any ideas.

5 Replies
 eek

You want the bounding box x and y center, with the z of the ground plane. Use bbox.min and .max.

Thanks, but i’m not sure how to use this… does it work on more objects?

1 Reply
 eek
(@eek)
Joined: 1 year ago

Posts: 0

sorry i thought it was a single mesh. If its a bunch of objects you could either use a position constraint or script it:

a, b, c are assigned as variables to nodes.

with animate off
(
objs = #(a,b,c)
posSum = [0,0,0]
for i = 1 to objs.count do
(
posSum += objs[i].transform.pos
)
posSum = (posSum/objs.count)
posSum[3] = 0
posSum
)

Thanks a bunch, I will try to incorporate this into my script.

doC

I have ended up using scripted controler for the object i want to center under those more objcts. Script is something like this:


(
objsX = #(BipHandL.transform.pos.x,BipHandR.transform.pos.x,BipLegL.transform.pos.x,BipLegR.transform.pos.x 
objsY = #(BipHandL.transform.pos.y,BipHandR.transform.pos.y,BipLegL.transform.pos.y,BipLegR.transform.pos.y)
posSum = [0,0,0]
posSum[1] = ((amax objsX + amin objsX)/2)
posSum[2] = ((amax objsY + amin objsY)/2) 
posSum"
)

It is calculating bounding box of selected objects by finding the two most distant object in each axis.