View Full Version : Calculate geometrical center of specific animated objects
doCHtor 09-09-2008, 01:32 PM 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.
|
|
You want the bounding box x and y center, with the z of the ground plane. Use bbox.min and .max.
doCHtor
09-09-2008, 04:56 PM
Thanks, but i'm not sure how to use this... does it work on more objects?
Thanks, but i'm not sure how to use this... does it work on more objects?
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
)
doCHtor
09-10-2008, 06:20 AM
Thanks a bunch, I will try to incorporate this into my script.
doC
doCHtor
09-11-2008, 07:54 AM
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.
CGTalk Moderation
09-11-2008, 07:54 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.