Class: Tracksperanto::Tool::Lerp
Overview
This tool adds linearly interpolated keyframes BETWEEN the keyframes passing through the exporter
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Methods included from Parameters
Methods included from SimpleExport
Methods included from ConstName
Methods included from BlockInit
Methods included from Casts
#cast_to_bool, #cast_to_float, #cast_to_int, #cast_to_string
Constructor Details
This class inherits a constructor from Tracksperanto::Tool::Base
Class Method Details
.action_description ⇒ Object
4 5 6 |
# File 'lib/tools/lerp.rb', line 4 def self.action_description "Interpolate missing keyframes of all the trackers" end |
Instance Method Details
#end_tracker_segment ⇒ Object
8 9 10 11 |
# File 'lib/tools/lerp.rb', line 8 def end_tracker_segment @last_f, @last_x, @last_y, @last_res = nil, nil, nil, nil super end |
#export_point(frame, float_x, float_y, float_residual) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tools/lerp.rb', line 13 def export_point(frame, float_x, float_y, float_residual) if @last_f && (frame - @last_f > 1) # Interpolate! interpolated_frames = [] interpolated_x = [] lerp(@last_f, @last_x, frame, float_x) do | interp_f, interp_x | interpolated_frames << interp_f interpolated_x << interp_x end interpolated_y = [] lerp(@last_f, @last_y, frame, float_y) do | interp_f, interp_y | interpolated_y << interp_y end interpolated_res = [] lerp(@last_f, @last_res, frame, float_residual) do | interp_f, interp_res | interpolated_res << interp_res end tuples = interpolated_frames.zip(interpolated_x).zip(interpolated_y).zip(interpolated_res).map{|e| e.flatten } tuples.each do | f, x, y, r | super(f.to_i, x, y, r) end else super(frame, float_x + (@x_shift || 0), float_y + (@y_shift || 0), float_residual) end @last_f, @last_x, @last_y, @last_res = frame, float_x, float_y, float_residual end |