Class: Tracksperanto::Export::FlameStabilizerCornerpin::Sorter

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

Overview

The trackers for cornerpins should go in Z order, like this

TL(0)---->TR(1)
          /
       /
    /
 /
BL(2)----->BR(3)

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.



27
28
29
# File 'lib/export/flame_stabilizer_cornerpin.rb', line 27

def initialize(exporter)
  @exp = exporter
end

Instance Method Details

#end_exportObject



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

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 = [tl, tr, bl, br] # If we have less than 4 we might have a problem
  
  @exp.just_export(bulk, @width, @height)
end

#end_tracker_segmentObject



47
48
49
# File 'lib/export/flame_stabilizer_cornerpin.rb', line 47

def end_tracker_segment
  # Just leave that
end

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



42
43
44
45
# File 'lib/export/flame_stabilizer_cornerpin.rb', line 42

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



31
32
33
34
# File 'lib/export/flame_stabilizer_cornerpin.rb', line 31

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

#start_tracker_segment(name) ⇒ Object



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

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