Sha256: 3d9eed445fbb8eaf1a61a10c0920679801110fb4515457716f1f982fea5b678e

Contents?: true

Size: 948 Bytes

Versions: 31

Compression:

Stored size: 948 Bytes

Contents

# -*- encoding : utf-8 -*-
class Tracksperanto::Import::SyntheyesAllTrackerPaths < Tracksperanto::Import::Base
  def self.human_name
    "Syntheyes \"All Tracker Paths\" export .txt file"
  end
  
  CHARACTERS_OR_QUOTES = /[AZaz"]/
  TRACKER_KEYFRAME = /^(\d+) ((\d+)\.(\d+)) ((\d+)\.(\d+))/
  
  def each
    t = Tracksperanto::Tracker.new
    while line = @io.gets do
      if line =~ CHARACTERS_OR_QUOTES
        t = Tracksperanto::Tracker.new(:name => line)
        fill_tracker(t, @io)
        yield(t)
      end
    end
  end
  
  private
  
  def fill_tracker(t, io)
    loop do
      prev_pos = io.pos
      line = io.gets
      if line =~ TRACKER_KEYFRAME
        parts = line.scan(TRACKER_KEYFRAME).flatten
        t.keyframe!(:frame => parts[0], :abs_x => parts[1], :abs_y => parts[2])
      else
        # Backtrack to where we started the line and return control
        io.pos = prev_pos
        return
      end
    end
  end
  
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
tracksperanto-3.0.1 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-3.0.0 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.12.0 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.11.3 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.11.2 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.11.1 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.11.0 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.10.0 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.9.9 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.9.8 lib/import/syntheyes_all_tracker_paths.rb
tracksperanto-2.9.7 lib/import/syntheyes_all_tracker_paths.rb