tracksperanto 1.9.8 → 1.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/bin/tracksperanto +1 -1
- data/lib/import/base.rb +25 -4
- data/lib/import/boujou.rb +13 -4
- data/lib/import/equalizer3.rb +6 -16
- data/lib/import/equalizer4.rb +2 -6
- data/lib/import/flame_stabilizer.rb +9 -6
- data/lib/import/match_mover.rb +3 -5
- data/lib/import/maya_live.rb +5 -5
- data/lib/import/nuke_script.rb +8 -9
- data/lib/import/pftrack.rb +4 -7
- data/lib/import/shake_script.rb +14 -6
- data/lib/import/shake_text.rb +7 -6
- data/lib/import/syntheyes.rb +8 -9
- data/lib/pipeline/base.rb +12 -12
- data/lib/tracksperanto/accumulator.rb +33 -0
- data/lib/tracksperanto.rb +2 -1
- data/test/helper.rb +1 -2
- data/test/import/test_3de_import.rb +1 -1
- data/test/import/test_3de_import3.rb +0 -1
- data/test/import/test_boujou_import.rb +2 -2
- data/test/test_flame_builder.rb +0 -1
- metadata +8 -7
data/Manifest.txt
CHANGED
@@ -58,6 +58,7 @@ lib/tracksperanto/simple_export.rb
|
|
58
58
|
lib/tracksperanto/tracker.rb
|
59
59
|
lib/tracksperanto/uv_coordinates.rb
|
60
60
|
lib/tracksperanto/zip_tuples.rb
|
61
|
+
lib/tracksperanto/accumulator.rb
|
61
62
|
test/export/README_EXPORT_TESTS.txt
|
62
63
|
test/export/samples/ref_Mayalive.txt
|
63
64
|
test/export/samples/ref_Mayalive_CustomAspect.txt
|
data/bin/tracksperanto
CHANGED
data/lib/import/base.rb
CHANGED
@@ -8,6 +8,9 @@ class Tracksperanto::Import::Base
|
|
8
8
|
include Tracksperanto::ZipTuples
|
9
9
|
include Tracksperanto::ConstName
|
10
10
|
|
11
|
+
# Every time the importer accumulates a tracker this block will be called
|
12
|
+
attr_accessor :receiver
|
13
|
+
|
11
14
|
# Tracksperanto will assign a proc that reports the status of the import to the caller.
|
12
15
|
# This block is automatically used by report_progress IF the proc is assigned. Should
|
13
16
|
# the proc be nil, the report_progress method will just pass (so you don't need to check for nil
|
@@ -60,12 +63,30 @@ class Tracksperanto::Import::Base
|
|
60
63
|
@progress_block.call(message) if @progress_block
|
61
64
|
end
|
62
65
|
|
66
|
+
# OBSOLETE: do not implement this method in your importer. This is used to accumulate trackers in an array
|
67
|
+
# and then send it to the caller. Used in tests.
|
68
|
+
def parse(track_file_io)
|
69
|
+
@receiver = []
|
70
|
+
class << @receiver
|
71
|
+
def call(with)
|
72
|
+
push(with)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
stream_parse(track_file_io)
|
77
|
+
@receiver
|
78
|
+
end
|
79
|
+
|
63
80
|
# The main method of the parser. Will receive an IO handle to the file being imported, and should
|
64
|
-
#
|
65
|
-
#
|
81
|
+
# send each consecutive tracker via the send_tracker method.
|
82
|
+
# Note that in general it's a good idea to stream-parse a document
|
66
83
|
# instead of bulk-reading it into memory (since Tracksperanto tries to be mem-efficient when dealing
|
67
84
|
# with large files)
|
68
|
-
def
|
69
|
-
|
85
|
+
def stream_parse(track_file_io)
|
86
|
+
end
|
87
|
+
|
88
|
+
# When a tracker has been detected completely (all keyframes) call this method with the tracker object as argument
|
89
|
+
def send_tracker(tracker_obj)
|
90
|
+
@receiver.call(tracker_obj) if @receiver
|
70
91
|
end
|
71
92
|
end
|
data/lib/import/boujou.rb
CHANGED
@@ -4,16 +4,25 @@ class Tracksperanto::Import::Boujou < Tracksperanto::Import::Base
|
|
4
4
|
"Boujou feature tracks export"
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def stream_parse(io)
|
8
8
|
wrapped_io = Tracksperanto::ExtIO.new(io)
|
9
9
|
detect_columns(wrapped_io)
|
10
10
|
trackers = {}
|
11
11
|
filtering_trackers_from(wrapped_io) do | name, frame, x, y |
|
12
|
-
|
12
|
+
if @last_tracker && (name != @last_tracker.name)
|
13
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
14
|
+
@last_tracker = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
if !@last_tracker
|
18
|
+
@last_tracker = Tracksperanto::Tracker.new(:name => name)
|
19
|
+
end
|
20
|
+
|
13
21
|
report_progress("Extracting frame #{frame} of #{name}")
|
14
|
-
|
22
|
+
@last_tracker.keyframe!(:frame => (frame.to_i - 1), :abs_y => (@height.to_f - y.to_f), :abs_x => x)
|
15
23
|
end
|
16
|
-
|
24
|
+
|
25
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
17
26
|
end
|
18
27
|
|
19
28
|
private
|
data/lib/import/equalizer3.rb
CHANGED
@@ -9,9 +9,8 @@ class Tracksperanto::Import::Equalizer3 < Tracksperanto::Import::Base
|
|
9
9
|
true
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def stream_parse(passed_io)
|
13
13
|
io = Tracksperanto::ExtIO.new(passed_io)
|
14
|
-
|
15
14
|
detect_format!(io)
|
16
15
|
extract_trackers(io)
|
17
16
|
end
|
@@ -24,31 +23,22 @@ class Tracksperanto::Import::Equalizer3 < Tracksperanto::Import::Base
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def extract_trackers(io)
|
27
|
-
ts = []
|
28
26
|
while line = io.gets do
|
29
27
|
if line =~ /^(\w+)/ # Tracker name
|
30
|
-
|
31
|
-
|
28
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
29
|
+
@last_tracker = Tracksperanto::Tracker.new(:name => line.strip)
|
32
30
|
report_progress("Capturing tracker #{line.strip}")
|
33
31
|
elsif line =~ /^\t/
|
34
|
-
|
32
|
+
@last_tracker.keyframe!(make_keyframe(line))
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
|
-
|
39
|
-
ts
|
40
|
-
end
|
41
|
-
|
42
|
-
def discard_last_empty_tracker!(in_array)
|
43
|
-
if (in_array.any? && in_array[-1].empty?)
|
44
|
-
in_array.delete_at(-1)
|
45
|
-
report_progress("Removing the last tracker since it had no keyframes")
|
46
|
-
end
|
36
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
47
37
|
end
|
48
38
|
|
49
39
|
def make_keyframe(from_line)
|
50
40
|
frame, x, y = from_line.split
|
51
41
|
report_progress("Capturing keyframe #{frame}")
|
52
|
-
|
42
|
+
{:frame => (frame.to_i - 1), :abs_x => x, :abs_y => y}
|
53
43
|
end
|
54
44
|
end
|
data/lib/import/equalizer4.rb
CHANGED
@@ -6,14 +6,10 @@ class Tracksperanto::Import::Equalizer4 < Tracksperanto::Import::Base
|
|
6
6
|
end
|
7
7
|
|
8
8
|
|
9
|
-
def
|
10
|
-
ts = []
|
9
|
+
def stream_parse(passed_io)
|
11
10
|
io = Tracksperanto::ExtIO.new(passed_io)
|
12
|
-
|
13
11
|
num_t = detect_num_of_points(io)
|
14
|
-
num_t.times {
|
15
|
-
|
16
|
-
ts
|
12
|
+
num_t.times { send_tracker(extract_tracker(io)) }
|
17
13
|
end
|
18
14
|
|
19
15
|
private
|
@@ -71,7 +71,7 @@ class Tracksperanto::Import::FlameStabilizer < Tracksperanto::Import::Base
|
|
71
71
|
private :to_ary
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
74
|
+
def stream_parse(io)
|
75
75
|
report_progress("Extracting setup size")
|
76
76
|
self.width, self.height = extract_width_and_height_from_stream(io)
|
77
77
|
report_progress("Extracting all animation channels")
|
@@ -81,7 +81,7 @@ class Tracksperanto::Import::FlameStabilizer < Tracksperanto::Import::Base
|
|
81
81
|
raise "A channel was nil" if channels.find{|e| e.nil? }
|
82
82
|
|
83
83
|
report_progress("Assembling tracker curves from channels")
|
84
|
-
scavenge_trackers_from_channels(channels)
|
84
|
+
scavenge_trackers_from_channels(channels) {|t| send_tracker(t) }
|
85
85
|
end
|
86
86
|
|
87
87
|
private
|
@@ -154,6 +154,12 @@ Channel tracker1/ref/x
|
|
154
154
|
end
|
155
155
|
|
156
156
|
USEFUL_CHANNELS = %w( /shift/x /shift/y /ref/x /ref/y ).map(&Regexp.method(:new))
|
157
|
+
|
158
|
+
# This method tells the importer whether a channel that has been found in the source
|
159
|
+
# setup is needed. If that method returns ++false++ the channel will be discarded and not
|
160
|
+
# kept in memory. Should you need to write a module that scavenges other Flame animation channels
|
161
|
+
# inherit from this class and rewrite this method to either return +true+ always (then all the channels
|
162
|
+
# will be recovered) or to return +true+ only for channels that you actually need.
|
157
163
|
def channel_is_useful?(channel_name)
|
158
164
|
USEFUL_CHANNELS.any?{|e| channel_name =~ e }
|
159
165
|
end
|
@@ -161,13 +167,10 @@ Channel tracker1/ref/x
|
|
161
167
|
REF_CHANNEL = "ref" # or "track" - sometimes works sometimes don't
|
162
168
|
|
163
169
|
def scavenge_trackers_from_channels(channels)
|
164
|
-
trackers = []
|
165
170
|
channels.select{|e| e.name =~ /\/#{REF_CHANNEL}\/x/}.each do | track_x |
|
166
171
|
report_progress("Detected reference channel #{track_x}")
|
167
|
-
|
172
|
+
yield grab_tracker(channels, track_x)
|
168
173
|
end
|
169
|
-
|
170
|
-
trackers
|
171
174
|
end
|
172
175
|
|
173
176
|
def grab_tracker(channels, track_x)
|
data/lib/import/match_mover.rb
CHANGED
@@ -12,10 +12,10 @@ class Tracksperanto::Import::MatchMover < Tracksperanto::Import::Base
|
|
12
12
|
".rz2"
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def stream_parse(io)
|
16
16
|
trackers = []
|
17
17
|
detect_format(io)
|
18
|
-
extract_trackers(io)
|
18
|
+
extract_trackers(io) { |t| send_tracker(t) }
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -29,11 +29,9 @@ class Tracksperanto::Import::MatchMover < Tracksperanto::Import::Base
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def extract_trackers(io)
|
32
|
-
tracks = []
|
33
32
|
while(line = io.gets) do
|
34
|
-
|
33
|
+
yield(extract_track(line, io)) if line =~ /^pointTrack/
|
35
34
|
end
|
36
|
-
tracks
|
37
35
|
end
|
38
36
|
|
39
37
|
def extract_track(start_line, io)
|
data/lib/import/maya_live.rb
CHANGED
@@ -15,24 +15,24 @@ class Tracksperanto::Import::MayaLive < Tracksperanto::Import::Base
|
|
15
15
|
|
16
16
|
COMMENT = /^# /
|
17
17
|
|
18
|
-
def
|
18
|
+
def stream_parse(original_io)
|
19
19
|
io = Tracksperanto::ExtIO.new(original_io)
|
20
20
|
extract_width_height_and_aspect(io.gets_non_empty)
|
21
|
-
trackers = []
|
22
21
|
|
23
22
|
while line = io.gets_and_strip
|
24
23
|
if line =~ COMMENT
|
25
|
-
|
24
|
+
send_tracker(@last_tracker) if @last_tracker
|
25
|
+
@last_tracker = Tracksperanto::Tracker.new(:name => line.gsub(/#{COMMENT} Name(\s+)/, ''))
|
26
26
|
next
|
27
27
|
end
|
28
28
|
|
29
29
|
tracker_num, frame, x, y, residual = line.split
|
30
30
|
|
31
31
|
abs_x, abs_y = aspect_values_to_pixels(x, y)
|
32
|
-
|
32
|
+
@last_tracker.keyframe! :frame => frame, :abs_x => abs_x, :abs_y => abs_y, :residual => set_residual(residual)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
send_tracker(@last_tracker) if @last_tracker
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
data/lib/import/nuke_script.rb
CHANGED
@@ -10,8 +10,14 @@ class Tracksperanto::Import::NukeScript < Tracksperanto::Import::Base
|
|
10
10
|
".nk"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
13
|
+
def stream_parse(in_io)
|
14
|
+
io = Tracksperanto::ExtIO.new(in_io)
|
15
|
+
while line = io.gets_and_strip
|
16
|
+
if line =~ TRACKER_3_PATTERN
|
17
|
+
scan_tracker_node(io).each { |t| send_tracker(t) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
15
21
|
end
|
16
22
|
|
17
23
|
private
|
@@ -20,13 +26,6 @@ class Tracksperanto::Import::NukeScript < Tracksperanto::Import::Base
|
|
20
26
|
TRACK_PATTERN = /^track(\d) \{/
|
21
27
|
NODENAME = /^name ([^\n]+)/
|
22
28
|
|
23
|
-
def scan_for_tracker3_nodes(io)
|
24
|
-
tracks = []
|
25
|
-
while line = io.gets_and_strip
|
26
|
-
tracks += scan_tracker_node(io) if line =~ TRACKER_3_PATTERN
|
27
|
-
end
|
28
|
-
tracks
|
29
|
-
end
|
30
29
|
|
31
30
|
def scan_tracker_node(io)
|
32
31
|
tracks_in_tracker = []
|
data/lib/import/pftrack.rb
CHANGED
@@ -9,8 +9,7 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
|
|
9
9
|
|
10
10
|
CHARACTERS_OR_QUOTES = /[AZaz"]/
|
11
11
|
|
12
|
-
def
|
13
|
-
trackers = []
|
12
|
+
def stream_parse(io)
|
14
13
|
until io.eof?
|
15
14
|
line = io.gets
|
16
15
|
next if (!line || line =~ /^#/)
|
@@ -19,11 +18,9 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
|
|
19
18
|
t = Tracksperanto::Tracker.new{|t| t.name = line.strip.gsub(/"/, '') }
|
20
19
|
report_progress("Reading tracker #{t.name}")
|
21
20
|
parse_tracker(t, io)
|
22
|
-
|
21
|
+
send_tracker(t)
|
23
22
|
end
|
24
23
|
end
|
25
|
-
|
26
|
-
trackers
|
27
24
|
end
|
28
25
|
|
29
26
|
private
|
@@ -35,10 +32,10 @@ class Tracksperanto::Import::PFTrack < Tracksperanto::Import::Base
|
|
35
32
|
end
|
36
33
|
|
37
34
|
num_of_keyframes = first_tracker_line.to_i
|
38
|
-
|
35
|
+
(1..num_of_keyframes).map do | keyframe_idx |
|
39
36
|
report_progress("Reading keyframe #{keyframe_idx} of #{num_of_keyframes} in #{t.name}")
|
40
37
|
f, x, y, residual = io.gets.chomp.split
|
41
|
-
|
38
|
+
t.keyframe!(:frame => f, :abs_x => x, :abs_y => y, :residual => residual.to_f * 8)
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
data/lib/import/shake_script.rb
CHANGED
@@ -25,8 +25,8 @@ class Tracksperanto::Import::ShakeScript < Tracksperanto::Import::Base
|
|
25
25
|
node_name = atom[1][-1]
|
26
26
|
trackers = atom[2][1][1..-1]
|
27
27
|
trackers.map do | tracker |
|
28
|
-
|
29
|
-
|
28
|
+
tracker.name = [node_name, tracker.name].join("_")
|
29
|
+
sentinel[0].call(tracker)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -239,11 +239,19 @@ class Tracksperanto::Import::ShakeScript < Tracksperanto::Import::Base
|
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
|
243
|
-
|
242
|
+
class PushCall
|
243
|
+
def initialize(proc)
|
244
|
+
@proc = proc
|
245
|
+
end
|
246
|
+
|
247
|
+
def push(t)
|
248
|
+
@proc.call(t)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def stream_parse(script_io)
|
244
253
|
progress_proc = lambda{|msg| report_progress(msg) }
|
245
|
-
Traxtractor.new(script_io, [
|
246
|
-
trackers
|
254
|
+
Traxtractor.new(script_io, [method(:send_tracker), progress_proc])
|
247
255
|
end
|
248
256
|
|
249
257
|
end
|
data/lib/import/shake_text.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
|
1
|
+
# Import for Shake Text files
|
2
2
|
class Tracksperanto::Import::ShakeText < Tracksperanto::Import::Base
|
3
3
|
|
4
4
|
def self.human_name
|
5
5
|
"Shake .txt tracker file"
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
trackers = []
|
8
|
+
def stream_parse(io)
|
10
9
|
io.each do | line |
|
11
10
|
if line =~ /TrackName (.+)/
|
12
|
-
|
11
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
12
|
+
@last_tracker = Tracksperanto::Tracker.new{|t| t.name = $1 }
|
13
13
|
# Toss the next following string - header
|
14
14
|
io.gets
|
15
15
|
else
|
16
16
|
keyframe_values = line.split
|
17
17
|
next if keyframe_values.length < 4
|
18
18
|
|
19
|
-
|
19
|
+
@last_tracker.keyframes << Tracksperanto::Keyframe.new do | kf |
|
20
20
|
kf.frame = (keyframe_values[0].to_i - 1)
|
21
21
|
kf.abs_x = keyframe_values[1]
|
22
22
|
kf.abs_y = keyframe_values[2]
|
@@ -25,6 +25,7 @@ class Tracksperanto::Import::ShakeText < Tracksperanto::Import::Base
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
29
29
|
end
|
30
|
+
|
30
31
|
end
|
data/lib/import/syntheyes.rb
CHANGED
@@ -5,29 +5,28 @@ class Tracksperanto::Import::Syntheyes < Tracksperanto::Import::Base
|
|
5
5
|
"Syntheyes 2D tracker paths file"
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
trackers = []
|
8
|
+
def stream_parse(io)
|
10
9
|
io.each_line do | line |
|
11
10
|
name, frame, x, y, frame_status = line.split
|
12
11
|
|
13
12
|
# Do we already have this tracker?
|
14
|
-
|
15
|
-
|
13
|
+
unless @last_tracker && @last_tracker.name == name
|
14
|
+
send_tracker(@last_tracker) if @last_tracker
|
16
15
|
report_progress("Allocating tracker #{name}")
|
17
|
-
|
18
|
-
trackers << t
|
16
|
+
@last_tracker = Tracksperanto::Tracker.new{|t| t.name = name }
|
19
17
|
end
|
20
18
|
|
21
19
|
# Add the keyframe
|
22
|
-
|
20
|
+
k = Tracksperanto::Keyframe.new do |e|
|
23
21
|
e.frame = frame
|
24
22
|
e.abs_x = convert_from_uv(width, x)
|
25
23
|
e.abs_y = height - convert_from_uv(height, y) # Convert TL to BL
|
26
24
|
end
|
25
|
+
|
26
|
+
@last_tracker.push(k)
|
27
27
|
report_progress("Adding keyframe #{frame} to #{name}")
|
28
28
|
end
|
29
|
+
send_tracker(@last_tracker) if @last_tracker && @last_tracker.any?
|
29
30
|
|
30
|
-
trackers
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
data/lib/pipeline/base.rb
CHANGED
@@ -116,25 +116,31 @@ class Tracksperanto::Pipeline::Base
|
|
116
116
|
end
|
117
117
|
@ios << io_with_progress
|
118
118
|
|
119
|
-
|
120
|
-
|
119
|
+
accumulator = Tracksperanto::Accumulator.new
|
120
|
+
importer.receiver = accumulator
|
121
|
+
@ios << accumulator
|
121
122
|
|
122
|
-
|
123
|
+
importer.stream_parse(io_with_progress)
|
124
|
+
|
125
|
+
report_progress(percent_complete = 50.0, "Validating #{accumulator.length} imported trackers")
|
126
|
+
raise "Could not recover any non-empty trackers from this file. Wrong import format maybe?" if accumulator.numt.zero?
|
123
127
|
|
124
128
|
report_progress(percent_complete, "Starting export")
|
125
129
|
|
126
|
-
percent_per_tracker = (100.0 - percent_complete) /
|
130
|
+
percent_per_tracker = (100.0 - percent_complete) / accumulator.numt
|
127
131
|
|
128
132
|
# Use the width and height provided by the parser itself
|
129
133
|
exporter.start_export(importer.width, importer.height)
|
130
|
-
|
134
|
+
accumulator.each_object_with_index do | t, tracker_idx |
|
135
|
+
raise "Not a Tracker" unless t.is_a?(Tracksperanto::Tracker)
|
136
|
+
|
131
137
|
kf_weight = percent_per_tracker / t.keyframes.length
|
132
138
|
points += 1
|
133
139
|
exporter.start_tracker_segment(t.name)
|
134
140
|
t.each_with_index do | kf, idx |
|
135
141
|
keyframes += 1
|
136
142
|
exporter.export_point(kf.frame, kf.abs_x, kf.abs_y, kf.residual)
|
137
|
-
report_progress(percent_complete += kf_weight, "Writing keyframe #{idx+1} of #{t.name.inspect}, #{
|
143
|
+
report_progress(percent_complete += kf_weight, "Writing keyframe #{idx+1} of #{t.name.inspect}, #{accumulator.numt - tracker_idx} trackers to go")
|
138
144
|
end
|
139
145
|
exporter.end_tracker_segment
|
140
146
|
end
|
@@ -166,10 +172,4 @@ class Tracksperanto::Pipeline::Base
|
|
166
172
|
@ios ||= []
|
167
173
|
@ios.push(File.open(path_to_file, "wb"))[-1]
|
168
174
|
end
|
169
|
-
|
170
|
-
# Check that the trackers made by the parser are A-OK
|
171
|
-
def validate_trackers!(trackers)
|
172
|
-
trackers.reject!{|t| t.empty? }
|
173
|
-
raise "Could not recover any non-empty trackers from this file. Wrong import format maybe?" if trackers.empty?
|
174
|
-
end
|
175
175
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Tracksperanto::Accumulator < DelegateClass(IO)
|
2
|
+
|
3
|
+
attr_reader :numt
|
4
|
+
def initialize
|
5
|
+
__setobj__(Tracksperanto::BufferIO.new)
|
6
|
+
@numt = 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(with_arrived_tracker)
|
10
|
+
|
11
|
+
@numt += 1
|
12
|
+
|
13
|
+
d = Marshal.dump(with_arrived_tracker)
|
14
|
+
bytelen = d.size
|
15
|
+
write(bytelen)
|
16
|
+
write("\t")
|
17
|
+
write(d)
|
18
|
+
write("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def each_object_with_index
|
22
|
+
rewind
|
23
|
+
@numt.times { |i| yield(recover_tracker, i - 1) }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def recover_tracker
|
29
|
+
# Read everything upto the tab
|
30
|
+
demarshal_bytes = gets("\t").strip.to_i
|
31
|
+
Marshal.load(read(demarshal_bytes))
|
32
|
+
end
|
33
|
+
end
|
data/lib/tracksperanto.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tempfile'
|
|
4
4
|
|
5
5
|
module Tracksperanto
|
6
6
|
PATH = File.expand_path(File.dirname(__FILE__))
|
7
|
-
VERSION = '1.9.
|
7
|
+
VERSION = '1.9.9'
|
8
8
|
|
9
9
|
module Import; end
|
10
10
|
module Export; end
|
@@ -83,6 +83,7 @@ end
|
|
83
83
|
simple_export
|
84
84
|
uv_coordinates
|
85
85
|
flame_builder
|
86
|
+
accumulator
|
86
87
|
).each do | submodule |
|
87
88
|
require File.join(Tracksperanto::PATH, "tracksperanto", submodule)
|
88
89
|
end
|
data/test/helper.rb
CHANGED
@@ -80,8 +80,7 @@ module ParabolicTracks
|
|
80
80
|
def ensure_same_output(exporter_klass, reference_path, message = "The line should be identical")
|
81
81
|
if ENV['OVERWRITE']
|
82
82
|
File.open(reference_path, "w") do | out |
|
83
|
-
|
84
|
-
export_parabolics_with(x)
|
83
|
+
export_parabolics_with(exporter_klass.new(out))
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -13,7 +13,6 @@ class Equalizer3ImportTest < Test::Unit::TestCase
|
|
13
13
|
fixture = File.open(File.dirname(__FILE__) + '/samples/3de_v3/3de_export_v3.txt')
|
14
14
|
|
15
15
|
parser = Tracksperanto::Import::Equalizer3.new
|
16
|
-
|
17
16
|
trackers = parser.parse(fixture)
|
18
17
|
|
19
18
|
assert_equal 2048, parser.width
|
@@ -13,9 +13,9 @@ class BoujouImportTest < Test::Unit::TestCase
|
|
13
13
|
fixture = File.open(File.dirname(__FILE__) + '/samples/boujou_features_text/boujou_txt_export.txt')
|
14
14
|
|
15
15
|
parser = Tracksperanto::Import::Boujou.new(:width => 2560, :height => 1200)
|
16
|
-
|
17
16
|
trackers = parser.parse(fixture)
|
18
|
-
|
17
|
+
|
18
|
+
assert_equal 21, trackers.length
|
19
19
|
|
20
20
|
tracker1 = trackers[1]
|
21
21
|
|
data/test/test_flame_builder.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracksperanto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 33
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 1.9.
|
9
|
+
- 9
|
10
|
+
version: 1.9.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julik Tarkhanov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-29 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -54,12 +54,12 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
hash:
|
57
|
+
hash: 21
|
58
58
|
segments:
|
59
59
|
- 2
|
60
60
|
- 6
|
61
|
-
-
|
62
|
-
version: 2.6.
|
61
|
+
- 1
|
62
|
+
version: 2.6.1
|
63
63
|
type: :development
|
64
64
|
version_requirements: *id003
|
65
65
|
description: Tracksperanto is a universal 2D-track translator between many apps.
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/tracksperanto/tracker.rb
|
136
136
|
- lib/tracksperanto/uv_coordinates.rb
|
137
137
|
- lib/tracksperanto/zip_tuples.rb
|
138
|
+
- lib/tracksperanto/accumulator.rb
|
138
139
|
- test/export/README_EXPORT_TESTS.txt
|
139
140
|
- test/export/samples/ref_Mayalive.txt
|
140
141
|
- test/export/samples/ref_Mayalive_CustomAspect.txt
|