Sha256: 70d4a16c509006f72a5cf2fa754f3213d0fdb1b536f24ed5fe167bb89ce22ef0

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 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_OR_QUOTES = /[AZaz"]/
  
  def stream_parse(io)
    until io.eof?
      line = io.gets
      next if (!line || line =~ /^#/)
      
      if line =~ CHARACTERS_OR_QUOTES # Tracker with a name
        t = Tracksperanto::Tracker.new{|t| t.name = line.strip.gsub(/"/, '') }
        report_progress("Reading tracker #{t.name}")
        parse_tracker(t, io)
        send_tracker(t)
      end
    end
  end
  
  private
    def parse_tracker(t, io)
      first_tracker_line = io.gets.chomp
      
      if first_tracker_line =~ CHARACTERS_OR_QUOTES # PFTrack version 5 format
        first_tracker_line = io.gets.chomp
      end
      
      num_of_keyframes = first_tracker_line.to_i
      (1..num_of_keyframes).map do | keyframe_idx |
        report_progress("Reading keyframe #{keyframe_idx} of #{num_of_keyframes} in #{t.name}")
        f, x, y, residual = io.gets.chomp.split
        t.keyframe!(:frame => f, :abs_x => x, :abs_y => y, :residual => residual.to_f * 8)
      end
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tracksperanto-2.0.2 lib/import/pftrack.rb
tracksperanto-2.0.1 lib/import/pftrack.rb
tracksperanto-2.0.0 lib/import/pftrack.rb
tracksperanto-1.9.9 lib/import/pftrack.rb