Sha256: 4fa6d0628498bcda0a6fab519296527b02e80e7db258e1cd6f825b876d706f93

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
  def self.human_name
    "PFTrack .2dt file"
  end
  
  def self.distinct_file_ext
    ".2dt"
  end
  
  CHARACTERS = /[AZaz]/
  
  def parse(io)
    trackers = []
    until io.eof?
      line = io.gets
      next if (!line || line =~ /^#/)
      
      if line =~ CHARACTERS # 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)
      first_tracker_line = io.gets.chomp
      
      if first_tracker_line =~ CHARACTERS # PFTrack version 5 format
        first_tracker_line = io.gets.chomp
      end
      
      num_of_keyframes = first_tracker_line.to_i
      t.keyframes = (1..num_of_keyframes).map do | keyframe_idx |
        report_progress("Reading keyframe #{keyframe_idx} of #{num_of_keyframes}")
        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

16 entries across 16 versions & 1 rubygems

Version Path
tracksperanto-1.6.4 lib/import/pftrack.rb
tracksperanto-1.6.3 lib/import/pftrack.rb
tracksperanto-1.6.2 lib/import/pftrack.rb
tracksperanto-1.6.1 lib/import/pftrack.rb
tracksperanto-1.6.0 lib/import/pftrack.rb
tracksperanto-1.5.7 lib/import/pftrack.rb
tracksperanto-1.5.6 lib/import/pftrack.rb
tracksperanto-1.5.5 lib/import/pftrack.rb
tracksperanto-1.5.4 lib/import/pftrack.rb
tracksperanto-1.5.3 lib/import/pftrack.rb
tracksperanto-1.5.2 lib/import/pftrack.rb
tracksperanto-1.5.1 lib/import/pftrack.rb
tracksperanto-1.5.0 lib/import/pftrack.rb
tracksperanto-1.4.0 lib/import/pftrack.rb
tracksperanto-1.3.1 lib/import/pftrack.rb
tracksperanto-1.3.0 lib/import/pftrack.rb