Collada plugin for
After Effects

More info here
Plugins and Scripts > trueSpace

Techniques

trueSpace Blog

Collection of notes for use and development on trueSpace

Clintons3dPlugin package for trueSpace

This rsx plugin is used by several scripts from this site. It is used in the unreal scripts to read the binary formats and in the indigo script making it possible to read scene level materials. Several scripts now use the Save-As dialog from this package.

The source code for the plugin can be downloaded from here.
ExamplesPlugin.TopologyExample2 = ImportPSK
ExamplesPlugin.TopologyExample4 = ImportPSA
ExamplesPlugin.TopologyExample5 = import collada
ExamplesPlugin.HelloWorld2 = ExportPSK
ExamplesPlugin.HelloWorld3 = ExportPSA
ExampleDataObject2 = guid for scene materials
ExampleDataObject3 = save as dialog
ExampleDataObject4 = triangle neighbors/polygon functions
RnConnectorExample2-9 & A-P - compositing nodes
UtilityDataObject - node connector info, select file folder dialog, save as dialog, set active material, guid for scene materials, point visualization, keyframe data info

Be warned that much of the source code is very rough. I never fully figured out how to use the beta sdk, so it's a messy collection of code that works. Also the source is a little bloated from extra libraries and experimentation.

polygon to triangles using Newells Method

feed it a list of vertices space delimited "x1 y1 z1 x2 y2 z2 ..."

get back triangle data "#triangles,i1 j1 k1,i2 j2 k2, ..."

polypoints = "-0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5"
utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
value = utilitydata.PolygonToTriangles(polypoints);
valArr = value.split(",");
for(var i = 0; i < valArr[0]*1; i++) {
	localindices = valArr[i+1].split(" ");

a little sloppy trailing space and comma in each triangle definition
value is "2,0 1 2 ,0 2 3 ,"

triangle neighbors

triangle neighbors diagram
//get triangle neighbors as a space delimited string of triangle indices
utilityFunctions = System.CreateDO("Clintons3D Package/Utility functions");
triangleIndex = 19;
neighborsS = utilityFunctions.GetTriangleNeighbors(firstSelected + "/Editable shape", triangleIndex);

result is "5 20 16", a space delimited list of neighbor indices at each edge of the triangle, -1 indicates no neighbor on that edge

the first value is the triangle index along the edge P1>P2, then P2>P3 and finally P3>P1

triangle edge visibility

meshdata = System.CreateDO("Space 3D Package/Mesh Data");
faceEdgeStream = System.CreateDO('Space 3D Package/Face Edges Stream Data');
meshdata = Node.Value(Node.FirstSelected() + "/Editable shape" ,"Mesh");
faceEdgeStream = meshdata.GetTrianglesStreamByName("Face Edges Stream Data");
triangleIndex = 19;
triangleEdgesS = faceEdgeStream.edges(triangleIndex);

result is the value of 1 to show that the first edge of the triangle is visible. if the second edge was also visible the value would be 1+2=3 and if the third edge was also visible it would be 1+2+4=7

truespace does not store polygon information. it stores triangle edge visibility to give the appearance and behavior of polygons

June 21, 2018

  • flipped the horizontal orientation for the procedural textures
  • new file dialog
  • plugin version v.1638412

May 22, 2018

  • render engine hooks for renderman, indigo and yafaray
  • added procedural texture generation
  • updated the folder dialog
  • version v.1638411

May 31, 2017

  • improved triangle neighbors function
  • polygons to triangles function
  • version v.1638408

April 8, 2017

  • keyframe data returns empty object if nothing found or no keys after time
  • version v.1638407

May 29 2016

  • version v.1638406
  • speed increase for some compositing nodes
  • started sane naming for compositing node files

August 17, 2015

  • fix save as dialog for reliability and compatibility with windows 10

April 8 2015: read keyframe data

April 17 2014: point visualization code, source code not up to date

March 23 2014:

  • added a version of the psk importer that produces standard skeletons
  • mongoose webserver code for ui experimentation
  • simple uv unwrap code
  • version 1638405 - April 6 2014

Note: may require VC++ runtime 2008 sp1 from Microsoft. (2010) Get it if the plugin does not install.

November 22, 2009

Clintons3dView Plugin package for trueSpace

This rsx plugin is used by the web based ui scripts and the node list view script.

The source code for the plugin can be downloaded from here.

January 19, 2018

version v.1638406

September 8 2016

  • version v.1638403

Note: may require VC++ runtime 2008 sp1 from Microsoft. (2010) Get it if the plugin does not install.

xxx xx, xxxx
height node

Height field node

point cloud test

A fast version of the Caligari Image Cloud script created by Norm Fortier and based on the SDK height field sample code.

Connectors:

  • Bitmap - texture image for the mesh faces if they are visible
  • Height field - texture to control the height and color of the points
  • Height segments - vertical resolution of the mesh
  • Method - how the height is generated
    • 0 - average value of the red, blue and green of the pixel
    • 1 - use the blue value
    • 2 - use the green value
    • 3 - use the red value
    • 4 - intensity/luminance (0.3*red + 0.59*green + 0.11*blue)
    • 5 - use the alpha value of the image
  • Multiplier - scale for the displacement values
  • Point alpha - if checked the transparency value of the points is determined by the alpha channel of the image
  • Point size - how large the points are
  • Surface Opacity - how opacity of the mesh faces, 0=invisible
  • Width segments - the horizontal resolution of the mesh

The plugin package is required to use this script. Download the plugin package here.

A bare bones height field node can be created by running a command:
Node.Create('Clintons3D Package/Height field',Space.CurrentScene());

April 17, 2014
material matching

Object scene material guid reader

This script demonstrates how to get the guid for object scene materials which are not available to scripting. Each material inside the scene's material node has a unique id assigned to it that can be read by script. The corresponding id is found inside the meshes "Material List" node. On the node connected to the "Material List Manager". Pass this node to the plugin to get it's id and match it against the "Material Flavor Manager's" "Material ID" connector value.

Select the node connected to the Material List Manager and push the button for the script to display the id in the list view.

By the way the "Material ID" connector on the "Material Flavor Manager" is hidden and can't be seen on the node even though it can be read via script.

The plugin package is required to use this script. Download the plugin package here.

November 22, 2009

Speech for trueSpace

This script demonstrates the use of the Microsoft Speech API using a jscript command node.

Voices:

  • winXP - Sam
  • Win7 - Anna
  • Win10 - David and Zira
August 14, 2015

Dump Buttons XML script

This script writes data from all buttons defined in truespace toolbars. It can be imported the a jscript command node. Output results from trueSpace 7.11 and 7.61(patched) links are below. The 7.11 dump includes the modelside button information.

trueSpace7.11 button dump

trueSpace7.61 button dump

December 19, 2015

Save-As Dialog for trueSpace

This script demonstrates the use of a Save-As dialog for scripts.

The plugin package is required to use this script. Download the plugin package here.

Code:

filedata = System.CreateDO('Clintons3d Package/File Save As data');
filedata.SetName("My special (*.bob)~*.BOB~Collada Files (*.dae)~*.DAE~All Files (*.*)~*.*~~");
file = filedata.GetName();

System.Alert(file);

uses "~" as a delimiter between the description and the extension and end the string with 2 ~'s

November 22, 2009

Save As Dialog (v2) for trueSpace

The plugin package is required. Download the plugin package here.

Sample Code:

var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = "some preexisting filename";
folder = fso.GetParentFolderName(filename);
filename = fso.GetFileName(filename);
var defExt = "tga";
var filter = "TGA (*.tga)~*.tga~EXR (*.exr)~*.exr~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var file = util.FileSaveAsDialog2(folder, filename, filter, defExt);

  • folder - can be blank
  • filename - full path or just file name
  • filter - first item is the default extension shown
  • defExt - can be blank, used if user does not enter an extension
June 21, 2018

Folder Dialog for trueSpace

The plugin package is required to use this script. Download the plugin package here.

Code:

pathdata = System.CreateDO("Clintons3D Package/Utility functions");
thedata = pathdata.GetFolderDialog();
System.Alert(thedata);

May 19, 2013

Keyframe data for trueSpace 7.61

Provides a keyframe data read from a clip nodes AnimData connector. Data is returned in JSON format and gives the value, the attribute, interpolation type and handle information.

The plugin package is required to use this script. Download the plugin package here.

Rotation values returned are the negative of the true values.

Code sample:

function Execute(params)
{
	//function will return values for the next keyframe after the provided time
	//
	//utilitydata.GetKeyframeData("Clip node full path","animated attribute",
	//a time before the next keyframe);
	//
	var utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
	var value = utilitydata.GetKeyframeData(Node.FirstSelected()+"/AnimClip","Matrix",-1);
	System.Trace(value);

	var obj = eval("(" + value + ")");

	for(j in obj) {
		System.Trace(j + " = " + obj[j])
		for(k in obj[j]) {
			System.Trace(k + " = " + obj[j][k]);
		}
	}
}
sample data:
{
    "time":"0",
    "tx":{"val":"-0.310669","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "ty":{"val":"1.40513","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "tz":{"val":"0.5","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "rx":{"val":"0","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "ry":{"val":"-0","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "rz":{"val":"-0","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "sx":{"val":"1","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "sy":{"val":"1","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"},
    "sz":{"val":"1","interp":"INTRPL_BEZIER_AUTO","leftAng":"0","leftLen":"0.333","rightAng":"0","rightLen":"0.333"}
}
April 8, 2015

Node Connectors info for trueSpace

Provides a list of a node's connectors including the name, type and flags. The first line returned is a header line. The list includes hidden connectors.

The plugin package is required to use this script. Download the plugin package here.

Code:

utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
currentnode = Node.FirstSelected();
thedata = utilitydata.GetConnectorData(currentnode);
connectors = thedata.split("\n");
for(i=0;i<connectors.length;i++)
{
System.Trace(connectors[i]);
connector = connectors[i].split("\t");
//connector[0] = script connector name
//connector[1] = connector name
//connector[2] = connector type
//connector[3] = flags
}

flags:

enum tagRtConFlags
{ CONFLG_DIRTY = 1,
CONFLG_OUT = 2,
CONFLG_IN = 4,
CONFLG_INOUT = 6,
CONFLG_RESERVED = 8,
CONFLG_EXPORTED = 16,
CONFLG_HIDDEN = 32,
CONFLG_CACHING = 64,
CONFLG_NONOTIFY = 128,
CONFLG_CONTROLFLOW = 256,
CONFLG_DISABLECACHING = 512,
CONFLG_REGISTERED = 1024,
CONFLG_CUSTOM = 2048,
CONFLG_TOPOLOGY = 4096,
CONFLG_LOCAL = 8192,
CONFLG_LAST = 8193
} RtConFlags;

May 19, 2013
joint orientation

Square Geometry Creator for trueSpace

This script will create a single 4 sided polygon square with uv coordinates assigned. Click the link or picture to download the script

September 5, 2009
joint orientation

Heads Up Display for trueSpace

This script demonstrates the use of the widget marker sets(IRfMarkerVisualizationDisp and IRiWidgets) to create a working analog/digital clock that always faces the viewer.

June 20, 2010
joint orientation

RGB Color Cube

A simple colored cubes generator. It uses a constant color to remove light interactions.

June 20, 2010
rgb points

RGB Color Points

A cube made of vertices. Uses IRdVertexVisualizationStream.

June 20, 2010

Test Panel Controls

Script adds UI controls, but no way to adjust them for labels, position, size etc. Controls disappear when the aspect is changed. Can make controls persistent by editing the panel.

June 20, 2010

Light Passthrough and Light Attribute Transfer for trueSpace7.61

2 part script for transferring a lights spot angle and color to an objects position, rotation and scale. One script goes inside the light. The other resides at the scene level.

Usage:

  1. Place the lightPassthrough script node inside the light encapsulator.
  2. Export the 2 output connectors, "angleOut" and "colorOut"
  3. Connect the "angleIn" to the outside through the "Angle" connector on the encapsulator.  Skip this step if the light isn't a spot light or the cone angle isn't animated.
  4. Connect the "colorIn" to the outside via the "Color" input connector.
  5. Add the lightAttrTransfer node to the scene level.
  6. Expand the light and connect the angleOut to the spotAngle input of the lightAttrTransfer node.
  7. Connect the colorOut of the light to the lightColor input of the lightAttrTransfer.
  8. Connect the matrixOut of the lightAttrTransfer to an object in the scene.

Now when the scene is exported to collada format the object's transforms will hold the cone angle and color animations for the light. Rotate X will hold the spot angle in degrees. Scale XYZ and Translate XYZ will hold the color values. Translate X is only valid if imported with a scale of 1. If pick whip on scale in After Effects then divide by 100 since AE converts scale 0-1 to 0-100.

Note: There is a script for an Enhanced Collada export that includes light cone and color animation export.

September 16, 2009

Camera FOV Attribute Transfer for trueSpace7.61

Script for transferring the camera FOV to an objects position, rotation and scale.

Usage:

  1. Set camera to "Exp" aspect in the LE
  2. Connect Camera output to the cam input
  3. Connect the MatrixOut to some object in the scene

Now when the scene is exported to collada format the object's transforms will hold the FOV animation for the camera. Rotate X will hold the fov in degrees. Scale X and Translate X will hold an After Effects compatible zoom value. Translate X is only valid if imported with a scale of 1 and the After Effects zoom is via pick whip and multiply by the composition height. If pick whip on scale also divide by 100 since AE converts scale 0-1 to 0-100.

Note: The collada exporter exports the camera fov from model space values and ignores the work space fov value.

Note: There is a script for an Enhanced Collada export that includes the camera's fov animation.

September 16, 2009
June 5, 2013