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
compositing nodes
sockets
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.

This rsx plugin v.1638412 comes pre-installed in the Unofficial trueSpace Updates - https://www.united3dartists.com/forum/viewforum.php?f=55

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

October 15, 2019

  • update sockets processing to include udp and timeout parameters
  • still version v.1638414 - forgot to update

August 25, 2019

  • plugin version v.1638414
  • collada import fixes
  • add node persistentID to the Node Connectors Info

April 30, 2019

  • plugin version v.1638413
  • updated composite nodes - all are fast now, added new Resample Node
  • sockets processing - for use with 3Delight python NSI system

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

Missing set keyframe button - tSBridge.SuggestTSStateByAlias("RecordKeyFrameButton"); found inside the tsxapi.dll file.

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);
//fso method return of folder or filename is flawed when path is invalid/empty
//causes returned value of plugin to cause tS crash
if(folder=="") folder="";
if(filename=="") 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.

The header line includes the nodes persistentID which is valid while the scene is open

first line heading(connectors[0]) is "script conn name\tconn name\ttype\tflags\t" + persistentID found 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

Offline Render hooks

setup offline render hooks for jscript

steps to install offline renderer

  1. open the offline preferences
  2. create the node in the now visible Offline renderers node
  3. now can call the offline script hooks
    //
    //Add Yafaray to offline renderers
    //
    //create/open render preferences node
    ScriptObject.RunCmd("space 3d package/open offline renderer preferences");

    if(!Node.Exists("/Offline renderers/Yafaray")) {
        try {
            Node.Create("Clintons3D Package/Yafaray", "/Offline renderers");
        } catch (err) {
            System.Trace("Error: Clintons3D Package plugin should be installed first");
        }
    }
                    
August 26, 2018

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

Procedural Modelling - Stool

stool

Adapted from a 3DBuzz Houdini Tutorial

Notes:

  • Watchdog responds to all connectors of single script object - one changes and all will send a signal to the watchdog. Maybe better to have changes that require a command script execution be on their own nodes.
  • uses an external mesh object parent for the leg, acting as a pivot for the leg
  • combines meshes via a command script combined with a Csg operation node
  • command node calls second command using ScriptObject.Execute to force synchronous update for truespace items
  • the masterControl node outputs were created via a utility script, Generate Outputs
April 11, 2019

Generate Outputs

generate outputs panel

Utility script that will read an exported scripts xml file, read the input parameters and create a new xml file with corresponding output parameters.

Usage:

  1. use the Export Script button to save an xml file
  2. choose the xml file with the ... button and press Start
  3. a new file is create - filename.xml => filename_Processed.xml
  4. use the Import Script button on the new xml file

Notes:

  • uses "Msxml2.DOMDocument.6.0"
  • each "parameter" will have a corresponding "parameterOUT" connector
  • CDATA is ignored and simply copied to the new file
  • can transfer between script objects and command scripts by editing the first lines after importing (Execute, OnComputeInputs...)
April 11, 2019

Flip Animation Scene

Inspired by Blender Animation nodes

flip tile node tree

Notes:

  • torus distance from each tile is used to determine the amount of rotation on a tile
  • GridArray_Cube node is an updated script derived from the soon to be old grid array script utility
  • The distances script object computes distances from each tile to the torus outputing a number array.
  • The Number Array MapRange script object scales the values of the distances number array to result in a rotation in pitch between 0 and 180 degrees for each tile.
  • The FlipCones node performs the rotations of the tiles found inside the GridArray_Cube node using values from the number array output of the MapRange node.
  • The target tiles are defined by selecting the first clone, "meshObj"
April 11, 2019

Look At Demo Object

look at math found: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/bb281710(v%3Dvs.85)

the matrix lookat script function is not working in truespace.

Move either sphere to see the lookat behavior

April 11, 2019

Sphere Collapse Scene

Inspired by Blender Animation nodes

Usage:

  1. select the Cube
  2. press the Copy Mesh button to populate the cubes
  3. press the Look at Center button to orient the cubes
  4. press the Select Effector to select the Torus
  5. move the Torus around

Notes:

  • Blender icosphere with 4 sub divs = 642 vertices. truespace set sphere resolution to 8 to match
  • predates the lookat math - instead uses a tailref cube connected to a headref cube via a lookat node
    • the headref is placed at (0,0,0)
    • the tailref is placed at the vertex locations of the larger sphere
    • the tailref rotation is read and copied to the individual cube matrix

Countdown Scene

Inspired by Blender Animation nodes

Notes:

  • Final mesh output uses a "mesh instancer" node
  • Uses 3 array point accumulators to create the grid of position values for the hexagonal shapes
  • The countdown text and an invisible cube are joined together with a csg node set for intersection mode. The cube is moved to the position of each array point and the csg resulting mesh is read in. If the resulting mesh is not empty, then that hexagon shape moves up.
  • The noise motion comes from a image cloud node
  • The wave image is made from the linearGradient image included in the trueSpace Unofficial Update combined with an image curve node. It is animated using an image crop node.
  • The material uses a vertex shader to blend between the colors.
  • Uses animation of a torus going up and down to control the numbers motion. RsAnim.PutFrame is used to set the time on the torus, then it's z value was read in as a control. PutFrame only effects the one item and does not effect the rest of the scenes animations.

Instancer.RsObj - used to create a single mesh from many copies.

Array Points.RsObj - creates a 1D line of vertices given a count and offset values

Array Points Accumulator.RsObj - same as array points but takes a vertex list input to create 2D and 3D vertex arrays

Clintons3D Plugin Ext package

Collection of plugin code that requires external files to operate

Only contains the tif loader at this time

Tiff Loader.zip contains all the required files in one zip archive.

Source code: Clintons3dExtSource.zip

  • Based on LibTIFF v3.6.1, http://www.libtiff.org/
  • Requires jpeg62.dll and libtiff3.dll placed in the same folder as the rsx file
  • Any other code that depends on external files will be added to this rsx plugin
April 28, 2019

TCP Sockets client

Communicate with other processes or servers via tcp sockets

util.SocketComm(text message, ip address of socket server, port number on socket server, timeout in ms - 0 means no timeout, true ==> use UDP otherwise use TCP) returns a text response

    function writeOut(val)
    {
        var result = util.SocketComm(val,"127.0.0.1", 5000, 300, false)
        System.Trace(result);
    }

    util = System.CreateDO("Clintons3D Package/Utility functions");

    writeOut('some text to send')
                    

Notes:

June 5, 2013