Class: Tracksperanto::Export::AE

Inherits:
Base
  • Object
show all
Defined in:
lib/export/cosa.rb

Overview

Exports trackers as an AfterEffects script creating nulls

Constant Summary collapse

PREAMBLE =
'// Run this script from the Script Editor
function convertFrameToSeconds(layerWithFootage, frameValue)
{
    var comp = layerWithFootage.containingComp;
    var rate = 1.0 / comp.frameDuration;
    // Frames in AE are 0-based by default
    return (frameValue) / rate;
}

var activeComp = app.project.activeItem;
if(!activeComp) {
    // Totally fail
    alert("You need to be focused on a comp for the tracker creation to work");
} else {'

Instance Attribute Summary

Attributes inherited from Base

#io

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from ConstName

#const_name

Methods included from SimpleExport

#just_export

Constructor Details

This class inherits a constructor from Tracksperanto::Export::Base

Class Method Details

.desc_and_extensionObject



19
20
21
# File 'lib/export/cosa.rb', line 19

def self.desc_and_extension
  "createNulls.jsx"
end

.human_nameObject



23
24
25
# File 'lib/export/cosa.rb', line 23

def self.human_name
  "AfterEffects .jsx script generating null layers"
end

Instance Method Details

#end_exportObject



50
51
52
# File 'lib/export/cosa.rb', line 50

def end_export
  @io.puts('}') # Finishes the export clause
end

#end_tracker_segmentObject



46
47
48
# File 'lib/export/cosa.rb', line 46

def end_tracker_segment
  @count += 1
end

#export_point(frame, abs_float_x, abs_float_y, float_residual) ⇒ Object



42
43
44
# File 'lib/export/cosa.rb', line 42

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  @io.puts('pos.setValueAtTime(convertFrameToSeconds(layer%d, %d), [%0.5f,%0.5f]);' % [@count, frame, abs_float_x, @height - abs_float_y])
end

#start_export(w, h) ⇒ Object



27
28
29
30
31
32
# File 'lib/export/cosa.rb', line 27

def start_export(w, h)
  @io.puts(PREAMBLE)
  @io.puts("")
  @count = 0
  @height = h
end

#start_tracker_segment(tracker_name) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/export/cosa.rb', line 34

def start_tracker_segment(tracker_name)
  @io.puts("")
  @io.puts('var layer%d = activeComp.layers.addNull();' % @count)
  @io.puts( 'layer%d.name = %s;' % [@count, tracker_name.inspect])
  @io.puts("")
  @io.puts('var pos = layer%d.property("Transform").property("Position");' % @count)
end