Class: Tracksperanto::Import::MayaLive

Inherits:
Base
  • Object
show all
Defined in:
lib/import/maya_live.rb

Constant Summary collapse

COMMENT =
/^# /

Instance Attribute Summary collapse

Attributes inherited from Base

#height, #io, #progress_block, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

distinct_file_ext, inherited, #report_progress

Methods included from BlockInit

#initialize

Methods included from ZipTuples

#zip_curve_tuples

Methods included from ConstName

#const_name

Methods included from Safety

#safe_reader

Methods included from Casts

#cast_to_bool, #cast_to_float, #cast_to_int, #cast_to_string

Instance Attribute Details

#aspectObject

Maya Live exports and imports tracks in “aspect units”, so a point at 0,0 will be at -1.78,-1 in MayaLive coordinates with aspect of 1.78. Therefore we offer an override for the aspect being imported (if the pixels are not square)



6
7
8
# File 'lib/import/maya_live.rb', line 6

def aspect
  @aspect
end

Class Method Details

.autodetects_size?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/import/maya_live.rb', line 12

def self.autodetects_size?
  true
end

.human_nameObject



8
9
10
# File 'lib/import/maya_live.rb', line 8

def self.human_name
  "Maya Live track export file"
end

.known_snagsObject



16
17
18
# File 'lib/import/maya_live.rb', line 16

def self.known_snags
  'Only square pixel aspect ratio shots are supported.'
end

Instance Method Details

#each {|@last_tracker| ... } ⇒ Object

Yields:

  • (@last_tracker)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/import/maya_live.rb', line 22

def each
  io = Tracksperanto::ExtIO.new(@io)
  extract_width_height_and_aspect(io.gets_non_empty)
  
  while line = io.gets_and_strip
    if line =~ COMMENT
      yield(@last_tracker) if @last_tracker
      @last_tracker = Tracksperanto::Tracker.new(:name => line.gsub(/#{COMMENT} Name(\s+)/, ''))
      next
    end
    
    tracker_num, frame, x, y, residual = line.split
    
    abs_x, abs_y = aspect_values_to_pixels(x, y)
    @last_tracker.keyframe! :frame => frame, :abs_x => abs_x, :abs_y => abs_y,  :residual => set_residual(residual)
  end
  
  yield(@last_tracker) if @last_tracker
end