Class: FlameChannelParser::FramecurveWriters::BatchTimewarp

Inherits:
SoftfxTimewarp show all
Defined in:
lib/framecurve_writers/batch_timewarp.rb

Overview

Writes out a Batch timewarp node setup

Constant Summary collapse

TEMPLATE =
File.dirname(__FILE__) + "/templates/BatchTW.xml"
TEMPLATE_KEY =
File.dirname(__FILE__) + "/templates/key.xml"

Constants inherited from SoftfxTimewarp

SoftfxTimewarp::DATETIME_FORMAT, SoftfxTimewarp::TIME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited, #run_export_from_framecurve, with_each_writer

Class Method Details

.extensionObject



7
8
9
# File 'lib/framecurve_writers/batch_timewarp.rb', line 7

def self.extension
  '.timewarp_node'
end

Instance Method Details

#run_export(io) {|w| ... } ⇒ Object

Yields:

  • (w)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/framecurve_writers/batch_timewarp.rb', line 11

def run_export(io)
  w = KeyWriter.new
  yield(w)
  keys = w.keys
  
  keys_data = ''
  keys.each_with_index do | k, idx |
    keys_data << templatize(TEMPLATE_KEY, :frame => k[0].to_i, :value => k[1].to_f, :idx => idx)
  end
  
  # Whole range BOTH in the source and destination
  used_frames = (keys.map{|k| k[1]} + keys.map{|k| k[0]}).sort
  first_frame, last_frame = used_frames[0], used_frames[-1]
  
  info = {:start_frame => first_frame, :last_frame => last_frame, :first_value => keys[0][1], :key_size => keys.size, :keys => keys_data }
  io.write(templatize(TEMPLATE, info))
end