PDA

View Full Version : Center a locator between two particles


ronviers
03-22-2010, 03:02 PM
I am trying to center a locator between two particles in an expression. It is not working. Here is how I tried to do it. Does anyone know of a good way to do this?


vector $pos1=`particle -at position -id 11 -q particle`;
vector $pos2=`particle -at position -id 3 -q particle`;
vector $mid=($pos2-$pos1)/2;
setAttr up_loc.translate $mid;


Edit: Never mind, got it figured out.

Thanks

Derek Wolfe
03-22-2010, 07:48 PM
Please share the solution for the benefit of the community.

ronviers
03-22-2010, 08:06 PM
There is probably a better way to do this but it's working.

vector $pUpPos1=`particle -at position -id 6 -q ffd1LatticeParticle`;
vector $pUpPos2=`particle -at position -id 7 -q ffd1LatticeParticle`;
vector $midUpPos=($pUpPos2+$pUpPos1)/2;
float $midUpPosF3[]=$midUpPos;
setAttr up_loc.t $midUpPosF3[0] $midUpPosF3[1] $midUpPosF3[2];

Edit: I changed this from before because I was using order rather than id. It was working the other way but it should be id.

CGTalk Moderation
03-22-2010, 08:06 PM
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.