class Tracksperanto::Import::NukeScript::Tracker4

Public Class Methods

new(options) click to toggle source
# File lib/import/nuke_script.rb, line 122
def initialize(options)
  
  @name = options["name"]
  @trackers = []
  tracks = options["tracks"]
  
  return unless tracks # For linked Tracker nodes that have no tracks
  
  preamble = tracks[1]
  headers = tracks[2]
  values = tracks[3]
  
  # When this was written, this was the order of the columns in the table:
  # le("e", "name", "track_x", "track_y", "offset_x", "offset_y", "T", "R", "S", "error",
  #  "error_min", "error_max", "pattern_x", "pattern_y", "pattern_r", "pattern_t", "search_x",
  # "search_y", "search_r", "search_t", "key_track", "key_search_x", "key_search_y", "key_search_r",
  # "key_search_t", "key_track_x", "key_track_y", "key_track_r", "key_track_t", "key_centre_offset_x", "key_centre_offset_y")
  tracker_rows = values[0]
  
  # The 0 element is the :c symbol
  tracker_rows[1..-1].each do | row |
    row_content = row[0]
    
    # For offsets see above
    point_name = row_content[2]
    begin
      x_curve = Tickly::Curve.new(row_content[3])
      y_curve = Tickly::Curve.new(row_content[4])
      full_name = [options["name"], point_name].join('_')
      tracker = package_tracker(full_name, x_curve, y_curve)
      @trackers << tracker
    rescue Tickly::Curve::InvalidCurveError
      # $stderr.puts "Failed to recover a tracker, it probably contained expressions"
    end
  end
end