Class: Tracksperanto::Export::NukeScript

Inherits:
Base
  • Object
show all
Defined in:
lib/export/nuke_script.rb

Overview

Export each tracker as a single Tracker3 node

Defined Under Namespace

Classes: T

Constant Summary collapse

NODE_TEMPLATE =
%[
Tracker3 {
     track1 {%s}
     name %s
     xpos 0
     ypos %d
}
]
KEYFRAME_PRECISION_TEMPLATE =
"%.4f"
PREAMBLE =
%[
version 5.1200
Constant {
 inputs 0
 channels rgb
 format "1920 1080 0 0 1920 1080 1"
 name CompSize_1920x1080
 postage_stamp false
 xpos 0
 ypos -60
}]
SCHEMATIC_OFFSET =
30

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#end_export, inherited, #initialize

Constructor Details

This class inherits a constructor from Tracksperanto::Export::Base

Class Method Details

.desc_and_extensionObject

Should return the suffix and extension of this export file (like “_flame.stabilizer”)



30
31
32
# File 'lib/export/nuke_script.rb', line 30

def self.desc_and_extension
  "nuke.nk"
end

.human_nameObject



34
35
36
# File 'lib/export/nuke_script.rb', line 34

def self.human_name
  "Nuke .nk script"
end

Instance Method Details

#end_tracker_segmentObject



50
51
52
53
54
# File 'lib/export/nuke_script.rb', line 50

def end_tracker_segment
  @io.puts( 
    NODE_TEMPLATE % [curves_from_tuples(@tracker), @tracker.name, (@ypos += SCHEMATIC_OFFSET)]
  )
end

#export_point(frame, abs_float_x, abs_float_y, float_residual) ⇒ Object



56
57
58
59
# File 'lib/export/nuke_script.rb', line 56

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  # Nuke uses 1-based frames
  @tracker << [frame + 1, abs_float_x, abs_float_y]
end

#start_export(w, h) ⇒ Object



38
39
40
41
# File 'lib/export/nuke_script.rb', line 38

def start_export(w, h)
  @io.puts(PREAMBLE.gsub(/1920/, w.to_s).gsub(/1080/, h.to_s))
  @ypos = 0
end

#start_tracker_segment(tracker_name) ⇒ Object

We accumulate a tracker and on end dump it out in one piece



44
45
46
47
48
# File 'lib/export/nuke_script.rb', line 44

def start_tracker_segment(tracker_name)
  # Setup for the next tracker
  @tracker = T.new
  @tracker.name = tracker_name
end