Sha256: 378dbcf8b283b877a0a6f6780b1e30ce367c84612d9d89366f7f57549d6c8d0c

Contents?: true

Size: 883 Bytes

Versions: 1

Compression:

Stored size: 883 Bytes

Contents

# Import for Shake Text files
class Tracksperanto::Import::ShakeText < Tracksperanto::Import::Base
  
  def self.human_name
    "Shake .txt tracker file"
  end
  
  def stream_parse(io)
    io.each do | line |
      if line =~ /TrackName (.+)/
        send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
        @last_tracker = Tracksperanto::Tracker.new(:name => $1)
        # Toss the next following string - header
        io.gets
      else
        keyframe_values = line.split
        next if keyframe_values.length < 4
        
        @last_tracker.keyframe!(
          :frame => (keyframe_values[0].to_i - 1),
          :abs_x => keyframe_values[1],
          :abs_y => keyframe_values[2],
          :residual => (1 - keyframe_values[3].to_f)
        )
      end
    end
    
    send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracksperanto-2.1.1 lib/import/shake_text.rb