flame_channel_parser 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.1.2 / 2011-29-06
2
+
3
+ * Fixed automatic length detection in setups that do not specify their length
4
+
1
5
  === 2.1.1 / 2011-23-06
2
6
 
3
7
  * Fixed exceptions for for channel not found errors
data/Manifest.txt CHANGED
@@ -29,7 +29,9 @@ test/snaps/RefT_Steadicam_TwoKFs.timewarp
29
29
  test/snaps/RefT_Steadicam_TwoKFs_AnotherSlope.timewarp
30
30
  test/snaps/RefT_Steadicam_TwoKFs_HermiteAtBegin.timewarp
31
31
  test/snaps/TW.timewarp
32
+ test/snaps/TW_015_010_v03.timewarp
32
33
  test/snaps/TW_SingleFrameExtrapolated_from2011.timewarp
34
+ test/snaps/TW_TEST.F_Kronos
33
35
  test/snaps/timewarp_where_interp_fails_at_end.timewarp
34
36
  test/test_channel.rb
35
37
  test/test_cli.rb
data/lib/extractor.rb CHANGED
@@ -46,24 +46,34 @@ class FlameChannelParser::Extractor
46
46
  private
47
47
 
48
48
  DEFAULT_START_FRAME = 1
49
- DEFAULTS = {:destination => $stdout, :start_frame => nil, :end_frame => nil, :channel => DEFAULT_CHANNEL_TO_EXTRACT, :on_curve_limits => false }
49
+ DEFAULTS = {
50
+ :destination => $stdout,
51
+ :start_frame => nil,
52
+ :end_frame => nil,
53
+ :channel => DEFAULT_CHANNEL_TO_EXTRACT,
54
+ :on_curve_limits => false
55
+ }
50
56
 
51
57
  SETUP_END_FRAME_PATTERN = /(MaxFrames|Frames)(\s+)(\d+)/
52
58
  SETUP_START_FRAME_PATTERN = /(MinFrame)(\s+)(\d+)/
53
59
 
60
+ def start_and_end_frame_from_curve_length(interp)
61
+ s, e = interp.first_defined_frame.to_i, interp.last_defined_frame.to_i
62
+ if (!s || !e)
63
+ raise NoKeyframesError, "This channel probably has no animation so there " +
64
+ "is no way to automatically tell how many keyframes it has. " +
65
+ "Please set the start and end frame explicitly."
66
+ elsif s == e
67
+ raise NoKeyframesError, "This channel has only one keyframe " +
68
+ "at frame #{s}and baking it makes no sense."
69
+ end
70
+ [s, e]
71
+ end
72
+
54
73
  def configure_start_and_end_frame(f, options, interpolator)
55
74
  # If the settings specify last and first frame...
56
75
  if options[:on_curve_limits]
57
- options[:start_frame] = interpolator.first_defined_frame.to_i
58
- options[:end_frame] = interpolator.last_defined_frame.to_i
59
- if (!options[:start_frame] || !options[:end_frame])
60
- raise NoKeyframesError, "This channel probably has no animation so there " +
61
- "is no way to automatically tell how many keyframes it has. " +
62
- "Please set the start and end frame explicitly."
63
- elsif options[:end_frame] == options[:start_frame]
64
- raise NoKeyframesError, "This channel has only one keyframe " +
65
- "at frame #{options[:start_frame]}and baking it makes no sense."
66
- end
76
+ options[:start_frame], options[:end_frame] = start_and_end_frame_from_curve_length(interpolator)
67
77
  else # Detect from the setup itself (the default)
68
78
  # First try to detect start and end frames from the known flags
69
79
  f.rewind
@@ -71,6 +81,12 @@ class FlameChannelParser::Extractor
71
81
 
72
82
  options[:start_frame] = options[:start_frame] || detected_start || DEFAULT_START_FRAME
73
83
  options[:end_frame] ||= detected_end
84
+
85
+ # If the setup does not contain that information retry with curve limits
86
+ if !options[:start_frame] || !options[:end_frame]
87
+ options[:on_curve_limits] = true
88
+ configure_start_and_end_frame(f, options, interpolator)
89
+ end
74
90
  end
75
91
  end
76
92
 
@@ -1,5 +1,5 @@
1
1
  module FlameChannelParser
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.2'
3
3
 
4
4
  # Parse a Flame setup into an array of Channel
5
5
  def self.parse(io)
@@ -0,0 +1,132 @@
1
+ TimewarpFileVersion 1.0
2
+ CreationDate Mon May 30 13:20:49 2011
3
+
4
+
5
+ Fields 0
6
+ Frames 476
7
+ Origin 1
8
+ RenderType yes
9
+ SamplingStep 0
10
+ Interpolation 0
11
+ FlowQuality 0
12
+ Animation
13
+ Channel Speed
14
+ Extrapolation constant
15
+ Value 57.2581
16
+ Size 5
17
+ KeyVersion 1
18
+ Key 0
19
+ Frame 1
20
+ Value 57.2581
21
+ Interpolation hermite
22
+ RightAutomaticSlope no
23
+ LeftAutomaticSlope no
24
+ BreakSlope yes
25
+ End
26
+ Key 1
27
+ Frame 383
28
+ Value 62.6375
29
+ Interpolation hermite
30
+ LeftSlope 0.0844935
31
+ RightAutomaticSlope no
32
+ LeftAutomaticSlope no
33
+ BreakSlope yes
34
+ End
35
+ Key 2
36
+ Frame 438
37
+ Value 100
38
+ Interpolation hermite
39
+ LeftSlope -4.07591
40
+ RightAutomaticSlope no
41
+ LeftAutomaticSlope no
42
+ BreakSlope yes
43
+ End
44
+ Key 3
45
+ Frame 476
46
+ Value 218.43
47
+ Interpolation hermite
48
+ LeftSlope -0.0700557
49
+ RightAutomaticSlope no
50
+ LeftAutomaticSlope no
51
+ BreakSlope yes
52
+ End
53
+ Key 4
54
+ Frame 531
55
+ Value 100
56
+ Interpolation hermite
57
+ LeftSlope 0.0611895
58
+ RightAutomaticSlope no
59
+ LeftAutomaticSlope no
60
+ BreakSlope yes
61
+ End
62
+ Uncollapsed
63
+ End
64
+ Channel Timing/Timing
65
+ Extrapolation linear
66
+ Value 174.274
67
+ Size 5
68
+ KeyVersion 1
69
+ Key 0
70
+ Frame 1
71
+ Value 174.274
72
+ Interpolation hermite
73
+ RightSlope 0.572581
74
+ LeftSlope 0.572581
75
+ End
76
+ Key 1
77
+ Frame 383
78
+ Value 393
79
+ Interpolation hermite
80
+ RightSlope 0.626375
81
+ LeftSlope 0.626375
82
+ End
83
+ Key 2
84
+ Frame 438
85
+ Value 448
86
+ Interpolation hermite
87
+ RightSlope 1
88
+ RightAutomaticSlope no
89
+ LeftAutomaticSlope no
90
+ End
91
+ Key 3
92
+ Frame 476
93
+ Value 508.586
94
+ Interpolation hermite
95
+ RightSlope 2.1843
96
+ LeftSlope 2.1843
97
+ RightAutomaticSlope no
98
+ LeftAutomaticSlope no
99
+ End
100
+ Key 4
101
+ Frame 531
102
+ Value 596
103
+ Interpolation hermite
104
+ RightSlope 1
105
+ LeftSlope 1
106
+ RightAutomaticSlope no
107
+ LeftAutomaticSlope no
108
+ End
109
+ Uncollapsed
110
+ End
111
+ Channel Mix/Mix
112
+ Extrapolation constant
113
+ Value 0
114
+ End
115
+ Channel Trail/Pre_Trail
116
+ Extrapolation constant
117
+ Value 1
118
+ End
119
+ Channel Trail/Pre_Weight
120
+ Extrapolation constant
121
+ Value 100
122
+ End
123
+ Channel Trail/Post_Trail
124
+ Extrapolation constant
125
+ Value 1
126
+ End
127
+ Channel Trail/Post_Weight
128
+ Extrapolation constant
129
+ Value 100
130
+ End
131
+ ChannelEnd
132
+ End
@@ -0,0 +1,464 @@
1
+ SparkFileVersion 1
2
+ CreationDate Wed Jan 27 16:14:27 2010
3
+
4
+
5
+ Name /usr/discreet/sparks/Furnace3.1v1/F_Kronos.spark_x86_64.setup
6
+ frameHeight 576
7
+ frameWidth 720
8
+ BeginSetupCtrls
9
+ SPARK_OFF
10
+
11
+ SPARK_OFF
12
+
13
+ SPARK_OFF
14
+
15
+ SPARK_OFF
16
+
17
+ SPARK_OFF
18
+
19
+ SPARK_OFF
20
+
21
+ SPARK_OFF
22
+
23
+ SPARK_OFF
24
+
25
+ SPARK_OFF
26
+
27
+ SPARK_OFF
28
+
29
+ SPARK_OFF
30
+
31
+ SPARK_OFF
32
+
33
+ SPARK_OFF
34
+
35
+ SPARK_OFF
36
+
37
+ SPARK_OFF
38
+
39
+ SPARK_OFF
40
+
41
+ SPARK_OFF
42
+
43
+ SPARK_OFF
44
+
45
+ SPARK_OFF
46
+
47
+ SPARK_OFF
48
+
49
+ SPARK_OFF
50
+
51
+ SPARK_OFF
52
+
53
+ EndSetupCtrls
54
+ SPARK_OFF
55
+
56
+ SPARK_STRING <null>
57
+
58
+ SPARK_STRING <null>
59
+
60
+ SPARK_STRING <null>
61
+
62
+ SPARK_OFF
63
+
64
+ SPARK_STRING <null>
65
+
66
+ SPARK_PUP 1
67
+ SPARK_FLOAT 50
68
+ SPARK_FLOAT 1
69
+ SPARK_CHANNEL 8
70
+ Channel Frame
71
+ Extrapolation constant
72
+ Value 1
73
+ Size 12
74
+ KeyVersion 1
75
+ Key 0
76
+ Frame 1
77
+ Value 1
78
+ Interpolation hermite
79
+ End
80
+ Key 1
81
+ Frame 249
82
+ Value 246.689
83
+ Interpolation hermite
84
+ RightSlope 1.01202
85
+ LeftSlope 1.01202
86
+ End
87
+ Key 2
88
+ Frame 458
89
+ Value 463.492
90
+ Interpolation hermite
91
+ RightSlope 1.20653
92
+ LeftSlope 1.20653
93
+ End
94
+ Key 3
95
+ Frame 553
96
+ Value 613.474
97
+ Interpolation hermite
98
+ RightSlope 1.81252
99
+ LeftSlope 1.81252
100
+ End
101
+ Key 4
102
+ Frame 668
103
+ Value 844.12
104
+ Interpolation hermite
105
+ RightSlope 2.00018
106
+ LeftSlope 2.00018
107
+ End
108
+ Key 5
109
+ Frame 791
110
+ Value 1089.52
111
+ Interpolation hermite
112
+ RightSlope 1.99494
113
+ LeftSlope 1.99494
114
+ End
115
+ Key 6
116
+ Frame 934
117
+ Value 1374.77
118
+ Interpolation hermite
119
+ RightSlope 2.15338
120
+ LeftSlope 2.15338
121
+ End
122
+ Key 7
123
+ Frame 1115
124
+ Value 1787.21
125
+ Interpolation hermite
126
+ RightSlope 2.61713
127
+ LeftSlope 2.61713
128
+ End
129
+ Key 8
130
+ Frame 1296
131
+ Value 2322.17
132
+ Interpolation hermite
133
+ RightSlope 3.11868
134
+ LeftSlope 3.11868
135
+ End
136
+ Key 9
137
+ Frame 1544
138
+ Value 3125.12
139
+ Interpolation hermite
140
+ RightSlope 2.22471
141
+ LeftSlope 2.22471
142
+ End
143
+ Key 10
144
+ Frame 2001
145
+ Value 3890.6
146
+ Interpolation hermite
147
+ RightSlope 0.542499
148
+ LeftSlope 0.542499
149
+ End
150
+ Key 11
151
+ Frame 5000
152
+ Value 5000
153
+ Interpolation hermite
154
+ End
155
+ Uncollapsed
156
+ End
157
+ SPARK_FLOAT 20
158
+ SPARK_FLOAT 500
159
+ SPARK_FLOAT 500
160
+ SPARK_INT 5
161
+ SPARK_PUP 0
162
+ SPARK_BOOL 0
163
+ SPARK_BOOL 0
164
+ SPARK_BOOL 0
165
+ SPARK_FLOAT 1
166
+ SPARK_INT 6
167
+ SPARK_PUP 1
168
+ SPARK_FLOAT 0
169
+ SPARK_INT 1
170
+ SPARK_BOOL 0
171
+ SPARK_OFF
172
+
173
+ SPARK_OFF
174
+
175
+ SPARK_PUP 0
176
+ SPARK_PUP 0
177
+ SPARK_FLOAT 29.89
178
+ SPARK_FLOAT 58.66
179
+ SPARK_FLOAT 11.44
180
+ SPARK_OFF
181
+
182
+ SPARK_OFF
183
+
184
+ SPARK_PUP 2
185
+ SPARK_PUP 0
186
+ SPARK_PUP 3
187
+ SPARK_FLOAT 0
188
+ SPARK_FLOAT 100
189
+ SPARK_FLOAT 100
190
+ SPARK_FLOAT 0
191
+ SPARK_OFF
192
+
193
+ SPARK_OFF
194
+
195
+ SPARK_OFF
196
+
197
+ SPARK_FLOAT 0
198
+ SPARK_FLOAT 100
199
+ SPARK_FLOAT 100
200
+ SPARK_FLOAT 0
201
+ SPARK_OFF
202
+
203
+ SPARK_OFF
204
+
205
+ SPARK_OFF
206
+
207
+ SPARK_FLOAT 0
208
+ SPARK_FLOAT 100
209
+ SPARK_FLOAT 100
210
+ SPARK_FLOAT 0
211
+ SPARK_OFF
212
+
213
+ SPARK_OFF
214
+
215
+ SPARK_OFF
216
+
217
+ SPARK_OFF
218
+
219
+ SPARK_OFF
220
+
221
+ SPARK_OFF
222
+
223
+ SPARK_OFF
224
+
225
+ SPARK_OFF
226
+
227
+ SPARK_OFF
228
+
229
+ SPARK_PUP 0
230
+ SPARK_PUP 3
231
+ SPARK_PUP 1
232
+ SPARK_OFF
233
+
234
+ SPARK_INT 5000
235
+ SPARK_INT 1
236
+ SPARK_OFF
237
+
238
+ SPARK_OFF
239
+
240
+ SPARK_OFF
241
+
242
+ SPARK_OFF
243
+
244
+ SPARK_OFF
245
+
246
+ SPARK_OFF
247
+
248
+ SPARK_OFF
249
+
250
+ SPARK_OFF
251
+
252
+ SPARK_OFF
253
+
254
+ SPARK_OFF
255
+
256
+ SPARK_OFF
257
+
258
+ SPARK_OFF
259
+
260
+ SPARK_OFF
261
+
262
+ SPARK_OFF
263
+
264
+ SPARK_OFF
265
+
266
+ SPARK_OFF
267
+
268
+ SPARK_OFF
269
+
270
+ SPARK_OFF
271
+
272
+ SPARK_OFF
273
+
274
+ SPARK_OFF
275
+
276
+ SPARK_OFF
277
+
278
+ SPARK_OFF
279
+
280
+ SPARK_OFF
281
+
282
+ SPARK_PUP 0
283
+ SPARK_PUP 3
284
+ SPARK_OFF
285
+
286
+ SPARK_OFF
287
+
288
+ SPARK_OFF
289
+
290
+ SPARK_OFF
291
+
292
+ SPARK_OFF
293
+
294
+ SPARK_OFF
295
+
296
+ SPARK_OFF
297
+
298
+ SPARK_OFF
299
+
300
+ SPARK_OFF
301
+
302
+ SPARK_OFF
303
+
304
+ SPARK_OFF
305
+
306
+ SPARK_OFF
307
+
308
+ SPARK_OFF
309
+
310
+ SPARK_OFF
311
+
312
+ SPARK_OFF
313
+
314
+ SPARK_OFF
315
+
316
+ SPARK_OFF
317
+
318
+ SPARK_OFF
319
+
320
+ SPARK_OFF
321
+
322
+ SPARK_OFF
323
+
324
+ SPARK_OFF
325
+
326
+ SPARK_OFF
327
+
328
+ SPARK_OFF
329
+
330
+ SPARK_OFF
331
+
332
+ SPARK_OFF
333
+
334
+ SPARK_OFF
335
+
336
+ SPARK_OFF
337
+
338
+ SPARK_OFF
339
+
340
+ SPARK_OFF
341
+
342
+ SPARK_OFF
343
+ SPARK_OFF
344
+ SPARK_OFF
345
+ SPARK_OFF
346
+ SPARK_OFF
347
+ SPARK_OFF
348
+ SPARK_CE_FLOAT 0
349
+ SPARK_CE_FLOAT 0
350
+ SPARK_CE_FLOAT 0
351
+ SPARK_CE_FLOAT 0
352
+ SPARK_CE_FLOAT 0
353
+ SPARK_CE_FLOAT 0
354
+ SPARK_CE_FLOAT 0
355
+ SPARK_CE_FLOAT 0
356
+ SPARK_CE_FLOAT 0
357
+ SPARK_OFF
358
+ SPARK_OFF
359
+ SPARK_OFF
360
+ SPARK_CE_INT 1
361
+ SPARK_OFF
362
+ SPARK_OFF
363
+ SPARK_OFF
364
+ SPARK_OFF
365
+ SPARK_OFF
366
+ SPARK_OFF
367
+ SPARK_OFF
368
+ SPARK_OFF
369
+ SPARK_OFF
370
+ SPARK_OFF
371
+ SPARK_OFF
372
+ SPARK_OFF
373
+ SPARK_OFF
374
+ SPARK_OFF
375
+ SPARK_OFF
376
+ SPARK_OFF
377
+ SPARK_OFF
378
+ SPARK_OFF
379
+ SPARK_OFF
380
+ SPARK_OFF
381
+ SPARK_OFF
382
+ SPARK_OFF
383
+ SPARK_OFF
384
+ SPARK_OFF
385
+ SPARK_OFF
386
+ SPARK_OFF
387
+ SPARK_OFF
388
+ SPARK_OFF
389
+ SPARK_OFF
390
+ SPARK_OFF
391
+ SPARK_OFF
392
+ SPARK_OFF
393
+ SPARK_OFF
394
+ SPARK_OFF
395
+ SPARK_OFF
396
+ SPARK_OFF
397
+ SPARK_OFF
398
+ SPARK_OFF
399
+ SPARK_OFF
400
+ SPARK_OFF
401
+ SPARK_OFF
402
+ SPARK_OFF
403
+ SPARK_OFF
404
+ SPARK_OFF
405
+ SPARK_OFF
406
+ SPARK_OFF
407
+ SPARK_OFF
408
+ SPARK_OFF
409
+ SPARK_OFF
410
+ SPARK_OFF
411
+ SPARK_OFF
412
+ SPARK_OFF
413
+ SPARK_OFF
414
+ SPARK_OFF
415
+ SPARK_OFF
416
+ SPARK_OFF
417
+ SPARK_OFF
418
+ SPARK_OFF
419
+ SPARK_OFF
420
+ SPARK_OFF
421
+ SPARK_OFF
422
+ SPARK_OFF
423
+ SPARK_OFF
424
+ SPARK_OFF
425
+ SPARK_OFF
426
+ SPARK_OFF
427
+ SPARK_OFF
428
+ SPARK_OFF
429
+ SPARK_OFF
430
+ SPARK_OFF
431
+ SPARK_OFF
432
+ SPARK_OFF
433
+ SPARK_OFF
434
+ SPARK_OFF
435
+ SPARK_OFF
436
+ SPARK_OFF
437
+ SPARK_OFF
438
+ SPARK_OFF
439
+ SPARK_OFF
440
+ SPARK_OFF
441
+ SPARK_OFF
442
+ SPARK_OFF
443
+ SPARK_OFF
444
+ SPARK_OFF
445
+ SPARK_OFF
446
+ SPARK_OFF
447
+ SPARK_OFF
448
+ SPARK_OFF
449
+ SPARK_OFF
450
+ SPARK_OFF
451
+ SPARK_OFF
452
+ SPARK_OFF
453
+ SPARK_OFF
454
+ SPARK_OFF
455
+ SPARK_OFF
456
+ SPARK_OFF
457
+ SPARK_OFF
458
+ SPARK_OFF
459
+ SPARK_OFF
460
+ SPARK_OFF
461
+ SPARK_OFF
462
+ SPARK_OFF
463
+ SPARK_OFF
464
+ End
@@ -67,4 +67,10 @@ class TestExtractor < Test::Unit::TestCase
67
67
  end
68
68
  end
69
69
 
70
+ def test_properly_uses_channel_length_for_range_detection_when_setup_length_is_not_give
71
+ io = StringIO.new
72
+ o = {:destination => io , :channel => "Frame"}
73
+ FlameChannelParser::Extractor.extract(File.dirname(__FILE__) + "/snaps/TW_TEST.F_Kronos", o)
74
+ assert_equal 5000, io.string.split("\n").length, "Should have parsed out 5000 frames"
75
+ end
70
76
  end
@@ -12,6 +12,13 @@ class TestFlameChannelParser < Test::Unit::TestCase
12
12
  assert_equal 816, chan[-1].frame
13
13
  end
14
14
 
15
+ def test_parsing_kronos_setup
16
+ data = File.open(File.dirname(__FILE__) + "/snaps/TW_TEST.F_Kronos")
17
+ chans = FlameChannelParser.parse(data)
18
+ assert_equal "Frame", chans[0].path
19
+ assert_equal 12, chans[0].length
20
+ end
21
+
15
22
  def test_parsing
16
23
  data = File.open(File.dirname(__FILE__) + "/sample_channel.dat")
17
24
  channels = FlameChannelParser.parse(data)
@@ -95,6 +95,12 @@ class TestInterpolator < Test::Unit::TestCase
95
95
  assert_same_interpolation(-10..300, reference, sampled)
96
96
  end
97
97
 
98
+ def test_kronos_tw
99
+ data = File.open(File.dirname(__FILE__) + "/snaps/TW_TEST.F_Kronos")
100
+ frame_chan = FlameChannelParser.parse(data)[0]
101
+ assert_in_delta DELTA, 5000.0, frame_chan.to_interpolator.sample_at(5001)
102
+ end
103
+
98
104
  def test_tw_with_constant
99
105
  data = File.open(File.dirname(__FILE__) + "/snaps/TW_SingleFrameExtrapolated_from2011.timewarp")
100
106
  channels_in_tw = FlameChannelParser.parse(data)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: flame_channel_parser
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.1
5
+ version: 2.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julik Tarkhanov
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-24 00:00:00 Z
13
+ date: 2011-06-29 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: update_hints
@@ -90,7 +90,9 @@ files:
90
90
  - test/snaps/RefT_Steadicam_TwoKFs_AnotherSlope.timewarp
91
91
  - test/snaps/RefT_Steadicam_TwoKFs_HermiteAtBegin.timewarp
92
92
  - test/snaps/TW.timewarp
93
+ - test/snaps/TW_015_010_v03.timewarp
93
94
  - test/snaps/TW_SingleFrameExtrapolated_from2011.timewarp
95
+ - test/snaps/TW_TEST.F_Kronos
94
96
  - test/snaps/timewarp_where_interp_fails_at_end.timewarp
95
97
  - test/test_channel.rb
96
98
  - test/test_cli.rb