/*
Creates an on screen control for facial animation.
facialControl()
*/
fn facialControl=
(
rec=Rectangle length:10 10 name:(uniqueName "FaceControl") wireColor:[0,0,200] displayRenderMesh:false
cir=circle radius:1 name:(uniqueName "FaceControlHandle") wireColor:[200,0,0] displayRenderMesh:false
cir.parent=rec
setTransformLockFlags cir #{3..9}
conName=text text:"Control" size:2 wireColor:[0,150,0] pos:[0,5.5,0] alignment:2 displayRenderMesh:false
conName.parent=rec
addModifier conName (meshSelect())
setTransformLockFlags conName #{1..9}
rec.rotation.x_rotation=90
listCon=cir.pos.controller=position_list()
scCon=listCon.available.controller=position_script()
def=attributes clamp
(
parameters clampP
(
l type:#float
w type:#float
x type:#float
y type:#float
)
)
custAttributes.add scCon def
scCon.l.controller=rec.length.controller=bezier_float()
scCon.l=10
scCon.w.controller=rec.width.controller=bezier_float()
scCon.w=10
scCon.x.controller=listCon[1].x_position.controller=bezier_float()
scCon.y.controller=listCon[1].y_position.controller=bezier_float()
script="
x=0
y=0
w=this.w/2
l=this.l/2
if this.x>w then (x=-this.x+w;this.x=w)
if this.x<-w then (x=-this.x-w;this.x=-w)
if this.y>l then (y=-this.y+l;this.y=l)
if this.y<-l then (y=-this.y-l;this.y=-l)
[x, y, 0]
"
scCon.script=script
)
facialControl()