Class: Tracksperanto::Export::NukeScript
- Inherits:
-
Base
- Object
- Base
- Tracksperanto::Export::NukeScript
show all
- Defined in:
- lib/export/nuke_script.rb
Overview
Export each tracker as a single Tracker3 node
Constant Summary
collapse
- NODE_TEMPLATE =
%[
Tracker3 {
track1 {%s}
name %s
xpos 0
ypos %d
}
]
- KEYFRAME_PRECISION_TEMPLATE =
"%.4f"
- PREAMBLE =
%[
version 5.1200
Root {
inputs 0
frame 1
last_frame %d
}
Constant {
inputs 0
channels rgb
format "%d %d 0 0 %d %d 1"
name CompSize_%dx%d
postage_stamp false
xpos 0
ypos -60
}]
- SCHEMATIC_OFFSET =
Offset by which the new nodes will be shifted down in the node graph
30
Instance Attribute Summary
Attributes inherited from Base
#io
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Methods included from ConstName
#const_name
#just_export
Class Method Details
.desc_and_extension ⇒ Object
36
37
38
|
# File 'lib/export/nuke_script.rb', line 36
def self.desc_and_extension
"nuke.nk"
end
|
.human_name ⇒ Object
40
41
42
|
# File 'lib/export/nuke_script.rb', line 40
def self.human_name
"Nuke .nk script"
end
|
Instance Method Details
#end_export ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/export/nuke_script.rb', line 72
def end_export
@trackers_io.rewind
preamble_values = [@max_frame + 1, @w, @h, @w, @h, @w, @h]
@io.puts(PREAMBLE % preamble_values)
@io.write(@trackers_io.read) until @trackers_io.eof?
@trackers_io.close!
end
|
#end_tracker_segment ⇒ Object
59
60
61
62
63
64
|
# File 'lib/export/nuke_script.rb', line 59
def end_tracker_segment
coord_tuples = @tracker.map{|kf| [kf.frame, kf.abs_x, kf.abs_y]}
@trackers_io.puts(
NODE_TEMPLATE % [curves_from_tuples(coord_tuples), @tracker.name, (@ypos += SCHEMATIC_OFFSET)]
)
end
|
#export_point(frame, abs_float_x, abs_float_y, float_residual) ⇒ Object
66
67
68
69
70
|
# File 'lib/export/nuke_script.rb', line 66
def export_point(frame, abs_float_x, abs_float_y, float_residual)
@tracker.keyframe!(:frame => frame + 1, :abs_x => abs_float_x, :abs_y => abs_float_y)
@max_frame = frame if frame > @max_frame
end
|
#start_export(w, h) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/export/nuke_script.rb', line 44
def start_export(w, h)
@max_frame, @ypos, @w, @h = 0, 0, w, h
@trackers_io = Tracksperanto::BufferIO.new
end
|
#start_tracker_segment(tracker_name) ⇒ Object
We accumulate a tracker and on end dump it out in one piece
54
55
56
57
|
# File 'lib/export/nuke_script.rb', line 54
def start_tracker_segment(tracker_name)
@tracker = Tracksperanto::Tracker.new(:name => tracker_name)
end
|