Hello,
I'm performing a facial animation using Tracking data, and I need to rigg a face using the tracking data that has been transformed into Locators.
Basically a script that take the Locators(that contain the animation), and transform them into joints, so they can be used to attach to the normal face model and animate the character's face.
// This script will select a vert on a model and add an emitter and a marker to the object.
// This will take a selection of verts and make and turn it into a string/list. -fl flag is added to deal with the verts, this way it will seperate everything out so we can do an operation on each vert.
string $sel[] = ls -fl -sl
;
string $obj;
// This will set up a loop for us to use.
for ($obj in $sel)
{
select $obj;
// Rename strings
string $emitterRename = ($obj +"emitter");
string $normalConstraintRename = ($obj +"normConstraint");
print $emitterRename;
print $normalConstraintRename;
// Make the emitter
emitter -type omni -r 100 -sro 0 -nuv 0 -cye none -cyi 1 -spd 1 -srn 0 -nsp 1 -tsp 0 -mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 -n emitter;
HideSelectedObjects;
// Make the nurbs spheres
// If you want to change the size of the spheres, change the number after -r
sphere -p 0 0 0 -ax 0 1 0 -ssw 0 -esw 360 -r .1 -d 3 -ut 0 -tol 0.01 -s 2 -nsp 2 -ch 1 -n marker_CTRL;objectMoveCommand;
setDisplaySmoothness 3;
DeleteHistory;
// Create a joint for each marker. These Joints will follow the markers due to the parent constraint we are about to make.
// If you want to change the joint radius, change the number after "joint.radius"
joint -p 0 0 0 -n joint_ -rad .05;
select -cl ;
// objExists will return true or false (1 or 0), so you can use it multiple ways.
int $objTest = objExists rootJointWorld
;
// If that object exists, it will return 1 (true), so then you could say something like:
if($objTest == 1) {
print "It Exists!" ;
}
else {
// This will create a joint at the world orient, all other joints will be parented to this joint.
// -n will allow us to name the joint, and -rad will let us set the radius for the joint.
joint -p 0 0 0 -n rootJointWorld -rad .2;
}
select -r joint_ rootJointWorld;
parent;
select -r marker_CTRL joint_;
parentConstraint -weight 1;
select -cl ;
select -r joint_;
rename "joint_" "joint_000";
// Create marker group
select -r marker_CTRL;
group -em -n marker_CTRL_Group; xform -os -piv 0 0 0 ;
// Parent the marker to the group
select -r marker_CTRL marker_CTRL_Group;
parent;
// Point constrain the marker group to the emitter
select -r "emitter" marker_CTRL_Group;
pointConstraint -weight 1;
// Normal constrain the marker group to the object
select -r $obj marker_CTRL_Group;
normalConstraint -weight 1 -aimVector 0 1 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 -n $normalConstraintRename;
// Rename the parts
rename "marker_CTRL" "marker_CTRL_";
rename "emitter" $emitterRename;
rename "marker_CTRL_Group" "marker_CTRL_Group_";
//end of the loop
}
// Group the markers
select -r "marker_CTRL_Group_*";
group -n marker_CTRL_GROUPS; xform -os -piv 0 0 0;
// Groups all the emitters into a set.
select -r -ne "emitterSet*";
$createSetResult = sets -name emitterSets\_ALL
;
select -cl ;