Class: Tracksperanto::Export::XSI

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

Overview

Export each tracker as a moving Softimage|XSI null

Constant Summary collapse

IMAGE_PLANE =
'Application.CreatePrim("Grid", "MeshSurface", "", "")
Application.SetValue("grid.Name", "ImagePlane", "")
Application.SetValue("ImagePlane.grid.ulength", %0.5f, "")
Application.SetValue("ImagePlane.grid.vlength", %0.5f, "")
Application.Rotate("", 90, 0, 0, "siRelative", "siLocal", "siObj", "siXYZ", "", "", "", "", "", "", "", 0, "")'
MULTIPLIER =
10.0

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


12
13
14
# File 'lib/export/xsi.rb', line 12

def self.desc_and_extension
  "xsi_nulls.py"
end

.human_nameObject


16
17
18
# File 'lib/export/xsi.rb', line 16

def self.human_name
  "Autodesk Softimage nulls Python script"
end

Instance Method Details

#end_exportObject


51
52
53
54
55
56
57
58
59
60
# File 'lib/export/xsi.rb', line 51

def end_export
  # Create a Model group and parent all the trackers and the image plane to it
  @io.puts('Application.DeselectAll()')
  @io.puts('Application.AddToSelection("ImagePlane", "", "")')
  @tracker_names.each do | tracker_name |
    @io.puts('Application.AddToSelection("%s", "", "")' % tracker_name)
  end
  @io.puts('Application.CreateModel("", "", "", "")')
  @io.puts('Application.SetValue("Model.Name", "Tracksperanto", "")')
end

#end_tracker_segmentObject


40
41
42
43
# File 'lib/export/xsi.rb', line 40

def end_tracker_segment
  # Parent the null to the image plane
  @tracker_names.push(@t)
end

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


45
46
47
48
49
# File 'lib/export/xsi.rb', line 45

def export_point(frame, abs_float_x, abs_float_y, float_residual)
  coords = get_coordinates(abs_float_x, abs_float_y)
  @io.puts('Application.Translate("", %0.5f, %0.5f, 0, "siAbsolute", "siView", "siObj", "siXYZ", "", "", "", "", "", "", "", "", "", 0, "")'% coords)
  @io.puts('Application.SaveKeyOnKeyable("%s", %d, "", "", "", False, "")' % [@t, frame + 1])
end

#start_export(w, h) ⇒ Object


20
21
22
23
24
25
26
27
28
# File 'lib/export/xsi.rb', line 20

def start_export(w, h)
  # Pixel sizes are HUGE. Hence we downscale
  @factor = (1 / w.to_f) * MULTIPLIER
  @true_width, @true_height = w * @factor, h * @factor
  
  # Generate a Grid primitive
  @io.puts(IMAGE_PLANE % [@true_width, @true_height])
  @tracker_names = []
end

#start_tracker_segment(tracker_name) ⇒ Object


30
31
32
33
34
35
36
37
38
# File 'lib/export/xsi.rb', line 30

def start_tracker_segment(tracker_name)
  @t = tracker_name
  @io.puts("# Data for tracker %s" % @t)
  @io.puts 'Application.GetPrim("Null", "", "", "")'
  @io.puts('Application.SetValue("null.Name", "%s", "")' % @t)
  # Application.ToggleSelection("Track_Point_02", "", "")
  # Select the tracker that we will animate
  @io.puts('Application.SelectObj("%s", "", True)' % @t)
end