Class: FlameChannelParser::Extractor
- Inherits:
-
Object
- Object
- FlameChannelParser::Extractor
- Defined in:
- lib/extractor.rb
Overview
Extracts and bakes a specific animation channel to a given buffer, one string per frame
Direct Known Subclasses
Defined Under Namespace
Classes: ChannelNotFoundError, NoKeyframesError
Constant Summary collapse
- DEFAULT_CHANNEL_TO_EXTRACT =
"Timing/Timing"
Class Method Summary collapse
-
.extract(path, options = {}) ⇒ Object
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).
Instance Method Summary collapse
Class Method Details
.extract(path, options = {}) ⇒ Object
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)
Note that start_frame and end_frame will be converted to integers. The output will look like this:
1 123.456
2 124.567
25 26 27 |
# File 'lib/extractor.rb', line 25 def self.extract(path, = {}) new.extract(path, ) end |
Instance Method Details
#extract(path, options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/extractor.rb', line 29 def extract(path, ) = DEFAULTS.dup.merge() File.open(path) do |f| # Then parse channels = FlameChannelParser.parse(f) selected_channel = find_channel_in(channels, [:channel]) interpolator = FlameChannelParser::Interpolator.new(selected_channel) # Configure the range configure_start_and_end_frame(f, , interpolator) # And finally... write_channel(interpolator, [:destination], [:start_frame], [:end_frame]) end end |