flame_timewarp_extractor 0.0.1
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/.gemtest +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +9 -0
- data/README.txt +45 -0
- data/Rakefile +11 -0
- data/bin/flametwextract +4 -0
- data/lib/flame_timewarp_extractor.rb +79 -0
- data/test/samples/TW_015_010_v01_Baked.timewarp +12288 -0
- data/test/samples/output.txt +816 -0
- data/test/test_twextract.rb +19 -0
- metadata +95 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
= flametwextract
|
2
|
+
|
3
|
+
* http://github.com/guerilla-di/twextract
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Extract timewarp channels from Flame setup files, for usage in say Maya or Houdini or whathaveyou.
|
8
|
+
|
9
|
+
|
10
|
+
== SYNOPSIS:
|
11
|
+
|
12
|
+
$flametwextract E001_Shot15.timewarp > sh15_tw.txt
|
13
|
+
|
14
|
+
== REQUIREMENTS:
|
15
|
+
|
16
|
+
Ruby > 1.8.5, tracksperanto gem
|
17
|
+
|
18
|
+
== INSTALL:
|
19
|
+
|
20
|
+
sudo gem install flame_timewarp_extractor
|
21
|
+
|
22
|
+
== LICENSE:
|
23
|
+
|
24
|
+
(The MIT License)
|
25
|
+
|
26
|
+
Copyright (c) 2011 me@julik.nl
|
27
|
+
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
29
|
+
a copy of this software and associated documentation files (the
|
30
|
+
'Software'), to deal in the Software without restriction, including
|
31
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
32
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
33
|
+
permit persons to whom the Software is furnished to do so, subject to
|
34
|
+
the following conditions:
|
35
|
+
|
36
|
+
The above copyright notice and this permission notice shall be
|
37
|
+
included in all copies or substantial portions of the Software.
|
38
|
+
|
39
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
40
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
41
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
42
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
43
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
44
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
45
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/flametwextract
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "tracksperanto"
|
3
|
+
|
4
|
+
class FlameTimewarpExtractor
|
5
|
+
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
|
8
|
+
class Output
|
9
|
+
def initialize(io, first_f, last_f)
|
10
|
+
@io, @first, @last = io, first_f, last_f
|
11
|
+
end
|
12
|
+
attr_reader :output_header, :output_tail
|
13
|
+
def write_kf(to_f, from_f)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Import < Tracksperanto::Import::FlameStabilizer
|
18
|
+
def initialize
|
19
|
+
@progress_block = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def channel_is_useful?(name)
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_channels(from_io)
|
27
|
+
extract_channels_from_stream(from_io)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class OutputChan < Output
|
32
|
+
def write_kf(to_f, from_f)
|
33
|
+
@io.puts("%d\t%.5f" % [to_f, from_f])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
CHANNELS = %( Timing/Timing Frame )
|
38
|
+
|
39
|
+
def extract(path)
|
40
|
+
f = File.open(path)
|
41
|
+
channels = Import.new.extract_channels(f)
|
42
|
+
timing_channel = channels.find{|c| CHANNELS.include?(c.name) }
|
43
|
+
raise "No timing channel found in this setup" unless timing_channel
|
44
|
+
|
45
|
+
write_channel(timing_channel)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def write_channel(ch)
|
51
|
+
|
52
|
+
o = OutputChan.new($stdout, ch[0][0], (ch[0][0] + ch.length))
|
53
|
+
o.output_header
|
54
|
+
last_at, last_value = nil, nil
|
55
|
+
ch.each do | at, value |
|
56
|
+
last_at, last_value = lerp(last_at, last_value, at, value) do | interp_at, interp_value |
|
57
|
+
o.write_kf(interp_at, interp_value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
o.output_tail
|
61
|
+
end
|
62
|
+
|
63
|
+
# Do a simple linear interpolxion. The function will yield
|
64
|
+
# the interim X and Y, one tuple per whole value between the set points,
|
65
|
+
# and return the last tuple (so you can return-assign from it in a loop)
|
66
|
+
def lerp(last_x, last_y, x, y) #:yields: interp_x, interp_y
|
67
|
+
if last_x.nil?
|
68
|
+
yield(x, y)
|
69
|
+
else
|
70
|
+
gap_size = x - last_x
|
71
|
+
increment = (y.to_f - last_y) / gap_size.to_f
|
72
|
+
(1..gap_size).each do | index |
|
73
|
+
yield(last_x + index, last_y + (increment * index))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
return [x, y]
|
78
|
+
end
|
79
|
+
end
|