Class: Tracksperanto::Import::NukeScript::Tracker3

Inherits:
Object
  • Object
show all
Includes:
ZipTuples
Defined in:
lib/import/nuke_script.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ZipTuples

#zip_curve_tuples

Constructor Details

#initialize(options) ⇒ Tracker3

Returns a new instance of Tracker3


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/import/nuke_script.rb', line 44

def initialize(options)
  @trackers = []
  point_channels.each do | point_name |
    next unless options[point_name]
    point_channel = options[point_name]
    
    curves = extract_curves_from_channel(point_channel)
    
    # We must always have 2 anim curves
    next unless curves.length == 2
    
    full_name = [options["name"], point_name].join('_')
    tracker = package_tracker(full_name, curves[0], curves[1])
    
    @trackers << tracker
  end
end

Instance Attribute Details

#trackersObject (readonly)

Returns the value of attribute trackers


42
43
44
# File 'lib/import/nuke_script.rb', line 42

def trackers
  @trackers
end

Instance Method Details

#extract_curves_from_channel(point_channel) ⇒ Object


71
72
73
74
75
76
77
78
79
80
# File 'lib/import/nuke_script.rb', line 71

def extract_curves_from_channel(point_channel)
  # First element is the :c curly identifier
  point_channel[1..-1].map do | curve_argument | 
    if curve_argument[1] == "curve"
      Tickly::Curve.new(curve_argument)
    else
      nil
    end
  end.compact
end

#package_tracker(full_name, xcurve, ycurve) ⇒ Object


62
63
64
65
66
67
68
69
# File 'lib/import/nuke_script.rb', line 62

def package_tracker(full_name, xcurve, ycurve)
  frame_x_and_y = zip_curve_tuples(xcurve, ycurve)
  Tracksperanto::Tracker.new(:name => full_name) do | t |
    frame_x_and_y.each do | (f, x, y) |
        t.keyframe!(:frame => (f -1), :abs_x => x, :abs_y => y) 
    end
  end
end

#point_channelsObject


82
83
84
# File 'lib/import/nuke_script.rb', line 82

def point_channels
  %w( track1 track2 track3 track4 )
end