Skip to content

Commit

Permalink
Documentation and naming updates
Browse files Browse the repository at this point in the history
Added visual examples to the documentation and updated the naming convention used for curveAtTime.
  • Loading branch information
jeinselen committed May 26, 2021
1 parent 939295b commit af535d5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Functions for use in Blender channel drivers.
Installation and usage:
- Download the .py file
- Open up Blender preferences
- Install the add-on
- Enable
- Install the addon
- Enable the addon
- Add a driver to any channel via keyboard shortcut (usually "D"), context menu (right-click), or directly (typing "#" and then the function)


## curveAtFrame
## curveAtTime
This driver function is intended to mimic Adobe After Effect's "valueAtTime" expression, returning the value of an animated channel from the specified point in time.

After Effects expression reference:
Expand All @@ -20,12 +20,22 @@ This returns the value of the "Cube" layer's X position from 0.167 seconds in th

Blender driver equivalent:
```javascript
curveAtFrame("Cube", 0, frame-5)
curveAtTime("Cube", 0, frame-5)
```
This returns the value of the "Cube" object's first animation curve from 5 frames in the past, relative to the current frame.

Note that Blender's time sampling doesn't allow references to an object's transform property; it has to be an animation curve, and it can only be referenced by index. The first channel that is keyframed will be assigned index 0, the second channel to be animated will be index 1, and so on.

### curveAtTime examples

![three spheres in a white environment, the left side is animated, the other two are tied to it using the curveAtTime driver function in Blender](images/curveAtTime.gif)

1. The left sphere is named "Sphere" and has an animation curve applied to the Z position channel
2. The middle sphere has the following driver applied to the Z position channel: `curveAtTime("Sphere", 0, frame-5)`
- Note how the time offset is implemented in frames, not fractions of a second like in AE
3. The right sphere has the following driver applied to the Z position channel: `curveAtTime("Sphere", 0, frame*0.5-5)`
- Note how the current frame value is multiplied by 0.5 to slow down time


## wiggle
Designed to mimic Adobe After Effect's "wiggle" expression with similar frequency (colloquially known as wiggles per second) and octave settings.
Expand All @@ -44,3 +54,19 @@ wiggle(3, 0.2, 1, 4)
This automatically animates a channel and vaguely matches AE's 3 "wiggles" per second, a potential distance range of -200mm to 200mm (if used in a transform channel), with 1 octave of noise, and a random seed of 4 (seeds can be any floating point number, including negative numbers).

Note that unlike After Effects, driver functions in Blender don't automatically receive unique identifiers for each channel they are applied to, so a unique seed value must be provided by the user.

### wiggle examples

![two spheres and a cube in a white environment animated using the wiggle driver function in Blender](images/wiggle.gif)

1. The left sphere has the following drivers applied to the Z position and all three scale channels:
- Z: `wiggle(2, 0.125, 3, 4.5) + 0.5`
- Scale: `wiggle(2, 0.25, 3, 4.5) + 1.0`
2. The middle sphere has the following drivers applied to the X, Y, and Z position channels:
- X: `wiggle(1, .45, 1, 0.5)`
- Y: `wiggle(2, .35, 1, 1.5)`
- Z: `wiggle(1, .25, 1, 2.5) + 0.75`
3. The right cube has the following drivers applied to the Z. Y, and Z rotation channels:
- X: `round(wiggle(0.3, 7.0, 3, 100)) / 7.0 * pi`
- Y: `round(wiggle(0.3, 7.0, 3, 200)) / 7.0 * pi`
- Z: `round(wiggle(0.3, 7.0, 3, 200)) / 7.0 * pi`
12 changes: 6 additions & 6 deletions VF_curveAtFrame.py → VF_curveAtTime.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
bl_info = {
"name": "VF curveAtFrame",
"name": "VF curveAtTime",
"author": "John Einselen - Vectorform LLC",
"version": (0, 1),
"version": (0, 2),
"blender": (2, 80, 0),
"location": "Channel driver -> curveAtFrame(\"Cube\", 0, frame-5)",
"description": "Adds curveAtFrame(objectName, curveIndex, time) driver function",
"location": "Channel driver -> curveAtTime(\"Cube\", 0, frame-5)",
"description": "Adds curveAtTime(objectName, curveIndex, time) driver function",
"warning": "inexperienced developer, use at your own risk",
"wiki_url": "",
"tracker_url": "",
Expand All @@ -15,7 +15,7 @@
# https://blender.stackexchange.com/questions/71305/how-to-make-an-addon-with-custom-driver-function

# Example usage:
# curveAtFrame("Cube", 0, frame-5)
# curveAtTime("Cube", 0, frame-5)
# returns the "Cube" object's first animation curve value 5 frames in the past
# note that Blender requires an animation curve to get time-based data, and doesn't reference them by type or name, only index number

Expand All @@ -31,7 +31,7 @@ def curve_at_time(name, channel, frame):
@persistent
def load_handler(dummy):
dns = bpy.app.driver_namespace
dns["curveAtFrame"] = curve_at_time
dns["curveAtTime"] = curve_at_time

def register():
load_handler(None)
Expand Down
Binary file added images/curveAtTime.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/wiggle.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit af535d5

Please sign in to comment.