Module: Bayonetta::KeyFrameInterpolate
- Included in:
- MOT2File::Interpolation4, MOT2File::Interpolation5, MOT2File::Interpolation6, MOT2File::Interpolation7, MOT2File::Interpolation8, MOTFile::Interpolation4, MOTFile::Interpolation6, MOTFile::Interpolation7
- Defined in:
- lib/bayonetta/mot.rb
Instance Method Summary collapse
- #interpol(frame, start_index, stop_index, i) ⇒ Object
- #value(frame_index) ⇒ Object
- #values(frame_count) ⇒ Object
Instance Method Details
permalink #interpol(frame, start_index, stop_index, i) ⇒ Object
[View source]
94 95 96 97 98 99 100 101 |
# File 'lib/bayonetta/mot.rb', line 94 def interpol(frame, start_index, stop_index, i) p_0 = get_p(i) p_1 = get_p(i+1) m_0 = get_m1(i) m_1 = get_m0(i+1) t = (frame - start_index).to_f / (stop_index - start_index) (2 * t*t*t - 3 * t*t + 1)*p_0 + (t*t*t - 2 * t*t + t)*m_0 + (-2 * t*t*t + 3 * t*t)*p_1 + (t*t*t - t * t)*m_1 end |
permalink #value(frame_index) ⇒ Object
[View source]
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/bayonetta/mot.rb', line 120 def value(frame_index) kfis = key_frame_indexes if frame_index <= kfis.first return get_p(0) elsif frame_index >= kfis.last return get_p(kfis.length - 1) else kfis.each_cons(2).each_with_index { |(start_index, stop_index), i| if frame_index <= stop_index && frame_index >= start_index return interpol(frame_index, start_index, stop_index, i) end } end end |
permalink #values(frame_count) ⇒ Object
[View source]
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/bayonetta/mot.rb', line 103 def values(frame_count) vs = [0.0]*frame_count kfis = key_frame_indexes kfis.each_cons(2).each_with_index { |(start_index, stop_index), i| (start_index..stop_index).each { |frame| vs[frame] = interpol(frame, start_index, stop_index, i) } } (0...kfis.first).each { |i| vs[i] = vs[kfis.first] } ((kfis.last+1)...frame_count).each { |i| vs[i] = vs[kfis.last] } vs end |