Friday, August 3, 2012

Trying to learn: Adding more code!


This is lesson 5 (Link).
This video further expands on the facial expressions controls and builds some relationships between them like having a blink affect the eye brows and the cheeks or a smile slider affect the mouth, the jaw and the cheeks all at the same time without having to animate them independently.

CODE IN EACH NULL OBJECT ATTACHED TO PUPPET PINS:  
  1. Go to the Null Object that corresponds with the names below.
  2. Copy the code that corresponds to the Null Object below. 
  3. Alt+Click on Position Stopwatch to paste code in blank.
  4. Profit.
ALL THE SLIDERS, BY NAME
Blink, MouthShape, Jaw, Smile, Eyebrows, Anger, Cheeks. Then make new ones by the names EyeBrowsRT and EyeBrowsLFT.  


ALL THE CODE THAT GOES INTO THE NULL OBJECTS THAT ARE ATTACHED TO THE PUPPET PINS ON THE HEAD COMPOSITION


Sometimes, when copying and pasting someone elses code, you may have named things differently and the code will error (ex: Cannot find "Jaw").
Delete everything after the equal sign (Blink=   ), put the cursor after the equal sign, 
then pick whip to the slider stopwatch for the Jaw slider.
  • Mouth_Bot:

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]+(Jaw-(MouthShape)*25)-(Smile*.15);

[PosX,PosY];

  • Mouth_LFT:

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]+(Smile);
PosY=transform.position[1]+(Jaw-(MouthShape)*25)*.5-(Smile*.7);

[PosX,PosY];

  • Mouth_RT:

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]-(Smile*.8);
PosY=transform.position[1]+(Jaw-(MouthShape)*25)*.5-(Smile*.5);

[PosX,PosY];
  • Brow_CNT:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]-(EyeBrows*.5)+(Anger*.3);

[PosX,PosY];

  • Brow_LFT:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrow_RT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrow_LFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]-(Anger*.5);
PosY=transform.position[1]-EyeBrows-EyeBrowLFT+(Blink*5);

[PosX,PosY];

  • Brow_RT:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrow_RT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrow_LFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]+(Anger*.5);
PosY=transform.position[1]-EyeBrows-EyeBrowRT+(Blink*5);

[PosX,PosY];

  • Cheek_LFT:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]+Smile
PosY=transform.position[1]-Smile-Cheeks-(Blink*3);

[PosX,PosY];

  • Cheek_RT:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]-Smile;
PosY=transform.position[1]-Smile-Cheeks-(Blink*3);

[PosX,PosY];

  • Nose:
None. There is no code for the nose. Huh.
  • MoutFace:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]-(Smile*.1)+(Jaw-MouthShape*25)*.25;

[PosX,PosY];

  • Chin:
Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]+Jaw;

[PosX,PosY];

CODE ADDED TO THE PUPPET PINS NEAR THE JAW.

The three to the left and right of the Chin pin. Those are Puppet Pins with no Null Objects. How the hell does this make any sense to me?

Both Sides:

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin #").position[0];
PosY=effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin #").position[1]+(Jaw*.4);

[PosX,PosY];


CODE ADDED TO PUPPET PINS ON EYEBROWS

Don't forget, the "center" of all these Null objects are in the Upper Left corner.
  • Eyebrow_LFT_01 (inner corner)


Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowRT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowLFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]-(Anger*.5);
PosY=transform.position[1]-(EyeBrows*0.7)-(EyeBrowLFT*.7)+(Blink*3)+(Anger*.3);

[PosX,PosY];


  • Eyebrow_LFT_02 (outer corner)

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowRT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowLFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]-(EyeBrows*.4)-(EyeBrowLFT*.4)+(Blink*2);

[PosX,PosY];


  • Eyebrow_RT_01 (inner corner)


Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowRT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowLFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0]+(Anger*.5);
PosY=transform.position[1]-(EyeBrows*0.7)-(EyeBrowRT*.7)+(Blink*3)+(Anger*.3);

[PosX,PosY];

  • Eyebrow_RT_02 (outer corner)

Blink=comp("Head_Flat_Med").layer("Head Controls").effect("Blink")("Slider");
MouthShape=comp("Head_Flat_Med").layer("Head Controls").effect("MouthShape")("Slider");
Jaw=comp("Head_Flat_Med").layer("Head Controls").effect("Jaw")("Slider");
Smile=comp("Head_Flat_Med").layer("Head Controls").effect("Smile")("Slider");
EyeBrows=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrows")("Slider");
EyeBrowRT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowRT")("Slider");
EyeBrowLFT=comp("Head_Flat_Med").layer("Head Controls").effect("EyeBrowLFT")("Slider");
Anger=comp("Head_Flat_Med").layer("Head Controls").effect("Anger")("Slider");
Cheeks=comp("Head_Flat_Med").layer("Head Controls").effect("Cheeks")("Slider");

PosX=transform.position[0];
PosY=transform.position[1]-(EyeBrows*.4)-(EyeBrowRT*.4)+(Blink*2);

[PosX,PosY];

Oddly enough, when I linked the Pins to the Null Object, the Eyebrow flew off the screen! So what I did is remembered (wrote down) the XY coordinates of the Puppet Pin before attaching the pin to the Null Object, then went to the Null object and plugged in the XY values. The Null Object floated out in the Netherworld, but the EyeBrow was good to go.

So.... WHEW! That's a lot of stuff! Time to take the weekend off!