Sha256: ae90885709808e9ee27cebde190d3231768a1e8c43d2d1066f80b45585440f56

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

# The base middleware class works just like a Tracksperanto::Export::Base, but it only wraps another exporting object and does not get registered on it's own
# as an export format. Middleware can be used to massage the tracks being exported in various interesting ways - like moving the coordinates, clipping the keyframes,
# scaling the whole export or even reversing the trackers to go backwards
class Tracksperanto::Middleware::Base
  include Tracksperanto::Casts
  include Tracksperanto::BlockInit
  include Tracksperanto::ConstName
  include Tracksperanto::SimpleExport
  
  # Used to automatically register your middleware in Tracksperanto.middlewares
  # Normally you wouldn't need to override this
  def self.inherited(by)
    Tracksperanto.middlewares.push(by)
    super
  end
  
  # Constructor accepts the exporter that will be wrapped
  def initialize(*exporter_and_args_for_block_init)
    @exporter = exporter_and_args_for_block_init.shift
    super
  end
  
  # Called on export start
  def start_export( img_width, img_height)
    @exporter.start_export(img_width, img_height)
  end
  
  # Called on export end
  def end_export
    @exporter.end_export
  end
  
  # Called on tracker start, one for each tracker. Start of the next tracker
  # signifies that the previous tracker has passed by
  def start_tracker_segment(tracker_name)
    @exporter.start_tracker_segment(tracker_name)
  end
  
  # Called on tracker end
  def end_tracker_segment
    @exporter.end_tracker_segment
  end
  
  # Called for each tracker keyframe
  def export_point(at_frame_i, abs_float_x, abs_float_y, float_residual)
    @exporter.export_point(at_frame_i, abs_float_x, abs_float_y, float_residual)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tracksperanto-2.1.0 lib/middleware/base.rb
tracksperanto-2.0.2 lib/middleware/base.rb