Minor changes to adjust CPoffset PuppetRig and StopmotionLayer to the new model.

renaissance
yorch 11 years ago
parent f4c74abe46
commit df5ea0ac01

@ -66,8 +66,6 @@ function YCPOffset()
}
this.yMainFunction = function yMainFunction()
{
alert(this);
//if called from the button as opposed as from the script.
if ( String(this) == "[object Button]" )
{

@ -1,245 +1,89 @@
yPuppetRig_data = new Object();
yPuppetRig_data.scriptName = 'yPuppetRigger';
yPuppetRig_data.scriptVer = 'v0.3.3a';
yPuppetRig_data.scriptDesc = 'Tools for streamlining puppet-based animation rigs.';
yPuppetRig_data.string_info = 'yorchnet.com';
yPuppetRig_data.e_000 = 'e_000 : No layers are selected.';
yPuppetRig_data.e_001 = 'e_001 : Layer contains no effects.';
yPuppetRig_data.e_002 = 'e_002 : Layer contains no Puppet effects.';
yPuppetRig_data.string_001 = 'Rig Pins';
yPuppetRig_data.string_001x = 'Rigs Selected Pins on Layer';
yPuppetRig_data.string_002 = 'Rig Layers';
yPuppetRig_data.string_002x = 'Rigs Selected Layers';
yPuppetRig_data.string_003 = 'Rig All';
yPuppetRig_data.string_003x = 'Rig All Layers in Comp';
//it should be called from toolbox.
yPuppetRig_data.buttonWidth=76;
yPuppetRig_data.buttonHeight=30;
//if yToolBox Exists add it to its tool list.
if (typeof(YTB)!=='undefined'){
YTB.tools.push(yPuppetRig_data);
yPuppetRig_data.btnLayout = "btn_"+ yPuppetRig_data.scriptName+": Button { preferredSize: ['"+YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+yPuppetRig_data.scriptName+"', helpTip:'"+yPuppetRig_data.scriptDesc+"' }";
}
#include "../yScripts/y_JSExtensions.jsx";
function YGenericTool()
{
this.info =
{
name : "yGenericTool",
version : 0.0,
stage : "development",
description : "Generic script to use as a base for new tools.",
url : "yorchnet.com"
};
this.appearence =
{
buttonHeight : 30,
buttonWidth : 126
};
this.resources =
{
icon : new File('yNet.png'),
};
this.init = function init()
{
function build_yPuppetRig_data_UI(){
//define custom strings for error messages, names, button names and helpTips. //Defines Layout variables.
this.btnLauyout =
"button\
{\
preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\
text:'" + this.info.name + "',\
helpTip:'" + this.info.description + "'\
}";
yPuppetRig_data.res = "window { \
type:'palette' , text:'"+yPuppetRig_data.scriptName+" "+yPuppetRig_data.scriptVer+"',margins:[10,10,10,10],spacing:[5,5,5,5],\
grp: Group { orientation:'column' , alignment:['fill','fill'] , alignChildren:['fill','fill'] , spacing:'2' , margin:'5', \
btn_01: Button { preferredSize: ['"+yPuppetRig_data.buttonWidth+"','"+yPuppetRig_data.buttonHeight+"'], text:'"+yPuppetRig_data.string_001+"', helpTip:'"+yPuppetRig_data.string_001x+"' }, \
btn_02: Button { preferredSize: ['"+yPuppetRig_data.buttonWidth+"','"+yPuppetRig_data.buttonHeight+"'], text:'"+yPuppetRig_data.string_002+"', helpTip:'"+yPuppetRig_data.string_002x+"' }, \
btn_03: Button { preferredSize: ['"+yPuppetRig_data.buttonWidth+"','"+yPuppetRig_data.buttonHeight+"'], text:'"+yPuppetRig_data.string_003+"', helpTip:'"+yPuppetRig_data.string_003x+"' }, \
chk_optn: Checkbox { text:'Enable Options', alignment:['fill','center'] , helpTip:'Enable Advanced Options' },\
optn: Panel{ text:'Options' , visible:'false', orientation:'row' , alignment:['fill','fill'] , alignChildren:['fill','fill'] , spacing:'2' , margin:'5', \
nullSizeGrp: Group{ \
orientation:'column' , alignment:['fill','fill'] , alignChildren:['fill','fill'] , spacing:'2' , margin:'5', \
sldr_tit: StaticText { text:'Set Null Size in Pixels.', alignment:['fill','center'] },\
sldr: Slider { value:'125' , minvalue:'6' , maxvalue:'250' , text:'alaverga', helpTip:'"+yPuppetRig_data.string_001x+"' }, \
sldr_Values_txt: Group{\
orientation:'row' , alignment:['fill','fill'] , alignChildren:['center','fill'] , spacing:'2' , margin:'5', \
mintxt: StaticText { text:'small', alignment:['left','fill'] },\
medtxt: StaticText { text:'medium', alignment:['center','fill'] },\
maxtxt: StaticText { text:'big', alignment:['right','fill'] },\
}\
otherOptionsGrp: Group{ \
orientation:'row' , alignment:['fill','fill'] , alignChildren:['fill','fill'] , spacing:'8' , margin:'5', \
chk_box_01: Checkbox { text:'Enable Draft Mode.', alignment:['fill','center'] , helpTip:'Mostly for oldschool pixelated stuff' },\
chk_box_02: Checkbox { text:'Lock Layer', alignment:['fill','center'] , helpTip:'Lock layer after rigging.' },\
this. res =
"window\
{\
type:'palette',\
text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\
info: Group \
{\
alignment:['center','bottom'],\
icon: Image \
{\
icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\
preferredSize: [15, 18]\
},\
}\
website: StaticText\
{\
text:'" + this.info.url + "',\
alignment:['fill','center']\
},\
info: Group { \
alignment:['center','bottom'], \
icn_app: Image {icon:'"+ YTB.icon.path+'/'+ YTB.icon.name+"',preferredSize: [15, 18]},\
txt_info: StaticText { text:'"+yPuppetRig_data.string_info+"', alignment:['fill','center'] },\
}\
}\
}";
//if (typeof(YTB)!=='undefined'){
yPuppetRigDialog = new Window (yPuppetRig_data.res); // Creates Window
//}
//yPuppetRigDialog.onDraw = customColors(yPuppetRigDialog);
yPuppetRigDialog.grp.optn.enabled = false;
yPuppetRigDialog.show(); //Shows Window.
//yPuppetRigDialog.grp.info.icn_app.image = YTB.icon.substring(3,YTB.icon.length);
yPuppetRigDialog.grp.btn_01.onClick = runRigPin; //Defines Button Action
yPuppetRigDialog.grp.btn_02.onClick = runRigLayer; //Defines Button Action
yPuppetRigDialog.grp.btn_03.onClick = runRigAll; //Defines Button Action
yPuppetRigDialog.grp.chk_optn.onClick = toggleOptions;
}
yPuppetRig_data.activate = build_yPuppetRig_data_UI ;
function toggleOptions(){
if(yPuppetRigDialog.grp.chk_optn==true){
yPuppetRigDialog.grp.chk_optn=false;
}
else
{
yPuppetRigDialog.grp.chk_optn=true;
}
yPuppetRigDialog.grp.optn.enabled = yPuppetRigDialog.grp.chk_optn;
}
function customColors(rsr){
g = rsr.graphics;
myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.25, 0.05, 0.25, 1]);
g.backgroundColor = yToolBoxPalette.graphics.backgroundColor;
}
function getPuppetEffects(aLayer){
puppetEffects = []
for(i=1;i<=aLayer('Effects').numProperties;i++){
puppetEffects.push(aLayer('Effects')(i));
}
return puppetEffects;
}
function getPosPins(aLayer){
puppetEffects = getPuppetEffects(aLayer);
if(puppetEffects.length>0){
posPins = [];
for(i=0;i<puppetEffects.length;i++){
posPinGroup = puppetEffects[i]('ADBE FreePin3 ARAP Group')('ADBE FreePin3 Mesh Group')('ADBE FreePin3 Mesh Atom')('ADBE FreePin3 PosPins');
for(j=1;j<=posPinGroup.numProperties;j++){
posPins.push(puppetEffects[i]('ADBE FreePin3 ARAP Group')('ADBE FreePin3 Mesh Group')('ADBE FreePin3 Mesh Atom')('ADBE FreePin3 PosPins')(j));
}
}
return posPins;
}
else
this.createUI = function createUI()
{
writeLn('No FreePin3 Effect found on Layer');
return []
}
}
function rigPins(aLayer,selectedOnly){
pins = getPosPins(aLayer);
selectedPins = [];
createdNulls =[];
for(i=0;i<pins.length;i++){
selectedPins.push(pins[i].selected)
}
setPropsFromUI();
for(i=0;i<pins.length;i++){
if(selectedPins[i]||!selectedOnly){
createdNulls.push([app.project.activeItem.layers.addNull(),pins[i]]);// populate register of created Nulls, associated with the pin property groups that will be controlled by them.
createdNulls[i][0].source.height = createdNulls[i][0].source.width = nullSize;
createdNulls[i][0].name = aLayer.name+"_"+createdNulls[i][1].name; //set nulls name to it's parent layer's name + the puppuet point name.
createdNulls[i][0].label = aLayer.label; // set nulls label equalt to its parent layer.
createdNulls[i][0].transform.anchorPoint.setValue([createdNulls[i][0].source.width/2,createdNulls[i][0].source.height/2]); //center pivot of created nulls
createdNulls[i][0].moveBefore(aLayer); //stack created null on top of original layer.
pinPosition = createdNulls[i][1]('ADBE FreePin3 PosPin Position').value;
aLayerPosition = aLayer('ADBE Transform Group')('ADBE Position').value;
aLayerAnchorPoint = aLayer('ADBE Transform Group')('ADBE Anchor Point').value;
createdNulls[i][0].transform.position.setValue(pinPosition+aLayerPosition-aLayerAnchorPoint); //needs a toWorld Function
txtExpression = 'l = thisComp.layer('+'"'+createdNulls[i][0].name+'"'+');\
'+'fromWorld(l.toComp(l.transform.anchorPoint))';
createdNulls[i][1]('ADBE FreePin3 PosPin Position').expression = txtExpression;
//there has to be a way to re select the original layer one had selected.
}
else{
createdNulls.push([null,null])
}
}
//stuff to apply to main layer
aLayer.quality = layerQuality;
aLayer.locked = layerLock;
pins = null;
selectedPins = null;
createdNulls = null;
pinPosition = null;
aLayerPosition= null;
aLayerAnchorPoint = null;
txtExpression = null;
}
function runRigPin(){
/* NOT WORKING YET
app.beginUndoGroup(string_001);
allLayers = app.project.activeItem.layers;
workLayers = [];
for(i=1;i<=allLayers.length;i++){
if(allLayers[i].selected){
workLayers.push(allLayers[i]);
}
}
for(x=0;x<workLayers.length;x++){
rigPins(workLayers[x],false);
}
app.endUndoGroup();
*/
app.beginUndoGroup(yPuppetRig_data.string_001);
sel =app.project.activeItem.selectedLayers;
setPropsFromUI();
rigPins(sel[0],true);
app.endUndoGroup();
}
function runRigLayer(){
app.beginUndoGroup(yPuppetRig_data.string_002);
allLayers = app.project.activeItem.layers;
workLayers = [];
for(i=1;i<=allLayers.length;i++){
if(allLayers[i].selected){
workLayers.push(allLayers[i]);
}
}
for(x=0;x<workLayers.length;x++){
rigPins(workLayers[x],false);
}
app.endUndoGroup();
}
function runRigAll(){
app.beginUndoGroup(yPuppetRig_data.string_003);
allLayers = app.project.activeItem.layers;
workLayers = [];
for(i=1;i<=allLayers.length;i++){
workLayers.push(allLayers[i]);
}
for(x=0;x<workLayers.length;x++){
rigPins(workLayers[x],false);
}
app.endUndoGroup();
}
function setPropsFromUI(){
nullSize = yFactor(parseInt(yPuppetRigDialog.grp.optn.nullSizeGrp.sldr.value),5)
if(yPuppetRigDialog.grp.optn.nullSizeGrp.otherOptionsGrp.chk_box_02.value==true){
layerLock =true // solo si vamos a hacer vainas pixeladas.
}
else
res =
"window {\
resizeable : true\
closeButton : true\
text:'wtf'\
}"
this.window = new Window( res );
this.window.layout.layout(true);
this.window.center();
this.window.show();
}
this.yMainFunction = function yMainFunction()
{
layerLock =false // solo si vamos a hacer vainas pixeladas.
this.createUI();
}
if(yPuppetRigDialog.grp.optn.nullSizeGrp.otherOptionsGrp.chk_box_01.value==true){
layerQuality =LayerQuality.DRAFT // solo si vamos a hacer vainas pixeladas.
}
else
this.activate = function activate()
{
layerQuality =LayerQuality.BEST // solo si vamos a hacer vainas pixeladas.
this.yTool.yMainFunction();
}
}
//build_yPuppetRig_UI();
this.init();
return this;
}
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
if (typeof(YTB)=='undefined'){
yPuppetRig_data.activate();
}else{
}
if (typeof(YTB)=='undefined')
{
yGenericTool = new YGenericTool();
yGenericTool.activate();
}
else
{
YTB.addTool(new YGenericTool());
}

@ -1,101 +1,89 @@
yStopMotion_data = new Object();
yStopMotion_data.scriptName = 'yStopMotion';
yStopMotion_data.scriptDesc = 'Dynamically change layer sequence opacity from a slider in pComp';
yStopMotion_data.scriptVer = '0.1a';
yStopMotion_data.webLink = 'yorchnet.com';
//if yToolBox Exists add it to its tool list.
if (typeof(YTB)!=='undefined'){
YTB.tools.push(yStopMotion_data);
//it should be called from toolbox.
/* yStopMotion_data.buttonWidth=76;
yStopMotion_data.buttonHeight=30;
*/
yStopMotion_data.btnLayout = "btn_"+yStopMotion_data.scriptName+": Button { preferredSize: ['"+ YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+yStopMotion_data.scriptName+"', helpTip:'"+yStopMotion_data.scriptDesc+"' }";
}
#include "../yScripts/y_JSExtensions.jsx";
function YGenericTool()
{
this.info =
{
name : "yGenericTool",
version : 0.0,
stage : "development",
description : "Generic script to use as a base for new tools.",
url : "yorchnet.com"
};
this.appearence =
{
buttonHeight : 30,
buttonWidth : 126
};
this.resources =
{
icon : new File('yNet.png'),
};
this.init = function init()
{
this.btnLauyout =
"button\
{\
preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\
text:'" + this.info.name + "',\
helpTip:'" + this.info.description + "'\
}";
yStopMotion_data.res = "window { \
type:'palette' , text:'"+yStopMotion_data.scriptName+' '+yStopMotion_data.scriptVer+"',\
\
\
info: Group { \
alignment:['center','bottom'], \
icon: Image {preferredSize: [15, 18]},\
website: StaticText { text:'"+yStopMotion_data.webLink+"', alignment:['fill','center'] },\
this. res =
"window\
{\
type:'palette',\
text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\
info: Group \
{\
alignment:['center','bottom'],\
icon: Image \
{\
icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\
preferredSize: [15, 18]\
},\
website: StaticText\
{\
text:'" + this.info.url + "',\
alignment:['fill','center']\
},\
}\
\
}";
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
// MAIN SCRIPT GOES HERE.
e_0000 = "There are no comps in project."
e_0001 = "No Comps selected."
function yStopMotionLayer(){
myName = "yStopMotionLayer";
myVer = "0.2a";
nComps = app.project.items.length;
app.beginUndoGroup(myName);
if(nComps>0){
sel = app.project.activeItem.selectedLayers; //array containing selection;
if(sel.length == 1&&sel[0].source!= null){
myItem = sel[0].source;
myItemType = myItem.typeName;
if(myItemType!="Composition"){
alert(e_0001,myName+' '+myVer);
}else{
sliderCtrl = sel[0]("Effects").addProperty("Slider Control");
sliderCtrl.name = "Animation State"; //should check for previously created sliders named the same and name uniquely accordingly.
txtExpression = 'myLayer = thisLayer;myComp =comp(myLayer.name);\
max = myComp.numLayers;\
myValue = effect("'+sliderCtrl.name+'")("'+sliderCtrl("Slider").name+'");\
if(myValue<=max&&myValue>1){\
parseInt(myValue)\
}else if (myValue>max){\
max\
}else if(myValue<1){1}';
//'l = thisComp.layer('+'"'+app.project.activeItem.selectedLayers[0].name+'"'+');'+'fromWorld(l.toComp(l.transform.anchorPoint))';
sliderCtrl("Slider").expression = txtExpression;
sliderCtrl("Slider").setValue(1);
txtExpression = null;
nLayers =myItem.numLayers;
txtExpression = 'extValue = comp("'+sel[0].containingComp.name+'").layer("'+myItem.name+'").effect("'+sliderCtrl.name+'")("'+sliderCtrl("Slider").name+'");if(extValue == thisLayer.index){100}else{0}';
for (z=1;z<=nLayers;z++){
myItem.layer(z).opacity.expression=txtExpression;
}
txtExpression = null;
this.createUI = function createUI()
{
res =
"window {\
resizeable : true\
closeButton : true\
text:'wtf'\
}"
this.window = new Window( res );
this.window.layout.layout(true);
this.window.center();
this.window.show();
}
}else{
alert(e_0001,myName+' '+myVer);
this.yMainFunction = function yMainFunction()
{
this.createUI();
}
}else{
alert(e_0000,myName+' '+myVer+" : Error");
this.activate = function activate()
{
this.yTool.yMainFunction();
}
app.endUndoGroup();
}
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
function build_yStopMotion_data_UI(){
yStopMotion_data.window = new Window ( yStopMotion_data.res);
yStopMotion_data.window.show();
}
yStopMotion_data.activate = yStopMotionLayer ;
this.init();
return this;
}
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
if (typeof(YTB)=='undefined'){
yStopMotion_data.activate();
}else{
}
if (typeof(YTB)=='undefined')
{
yGenericTool = new YGenericTool();
yGenericTool.activate();
}
else
{
YTB.addTool(new YGenericTool());
}

Loading…
Cancel
Save