flame_timewarp_extractor 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.0.0 / 2011-05-17
2
+
3
+ * Chang the main method to accept an options hash
4
+
1
5
  === 1.1.0 / 2011-05-17
2
6
 
3
7
  * Update the dependency version
data/Manifest.txt CHANGED
@@ -1,9 +1,14 @@
1
+ .autotest
1
2
  History.txt
2
3
  Manifest.txt
3
4
  README.rdoc
4
5
  Rakefile
5
6
  bin/flametwextract
6
7
  lib/flame_timewarp_extractor.rb
8
+ test/.DS_Store
7
9
  test/samples/TW_015_010_v01_Baked.timewarp
10
+ test/samples/TW_016_010_v01.timewarp
11
+ test/samples/TW_016_010_v01_Baked.timewarp
12
+ test/samples/my_output.framecurve.txt
8
13
  test/samples/output.txt
9
14
  test/test_twextract.rb
@@ -3,29 +3,33 @@ require "flame_channel_parser"
3
3
 
4
4
  class FlameTimewarpExtractor
5
5
 
6
- VERSION = "1.1.0"
6
+ VERSION = "2.0.0"
7
7
 
8
8
  CHANNELS = %( Timing/Timing Frame )
9
9
 
10
+ DEFAULTS = {:destination => $stdout, :start_frame => 1, :end_frame => :auto }
11
+
10
12
  # Pass the path to the Kronos or Timewarp setup here and you will get the timewarp curve on STDOUT
11
- def extract(path, to_io = $stdout)
13
+ def extract(path, options = {})
14
+ options = DEFAULTS.merge(options)
12
15
  File.open(path) do | f |
13
16
  channels = FlameChannelParser.parse(f)
14
17
 
15
18
  timing_channel = channels.find{|c| CHANNELS.include?(c.name) }
16
19
  raise "No timing channel found in this setup" unless timing_channel
17
20
 
18
- write_channel(timing_channel, to_io)
21
+ write_channel(timing_channel, options[:destination], options[:start_frame], options[:end_frame])
19
22
  end
20
23
  end
21
24
 
22
25
  private
23
26
 
24
- def write_channel(channel, to_io)
27
+ def write_channel(channel, to_io, start_frame, end_frame)
25
28
  interpolator = FlameChannelParser::Interpolator.new(channel)
26
29
 
27
- from_frame = interpolator.first_defined_frame
28
- to_frame = interpolator.last_defined_frame
30
+
31
+ from_frame = (start_frame == :auto) ? interpolator.first_defined_frame : start_frame
32
+ to_frame = (end_frame == :auto) ? interpolator.last_defined_frame : interpolator.last_defined_frame
29
33
 
30
34
  (from_frame..to_frame).each do | frame |
31
35
  to_io.puts("%d\t%.5f" % [frame, interpolator.sample_at(frame)])
data/test/.DS_Store ADDED
Binary file
@@ -0,0 +1,134 @@
1
+ TimewarpFileVersion 1.0
2
+ CreationDate Fri Apr 22 16:37:34 2011
3
+
4
+
5
+ Fields 0
6
+ Frames 428
7
+ Origin 1
8
+ RenderType no
9
+ SamplingStep 0
10
+ Interpolation 0
11
+ FlowQuality 2
12
+ Animation
13
+ Channel Speed
14
+ Extrapolation constant
15
+ Value 100
16
+ Size 5
17
+ KeyVersion 1
18
+ Key 0
19
+ Frame 1
20
+ Value 100
21
+ Interpolation hermite
22
+ RightAutomaticSlope no
23
+ LeftAutomaticSlope no
24
+ BreakSlope yes
25
+ End
26
+ Key 1
27
+ Frame 160
28
+ Value 100
29
+ Interpolation hermite
30
+ RightAutomaticSlope no
31
+ LeftAutomaticSlope no
32
+ BreakSlope yes
33
+ End
34
+ Key 2
35
+ Frame 179
36
+ Value 211.478
37
+ Interpolation hermite
38
+ RightSlope 0.558946
39
+ LeftSlope 0.558946
40
+ End
41
+ Key 3
42
+ Frame 197
43
+ Value 120.681
44
+ Interpolation hermite
45
+ RightSlope -3.04349
46
+ LeftSlope -4.12211
47
+ RightAutomaticSlope no
48
+ LeftAutomaticSlope no
49
+ BreakSlope yes
50
+ End
51
+ Key 4
52
+ Frame 215
53
+ Value 100
54
+ Interpolation hermite
55
+ LeftSlope 0.382772
56
+ RightAutomaticSlope no
57
+ LeftAutomaticSlope no
58
+ BreakSlope yes
59
+ End
60
+ Uncollapsed
61
+ End
62
+ Channel Timing/Timing
63
+ Extrapolation linear
64
+ Value 148
65
+ Size 5
66
+ KeyVersion 1
67
+ Key 0
68
+ Frame 1
69
+ Value 1
70
+ Interpolation hermite
71
+ RightSlope 1
72
+ RightAutomaticSlope no
73
+ LeftAutomaticSlope no
74
+ End
75
+ Key 1
76
+ Frame 160
77
+ Value 160
78
+ Interpolation hermite
79
+ RightSlope 1
80
+ LeftSlope 1
81
+ RightAutomaticSlope no
82
+ LeftAutomaticSlope no
83
+ End
84
+ Key 2
85
+ Frame 179
86
+ Value 189.422
87
+ Interpolation hermite
88
+ RightSlope 2.11478
89
+ LeftSlope 2.11478
90
+ RightAutomaticSlope no
91
+ LeftAutomaticSlope no
92
+ End
93
+ Key 3
94
+ Frame 197
95
+ Value 220.58
96
+ Interpolation hermite
97
+ RightSlope 1.20681
98
+ LeftSlope 1.20681
99
+ RightAutomaticSlope no
100
+ LeftAutomaticSlope no
101
+ End
102
+ Key 4
103
+ Frame 215
104
+ Value 239.517
105
+ Interpolation hermite
106
+ RightSlope 1
107
+ LeftSlope 1
108
+ RightAutomaticSlope no
109
+ LeftAutomaticSlope no
110
+ End
111
+ Uncollapsed
112
+ End
113
+ Channel Mix/Mix
114
+ Extrapolation constant
115
+ Value 0
116
+ End
117
+ Channel Trail/Pre_Trail
118
+ Extrapolation constant
119
+ Value 1
120
+ End
121
+ Channel Trail/Pre_Weight
122
+ Extrapolation constant
123
+ Value 100
124
+ End
125
+ Channel Trail/Post_Trail
126
+ Extrapolation constant
127
+ Value 1
128
+ End
129
+ Channel Trail/Post_Weight
130
+ Extrapolation constant
131
+ Value 100
132
+ End
133
+ ChannelEnd
134
+ End