lib/import/nuke_script.rb in tracksperanto-3.2.2 vs lib/import/nuke_script.rb in tracksperanto-3.3.0.pre
- old
+ new
@@ -1,8 +1,7 @@
# -*- encoding : utf-8 -*-
require 'tickly'
-require File.expand_path(File.dirname(__FILE__)) + "/nuke_grammar/utils"
class Tracksperanto::Import::NukeScript < Tracksperanto::Import::Base
def self.human_name
"Nuke .nk script file with Tracker, Reconcile3D and PlanarTracker nodes"
@@ -15,25 +14,20 @@
def self.known_snags
'The only supported nodes that we can extract tracks from are Reconcile3D, PlanarTracker and Tracker (supported Nuke versions are 5, 6 and 7)'
end
def each
- parser = Tickly::NodeExtractor.new("Tracker3", "Tracker4", "PlanarTracker1_0", "Reconcile3D")
- script_tree = Tickly::Parser.new.parse(@io)
+ parser = Tickly::NodeProcessor.new
+ parser.add_node_handler_class(Tracker3)
+ parser.add_node_handler_class(Reconcile3D)
+ parser.add_node_handler_class(PlanarTracker1_0)
+ parser.add_node_handler_class(Tracker4)
- evaluator = Tickly::Evaluator.new
- evaluator.add_node_handler_class(Tracker3)
- evaluator.add_node_handler_class(Reconcile3D)
- evaluator.add_node_handler_class(PlanarTracker1_0)
- evaluator.add_node_handler_class(Tracker4)
-
- script_tree.each do | node |
- evaluator.evaluate(node) do | node_object |
- node_object.trackers.each do | t |
- report_progress("Scavenging tracker #{t.name}")
- yield t
- end
+ parser.parse(@io) do | node |
+ node.trackers.each do | t |
+ report_progress("Scavenging tracker #{t.name}")
+ yield t
end
end
end
private
@@ -68,15 +62,14 @@
end
end
end
def extract_curves_from_channel(point_channel)
- u = Tracksperanto::NukeGrammarUtils.new
# First element is the :c curly identifier
point_channel[1..-1].map do | curve_argument |
if curve_argument[1] == "curve"
- u.parse_curve(curve_argument.to_a)
+ Tickly::Curve.new(curve_argument)
else
nil
end
end.compact
end
@@ -115,17 +108,17 @@
# "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]
- u = Tracksperanto::NukeGrammarUtils.new
-
# The 0 element is the :c symbol
tracker_rows[1..-1].each do | row |
row_content = row[0]
# For offsets see above
- point_name, x_curve, y_curve = row_content[2], u.parse_curve(row_content[3].to_a), u.parse_curve(row_content[4].to_a)
+ point_name = row_content[2]
+ 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
end