Sha256: 3d0bbe89a73958a3c8d6f1546cd364dd70b4f7dd8193b2d7faa069f1cf8cb101

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

class Tracksperanto::Import::Syntheyes < Tracksperanto::Import::Base
  
  def self.human_name
    "Syntheyes 2D tracker paths file"
  end
  
  def parse(io)
    trackers = []
    io.each_line do | line |
      name, frame, x, y, frame_status = line.split
      
      # Do we already have this tracker?
      t = trackers.find {|e| e.name == name}
      if !t
        report_progress("Allocating tracker #{name}")
        t = Tracksperanto::Tracker.new{|t| t.name = name }
        trackers << t
      end
      
      # Add the keyframe
      t.keyframes << Tracksperanto::Keyframe.new do |e| 
        e.frame = frame
        e.abs_x = convert_from_uv(width, x)
        e.abs_y = height - convert_from_uv(height, y) # Convert TL to BL
      end
      report_progress("Adding keyframe #{frame} to #{name}")
    end
    
    trackers
  end
  
  private
    # Syntheyes exports UV coordinates that go from -1 to 1, up and right and 0
    # is the center
    def convert_from_uv(absolute_side, uv_value)
      # First, start from zero (-.1 becomes .4)
      value_off_corner = (uv_value.to_f / 2) + 0.5
      absolute_side * value_off_corner
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tracksperanto-1.6.0 lib/import/syntheyes.rb
tracksperanto-1.5.7 lib/import/syntheyes.rb
tracksperanto-1.5.6 lib/import/syntheyes.rb
tracksperanto-1.5.5 lib/import/syntheyes.rb
tracksperanto-1.5.4 lib/import/syntheyes.rb