Sha256: 35e1557b610118cf3e40f3bb66ae9eb96d13233333372b56189f8a3ab3578709

Contents?: true

Size: 1.38 KB

Versions: 34

Compression:

Stored size: 1.38 KB

Contents

# Imports 3D Equalizer's text files, version 3
class Tracksperanto::Import::Equalizer3 < Tracksperanto::Import::Base
  
  def self.human_name
    "3DE v3 point export file"
  end
  
  def self.autodetects_size?
    true
  end
  
  def parse(passed_io)
    io = Tracksperanto::ExtIO.new(passed_io)
    
    detect_format!(io)
    extract_trackers(io)
  end
  
  private
    
    def detect_format!(io)
      first_line = io.gets_non_empty
      self.width, self.height = first_line.scan(/(\d+) x (\d+)/).flatten
    end
    
    def extract_trackers(io)
      ts = []
      while line = io.gets do
        if line =~ /^(\w+)/ # Tracker name
          discard_last_empty_tracker!(ts)
          ts.push(Tracksperanto::Tracker.new(:name => line.strip))
          report_progress("Capturing tracker #{line.strip}")
        elsif line =~ /^\t/
          ts[-1].push(make_keyframe(line))
        end
      end
      
      discard_last_empty_tracker!(ts)
      ts
    end
    
    def discard_last_empty_tracker!(in_array)
      if (in_array.any? && in_array[-1].empty?)
        in_array.delete_at(-1)
        report_progress("Removing the last tracker since it had no keyframes")
      end
    end
    
    def make_keyframe(from_line)
      frame, x, y = from_line.split
      report_progress("Capturing keyframe #{frame}")
      Tracksperanto::Keyframe.new(:frame => (frame.to_i - 1), :abs_x => x, :abs_y => y)
    end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
tracksperanto-1.9.8 lib/import/equalizer3.rb
tracksperanto-1.9.6 lib/import/equalizer3.rb
tracksperanto-1.9.5 lib/import/equalizer3.rb
tracksperanto-1.9.4 lib/import/equalizer3.rb
tracksperanto-1.9.3 lib/import/equalizer3.rb
tracksperanto-1.9.2 lib/import/equalizer3.rb
tracksperanto-1.9.1 lib/import/equalizer3.rb
tracksperanto-1.9.0 lib/import/equalizer3.rb
tracksperanto-1.8.4 lib/import/equalizer3.rb
tracksperanto-1.8.2 lib/import/equalizer3.rb
tracksperanto-1.8.1 lib/import/equalizer3.rb
tracksperanto-1.8.0 lib/import/equalizer3.rb
tracksperanto-1.7.5 lib/import/equalizer3.rb
tracksperanto-1.7.4 lib/import/equalizer3.rb
tracksperanto-1.7.3 lib/import/equalizer3.rb
tracksperanto-1.7.2 lib/import/equalizer3.rb
tracksperanto-1.7.1 lib/import/equalizer3.rb
tracksperanto-1.7.0 lib/import/equalizer3.rb
tracksperanto-1.6.9 lib/import/equalizer3.rb
tracksperanto-1.6.8 lib/import/equalizer3.rb