Class: Tracksperanto::Export::FlameStabilizer2014Cornerpin::Sorter

Inherits:
Object
  • Object
show all
Includes:
SimpleExport
Defined in:
lib/export/flame_stabilizer_2014_cornerpin.rb

Overview

The trackers for cornerpins should go in Z order, but now in N order, unline it did previously. Like so:

TL(1)     TR(3)
 ˆ \       ˆ
 |  \      |
 |    \    |
 |      \  |
BL(0)     BR(2)

This “kinda tool” ensures that this is indeed taking place

Instance Method Summary collapse

Methods included from SimpleExport

#just_export

Constructor Details

#initialize(exporter) ⇒ Sorter

Returns a new instance of Sorter.



26
27
28
# File 'lib/export/flame_stabilizer_2014_cornerpin.rb', line 26

def initialize(exporter)
  @exp = exporter
end

Instance Method Details

#end_exportObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/export/flame_stabilizer_2014_cornerpin.rb', line 50

def end_export
  # We will have problems sorting if we have too few trackers
  return @exp.just_export(@corners, @width, @height) unless @corners.length == 4
  
  # Sort the trackers, first in Y of the first keyframe
  in_y = sort_on_first_keyframe(@corners, :abs_y)
  
  # then on the X for the two separate blocks for top and bottom
  tl, tr = sort_on_first_keyframe(in_y[2..3], :abs_x)
  bl, br = sort_on_first_keyframe(in_y[0..1], :abs_x)
  
  bulk = [bl, tl, br, tr] # New Flame 2014 order
  
  @exp.just_export(bulk, @width, @height)
end

#end_tracker_segmentObject



46
47
48
# File 'lib/export/flame_stabilizer_2014_cornerpin.rb', line 46

def end_tracker_segment
  # Just leave that
end

#export_point(f, x, y, r) ⇒ Object



41
42
43
44
# File 'lib/export/flame_stabilizer_2014_cornerpin.rb', line 41

def export_point(f, x, y, r)
  return if @four_done
  @corners[-1].keyframe! :frame => f, :abs_x => x, :abs_y => y, :residual => r
end

#start_export(w, h) ⇒ Object



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

def start_export(w,h)
  @width, @height = w, h
  @corners, @four_done = [], false
end

#start_tracker_segment(name) ⇒ Object



35
36
37
38
39
# File 'lib/export/flame_stabilizer_2014_cornerpin.rb', line 35

def start_tracker_segment(name)
  @four_done = (@corners.length == 4)
  return if @four_done
  @corners.push(Tracksperanto::Tracker.new(:name => name))
end