Sha256: 86cdc166b337b7f793e83f2caaad1849095fa21f2198804be38b8e167fc7329c

Contents?: true

Size: 930 Bytes

Versions: 5

Compression:

Stored size: 930 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{|t| t.name = $1 }
        # Toss the next following string - header
        io.gets
      else
        keyframe_values = line.split
        next if keyframe_values.length < 4
        
        @last_tracker.keyframes << Tracksperanto::Keyframe.new do | kf |
          kf.frame = (keyframe_values[0].to_i - 1)
          kf.abs_x = keyframe_values[1]
          kf.abs_y = keyframe_values[2]
          kf.residual = (1 - keyframe_values[3].to_f)
        end
      end
    end
    
    send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

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