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

inherited, #initialize

Methods included from ConstName

#const_name, included

Methods included from SimpleExport

#just_export

Constructor Details

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

Class Method Details

.desc_and_extensionObject



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

def self.desc_and_extension
  "createNulls.jsx"
end

.human_nameObject



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

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

Instance Method Details

#end_exportObject



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

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

#end_tracker_segmentObject



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

def end_tracker_segment
  @count += 1
end

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



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

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



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

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

#start_tracker_segment(tracker_name) ⇒ Object



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

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