Sha256: d31f82926e44cf58e851fe31eb3b03c4cf2dce4a1fbdc42cb239a25b3453cf8d

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
  def parse(file_content)
    trackers = []
    io = StringIO.new(file_content)
    until io.eof?
      line = io.gets
      next unless line
      
      if line =~ /[AZaz]/ # Tracker with a name
        t = Tracksperanto::Tracker.new{|t| t.name = line.strip.gsub(/"/, '') }
        report_progress("Reading tracker #{t.name}")
        parse_tracker(t, io)
        trackers << t
      end
    end
    
    trackers
  end
  
  private
    def parse_tracker(t, io)
      num_of_keyframes = io.gets.chomp.to_i
      t.keyframes = (1..num_of_keyframes).map do
        report_progress("Reading keyframe")
        Tracksperanto::Keyframe.new do |k| 
          k.frame, k.abs_x, k.abs_y, k.residual = io.gets.chomp.split
        end
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracksperanto-1.1.1 lib/import/pftrack.rb