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

Methods included from SimpleExport

#just_export

Methods included from ConstName

#const_name, included

Constructor Details

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

Class Method Details

.desc_and_extensionObject



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

def self.desc_and_extension
  "nuke.nk"
end

.human_nameObject



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

def self.human_name
  "Nuke .nk script"
end

Instance Method Details

#end_tracker_segmentObject



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

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



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

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



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

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



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

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