2013-09-04

Common AE Expressions

Inertial Bounce is like making your moves "rubbery." Layers will overextend, then settle into place on position and rotation keyframes.

// Inertial Bounce (moves settle into place after bouncing around a little)
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}

if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
amp = .05;
freq = 4.0;
decay = 2.0;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}

//Takes 3d space of layer and converts to 2d screen space

thisComp.layer("Light 1").toComp([0,0,0]);

Jumpy Wiggle 1 makes wiggle skip and hold rather than move fluidly.

// Jumpy Wiggle 1 (moves at a random FPS)
v=wiggle(5,50);
if(v < 50)v=0;
if(v > 50)v=100;
v
Jumpy Wiggle 2 is similar to 1, but works at a defined FPS so your "jump" will happen at a regular pace.

// Jumpy Wiggle 2 (moves at a defined FPS)
fps=5; //frequency
amount=50; //amplitude
wiggle(fps,amount,octaves = 1, amp_mult = 0.5,(Math.round(time*fps))/fps);

Sometimes you just want something to move constantly without keyframing it. Use throw.

// Throw (move at a constant speed without keyframes)
veloc = -10; //horizontal velocity (pixels per second)
x = position[0] + (time - inPoint) *veloc;
y = position[1];
[x,y]

Same as throw, but for rotation.

// Spin (rotate at a constant speed without keyframes)
veloc = 360; //rotational velocity (degrees per second)
r = rotation + (time - inPoint) *veloc;
[r]

//Autofade: Add to opacity
transition = 20;       // transition time in frames
if (marker.numKeys<2 br=""> tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
linear(time, inPoint, inPoint + tSecs, 0, 100) - linear(time, outPoint - tSecs, outPoint, 0, 100)
}else{
linear(time, inPoint, marker.key(1).time, 0, 100) - linear(time, marker.key(2).time, outPoint, 0, 100)
}

//Snap zoom in and out: apply to scale
snapScale = 300; //percent of scale to zoom

trans = 4; //  transition time in frames
trans = trans * thisComp.frameDuration;
inTrans  = easeOut(time, inPoint, inPoint + trans, [snapScale,snapScale], [0,0]);
outTrans = easeIn(time, outPoint, outPoint - trans, [0,0], [snapScale, snapScale]);
value+ inTrans + outTrans

// Y Axis Jitter
probability = 8 ;  //higher is less likely
pos = 50;
val  = random(-probability-2, 1);
m = clamp(val, 0, 1);
y = wiggle(10, pos*m)-position;
value + [0, y[1]]

3D layer invisible while facing backwards to camera (use on Opacity):
if (toCompVec([0, 0, 1])[2] > 0 ) value else 0

Parent Puppet pin to Null (there is a script on AEscripts for this also I beleve, haven't used it):
n=thisComp.layer("NullObject_Name");
nullpos=n.toComp(n.anchorPoint);
fromComp(nullpos);
Numbers:
Add a slider and name to 'Value'

places = 3; //number of decimal places desired
val = effect("Value")("Slider"); //sub in the name of your slider here

factor = Math.pow(0.1, places) ;
sign = "";
if (val < 0) sign = "-";

val = Math.abs(val);
whole = Math.floor(val);
fraction = "" + Math.round((val - whole)/factor)*factor;

for (fraction; fraction.length < places+2; fraction+="0");

sign + whole + "." + fraction.substring(2, places+2)

Position from layer above
thisComp.layer(index - 1).transform.position

Number of decimal places
//--Begin Expression
nums = thisComp.layer("Deep Lime Green Solid 1").effect("Slider Control")("Slider");
numOfPlaces = 3;
//--Do not modify below this line


function roundTo(number, places)
{
num = Math.round ( Math.pow(number, places) );


NUMBER ROUNDING
myNumber = 23.3453255243697978;
round(myNumber, 2);

function round(aNum, dP) {
     return(Math.round(aNum*Math.pow(10, dP))/Math.pow(10, dP));
}
num /= Math.pow(10, places);
return num;
}

roundTo(nums, numOfPlaces)

//--End expression


Round decimal
Math.round(your_decimal_number_here)


RANDOM MOVEMENT
//Returns two values by default; [x-pos. y-pos]
segDur = .5;// duration of each "segment" of random motion
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];


seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal =  random(minVal,maxVal);
seedRandom(seed+1,true);
endVal = random(minVal,maxVal);
ease(time,segStart,segStart + segDur, startVal, endVal);


Time Output
//Contains rounding + always display 2 digits


min = Math.floor(time);
strMin = String(min);
if(min < 10){
  strMin = '0' + strMin;
}

sec = Math.round(((time) - min)*100);
strSec = String(sec);
if(sec < 10){
  strSec = '0' + strSec;
}

"18:22:" + strMin + ":" + strSec

Random Letters
//Begin expression
numOfLetters = 25; //Modify me
useSpaces = true; //Modify me
changeEveryFrame = true; //Modify me

//Don't modify below this line

seedRandom(index, !changeEveryFrame)
//--
function genLetter( ) {
r = random(65, 90);//from a to z
return String.fromCharCode( r );
}
s = "";
for(i = 0; i < numOfLetters; i++)
{
s += genLetter();
if(useSpaces)
s += " ";
}
s
//End expression

Loop
//Looping Script
freq = 0.6;
amp = 5;
loopTime = 10;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

Random Position HOLD
holdTime = .5; //time to hold each position (seconds)
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];


seed = Math.floor(time/holdTime);
seedRandom(seed,true);
random(minVal,maxVal)
Smooth Keyframes
smooth(width = .2, samples = 5, t = time)

Creating Trails

delay = 5; //number of frames to delay

d = delay*thisComp.frameDuration*(index - 1);
thisComp.layer(1).position.valueAtTime(time - d)

OR
thisComp.layer(index+1).transform.position.valueAtTime(time-.1)


Smooth Wiggle

seedRandom(time*5);
wiggle(0,100);

Copy size and rescale from layer above
thisComp.layer(index - 1).scale-[7,7]


Copy rotation from layer below and rotate 22.5
thisComp.layer(index+1).transform.rotation+22.5


Copy position from layer above
thisComp.layer(index-1).position


Keep x at 960, move Y X time * 100 pixels

[960, position[1]+time*-100]

Time delay from layer above
thisComp.layer(index+1).transform.position.valueAtTime(time-.1)

Wiggle in one direction only
Wiggle Y Only:

[value[0],wiggle(1,100)[1]]

Wiggle X Only:

[wiggle(5,30)[0],value[1]]

Wiggle X and Y seperately:

[wiggle(5,30)[0],wiggle(1,100)[1]]


Loop Types
loopOut("pingpong")  // ABCD(CBABCDCBA)
loopOut("continue") // ABCD(EFGHIJKL)
loopOut("Cycle")  // ABCD(ABCDABCD)


Range Mapping
input = effect("Slider Control")("Slider");
inputLow = 0;
inputHigh = 100;
outputLow = -100;
outputHigh = 100;

linear(input,inputLow,inputHigh,outputLow,outputHigh)

For when you want burn in text to automatically display the layer name (i.e. render out tiff sequence first, then making a QT w/ name burn in).


Make text layer, add expression to 'source text'.


function pad(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } var theLayerName = thisComp.layer(index+1).name; var theLayerNameSplit = theLayerName.split('.'); theLayerNameSplit[0];

To change which layer is read for the name, change the (index+1) to (index+2) and so on.

Counting numbers with comma:

startCount = 0;
endCount = 11689;
countDur = 1.2;
s = "" + Math.round(linear(time,0,countDur,startCount,endCount));


if (s.length > 3){
s.substr(0, s.length -3) + "," + s.substr(-3);
}else{
s
}



2013-01-30

C4D 快速鍵


[動畫模塊]
記錄激活的物體 F9
倒放 F6
播放 F8
自動關鍵幀 Ctrl + F9
點級別動畫開關 L
到第一幀 Shift + G
到前一個關鍵點 Ctrl + F
到前一幀 F
到下一個關鍵點 Ctrl + G
到下一幀 G
到結束幀 Shift + F
--------------------------------------------------------
[屬性管理器]
新建屬性管理器 Shift + F5
--------------------------------------------------------
[Body Paint 3D]
順時針旋轉畫筆 Alt Alt + . or Alt + ]
逆時針旋轉畫筆 Alt + , or Alt + [
增大畫筆尺寸 . or ]
減小畫筆尺寸 , or [
增加畫筆銳度 Shift + . or Shift + ]
減小畫筆銳度 Shift + , or Shift + [
增加筆觸壓力 Ctrl + . or Ctrl + ]
減小筆觸壓力 Ctrl + , or Ctrl + [
--------------------------------------------------------
[瀏覽器]
另存目錄 Shift + Ctrl + S
導入文件夾 Shift + O
導入文件 Shift + Ctrl + O
打開目錄 Ctrl + O
新建目錄 Ctrl + N
--------------------------------------------------------
[編輯器]
打開控制台 Alt + F9
打開坐標管理器 Shift + F7
變換坐標系 W
剪切 Ctrl + X
關閉視窗 Shift + W
刪除 Backspace
跳出盒式功能表 V
打開F-Curve 編輯器 Shift + F4
--------------------------------------------------------
[主功能表]
新建項目 Ctrl + N
合併項目 Shift + Ctrl + O
打開項目 Ctrl + O
關閉所有項目 Shift + Ctrl + F4
另存物體 Shift + Ctrl + S
關閉項目 Ctrl + F4
保存項目 Ctrl + S
--------------------------------------------------------
[材質管理器]
另存材質 Shift + Ctrl + S
載入材質 Shift + Ctrl + O
新建材質 Ctrl + N
打開材質管理器 Shift + F2
--------------------------------------------------------
[物體管理器]
載入物體 Shift + Ctrl + O
場景資訊 Ctrl + I
將所選物體打組 Alt + G
將所選物體解組 Shift + G
打開物體管理器 Shift + F1
另存物體 Shift + Ctrl + S
--------------------------------------------------------
[圖片瀏覽器]
灰階通道 S
紅色通道 R
綠色通道 G
藍色通道 B
打開圖片瀏覽器 Shift + F6
--------------------------------------------------------
[結構管理器]
導入ASCII 碼 Shift + Ctrl + O
跳到最後 End
跳到上一選擇處 L
跳到下一選擇處 N
跳到上一頁 Page Up
跳到下一頁 Page down
跳到開始處 Home
頂點貼圖模式 V
點模式 P
面模式 O
UVW模式 U
--------------------------------------------------------
[時間線]
打開時間線 Shift + F3
--------------------------------------------------------
[視窗]
移動視窗 1, Alt + MMB 快速鍵
縮放視窗 2, Alt + RMB 快速鍵
旋轉視窗 3, Alt + LMB 快速鍵
使視窗適合所選元素大小 S, Alt + S
使視窗適合激活物體大小 O, Alt + O
使視窗適合場景(不含攝像機和燈光) H, Alt + H
定製所有視窗 Alt + V
打開渲染視窗 Ctrl + R
取消視窗變化 Shift + Ctrl + Z
重做視窗變化 Shift + Ctrl + Y
最大化視窗1 F1
最大化視窗2 F2
最大化視窗3 F3
最大化視窗4 F4
轉變為四視窗 F5
切換活動視窗 Page Up
顯示切換快捷功能表 N
刷新視窗 A
顯示物體手柄 Alt + D
使用Isoline 編輯 Alt + A
--------------------------------------------------------
[Mocca]
時間彎曲 J 快速鍵
--------------------------------------------------------
[建模]
加點 M A
橋接 B, M B
刻刀 M C
閉合洞口 M D
創建面 M E
切割邊 M F
熨斗 M G
刀 K, M H
磁鐵 M I
鏡像 M K
設置點的位置資料 M L
移動邊 M O
縫合(點、邊) M P
銲接點 M Q
權重 HN M R, . 快速鍵
倒角 M S
擠壓 D, M T
向內倒角 I, M W
連續擠壓 M X
平滑擴展 M Y
法線移動 M Z
法線縮放 M #
法線旋轉 M ,
分離被選擇元素 U P
反轉法線 U R
移除多邊形 U E
細分 U S
融合 U Z
塌陷 U C
三角面轉換 U T
分離 U D
對齊法線 U A
擠壓 D
轉換為可編輯物體 C
多邊形再三角化 U G
所選面轉為四邊形 U U
移動視窗 1, Alt + MMB 快速鍵
縮放視窗 2, Alt + RMB 快速鍵
旋轉視窗 3, Alt + LMB 快速鍵
移動物體 4 快速鍵
縮放物體 5 快速鍵
旋轉物體 6 快速鍵
縮放模型 7 快速鍵
預設建模方式 Alt + Q
調節式建模方式 Alt + E
點邊面自動轉換建模方式 Alt + W
移動工具 E
旋轉工具 R
放縮工具 T
切換選擇工具 Space
切換子物體編輯方式 Return
取消動作 Shift + Z
全選 Ctrl + A
選擇相連的 U W
取消選擇 Shift + Ctrl + A
自由選擇 8 快速鍵
選擇 9 快速鍵
框選 0 快速鍵
反選 U I
轉換選擇(子物體) U X
選擇邊緣 U Q
填充選擇 U F
擴展選擇 U Y
Ring選擇 U B
Loop選擇 U L
收縮選擇 U K
跳出建模工具功能表 Alt + Ctrl + V

2010-10-22

AE Learning....



wiggle語法的使用,以及控制器slider應用。
effect> transform> separate XYZ position



parent應用(先選子再選母)
effect> stylize> motion tile (使用wiggle時有黑邊)
effect> time> time remap (改變comp的速度)



effect> cc pixel polly & shatter (like explosion)
effect> cc force motion blur (動態模糊)
新增adujestment layer,增加控制器slider,以控制particle以下數據...
effect> cc particle world
effect> lens blur (鏡頭模糊)
effect> out of focus (鏡頭模糊)