Sha256: d5f7ca5d2bff58595b94d63bf488e41cf1217b4fd1a52c68b587b7e4072d722e

Contents?: true

Size: 718 Bytes

Versions: 2

Compression:

Stored size: 718 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(/"/, '') }
        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
        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

2 entries across 2 versions & 1 rubygems

Version Path
tracksperanto-1.1.0 lib/import/pftrack.rb
tracksperanto-1.0.6 lib/import/pftrack.rb