Class: FlameChannelParser::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/extractor.rb

Overview

Extracts and bakes a specific animation channel

Defined Under Namespace

Classes: ChannelNotFoundError, EmptySegmentError, NoKeyframesError

Constant Summary

DEFAULT_CHANNEL_TO_EXTRACT =
"Timing/Timing"
DEFAULTS =
{:destination => $stdout, :start_frame => nil, :end_frame => nil, :channel => DEFAULT_CHANNEL_TO_EXTRACT }

Class Method Summary (collapse)

Class Method Details

+ (Object) extract(path, options = {})

Pass the path to Flame setup here and you will get the animation curve on the object passed in the :destionation option (defaults to STDOUT). The following options are accepted:

:destination - The object to write the output to, anything that responds to shovel (<<) will do
:start_frame - From which frame the curve should be baked. Will default to the first keyframe of the curve
:end_frame - Upto which frame to bake. Will default to the last keyframe of the curve
:channel - Name of the channel to extract from the setup. Defaults to "Timing/Timing" (timewarp frame)


23
24
25
26
27
28
29
30
31
# File 'lib/extractor.rb', line 23

def self.extract(path, options = {})
  options = DEFAULTS.merge(options)
  File.open(path) do |f|
    channels = FlameChannelParser.parse(f)
    selected_channel = find_channel_in(channels, options[:channel])
    interpolator = FlameChannelParser::Interpolator.new(selected_channel)
    write_channel(interpolator, options[:destination], options[:start_frame], options[:end_frame])
  end
end