-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoscillate.mel
More file actions
26 lines (21 loc) · 889 Bytes
/
oscillate.mel
File metadata and controls
26 lines (21 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// "oscillation_controller" is the name of the object that has oscillation controls
// testcube.translateY is the attribute that is being oscilated
float $currentFrame = `currentTime -q`;
string $frequencyAttribute = "oscillation_controller.frequency";
float $amp = oscillation_controller.amplitude;
float $center = oscillation_controller.oscillationCenter;
float $phase = oscillation_controller.phase;
float $timeOffset = oscillation_controller.timeOffset;
proc float riemann(float $frame, string $attribute, float $step) {
if ($frame < 0) {
$step = $step * -1;
}
float $t = 0;
float $result = 0;
while (`abs $t` < `abs $frame`) {
$result += `getAttr -time $t $attribute` * $step;
$t += $step;
}
return $result;
}
cube.translateY = $center + $amp * sin(riemann($currentFrame + $timeOffset, $frequencyAttribute, 1)/24 + $phase);