Class: Tracksperanto::Import::ShakeText

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

Overview

Import for Shake Text files

Instance Attribute Summary

Attributes inherited from Base

#height, #io, #progress_block, #width

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

autodetects_size?, distinct_file_ext, inherited, known_snags, #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

Class Method Details

.human_nameObject



4
5
6
# File 'lib/import/shake_text.rb', line 4

def self.human_name
  "Shake .txt tracker file and Nuke CameraTracker auto tracks export"
end

Instance Method Details

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

Yields:

  • (@last_tracker)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/import/shake_text.rb', line 8

def each
  @io.each do | line |
    if line =~ /TrackName (.+)/
      yield(@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
  
  yield(@last_tracker) if @last_tracker && @last_tracker.any?
end