A link to understand of what we are talking :
http://www.videocopilot.net/tutorials/presets_and_more/
This is the original code for the SureTarget 1.51 preser.
Code: Select all
ST = effect("SureTarget")("Curseur");
Min = Math.floor(ST);
Max = Min+1;
try{
L = effect("T-"+Min)("Calque"); M = effect("T-"+Max)("Calque"); exists = true;
}catch (err){
function countItems(obj) { a=0; while (true) { a++; try { eval(obj+"("+a+")"); } catch(error) { a--; break; } } return a } TargetCount = countItems("effect") - 5; exists = false;
}
// here is the part who interessting me
if(exists){ Amin = effect("T-"+Min)("Calque").position+wig; Amax = effect("T-"+Max)("Calque").position+wig; }else{Amin = effect("T-"+(TargetCount))("Calque").position+wig; Amax = effect("T-"+TargetCount)("Calque").position+wig;}
if(effect("EaseTargets")("Case") == 0){ linear(ST,Min,Min+1,Amin,Amax); }else{ ease(ST,Min,Min+1,Amin,Amax); }
If you used this with parented layers, it makes a weird trajectory. So i have modified the code with a basic toWorld. It look like this :
Code: Select all
ST = effect("SureTarget")("Curseur");
Min = Math.floor(ST);
Max = Min+1;
try{
L = effect("T-"+Min)("Calque"); M = effect("T-"+Max)("Calque"); exists = true;
}catch (err){
function countItems(obj) { a=0; while (true) { a++; try { eval(obj+"("+a+")"); } catch(error) { a--; break; } } return a } TargetCount = countItems("effect") - 5; exists = false;
}
// here is the modified part.
if(exists){ Amin = effect("T-"+Min)("Calque").toWorld((0,0,0),time)+wig; Amax = effect("T-"+Max)("Calque").toWorld((0,0,0),time)+wig; }else{Amin = effect("T-"+(TargetCount))("Calque").toWorld((0,0,0),time)+wig; Amax = effect("T-"+TargetCount)("Calque").toWorld((0,0,0),time)+wig;}
if(effect("EaseTargets")("Case") == 0){ linear(ST,Min,Min+1,Amin,Amax); }else{ ease(ST,Min,Min+1,Amin,Amax); }
But you always have the same problem with the rotation of the parented layers, this is the original code.
Code: Select all
if(exists){ Amin = effect("T-"+Min)("Calque").transform.zRotation; Amax = effect("T-"+Max)("Calque").transform.zRotation;}else{Amin = effect("T-"+TargetCount)("Calque").transform.zRotation; Amax = effect("T-"+TargetCount)("Calque").transform.zRotation;}
And this is the modified version of the code based on Dan Ebberts
http://www.motionscript.com/mastering- ... ient.html
, who allow the following of the zRotation
Code: Select all
// i'm calculating the possible value before the test!
u = effect("T-"+Min)("Calque").toWorldVec([1,0]);
Umin = radiansToDegrees(Math.atan2(u[1],u[0]));
u = effect("T-"+Max)("Calque").toWorldVec([1,0]);
Umax = radiansToDegrees(Math.atan2(u[1],u[0]));
u = effect("T-"+TargetCount)("Calque").toWorldVec([1,0]);
UTargetCount = radiansToDegrees(Math.atan2(u[1],u[0]));
if(exists){ Amin = Umin; Amax = Umax;}else{Amin =UTargetCount; Amax = UTargetCount;}
I have adapted this code for xRotation and yRotation by changing the toWorldVec in (0,1,0) and atan2(u(2),u(1)) for xRot and (0,0,1) and atan2(u(0),u(2)) for yRot.
It works for each rotation, but not if you used more than one rotation expression, because the rotation value becomes weird.
IN this state, it's useful but in order to become the real 1.6 version, i have to find a solution and for the moment i have no idea. The math works so i can't figure out why the rotation can't interact.
A possibility is to find an other technic to get the rotation value, without the toWorldvec.
If anybody have a solution, it will be useful for one of my script project, with a lot of parented text layer.
Thanks!
P.S.: a possibility is to search a recursive method to add all the rotation of the parented layer, until the first parent value, to obtain the real rotation value, even if it could take a long time with a lot of layers.
