Sha256: de48e7f4923fad0bcb130f2a5da238a260649c19c0d16792d8b01dc278b505d7

Contents?: true

Size: 1.21 KB

Versions: 42

Compression:

Stored size: 1.21 KB

Contents

# -*- encoding : utf-8 -*-
# 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 each
    io = Tracksperanto::ExtIO.new(@io)
    detect_format!(io)
    extract_trackers(io) {|t| yield(t) }
  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)
      while line = io.gets do
        if line =~ /^(\w+)/ # Tracker name
          yield(@last_tracker) if @last_tracker && @last_tracker.any?
          @last_tracker = Tracksperanto::Tracker.new(:name => line.strip)
          report_progress("Capturing tracker #{line.strip}")
        elsif line =~ /^\t/
          @last_tracker.keyframe!(make_keyframe(line))
        end
      end
      
      yield(@last_tracker) if @last_tracker && @last_tracker.any?
    end
    
    def make_keyframe(from_line)
      frame, x, y = from_line.split
      report_progress("Capturing keyframe #{frame}")
      {:frame => (frame.to_i - 1), :abs_x => x, :abs_y => y}
    end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
tracksperanto-3.5.9 lib/import/equalizer3.rb
tracksperanto-3.5.8 lib/import/equalizer3.rb
tracksperanto-3.5.7 lib/import/equalizer3.rb
tracksperanto-3.5.6 lib/import/equalizer3.rb
tracksperanto-3.5.5 lib/import/equalizer3.rb
tracksperanto-3.5.4 lib/import/equalizer3.rb
tracksperanto-3.5.2 lib/import/equalizer3.rb
tracksperanto-3.5.1 lib/import/equalizer3.rb
tracksperanto-3.5.0 lib/import/equalizer3.rb
tracksperanto-3.4.1 lib/import/equalizer3.rb
tracksperanto-3.4.0 lib/import/equalizer3.rb
tracksperanto-3.3.13 lib/import/equalizer3.rb
tracksperanto-3.3.12 lib/import/equalizer3.rb
tracksperanto-3.3.11 lib/import/equalizer3.rb
tracksperanto-3.3.10 lib/import/equalizer3.rb
tracksperanto-3.3.9 lib/import/equalizer3.rb
tracksperanto-3.3.8 lib/import/equalizer3.rb
tracksperanto-3.3.7 lib/import/equalizer3.rb
tracksperanto-3.3.6 lib/import/equalizer3.rb
tracksperanto-3.3.0.pre lib/import/equalizer3.rb