truespace misc sdk notes from the wiki


creates some xml documentation files RsCmdDoc.xml and RsNodeDoc.xml
RsImport.ExportCollada(‘filename’,’list of nodes’) – will export a collada file via script
Widgets.Rotate == rotate about origin (0,0,0) then offset back to original position
WindowsManager.MoveWindow name item enhanced about possibility to work with working area size or the whole window size.

   * Example:
         o WindowsManager.MoveWindow(idWindow, -1, -1, Width, Height, WorkAreaSize, -1, -1);

trueSpace Python Notes(copied from wiki)

The python samples don’t work for trueSpace7.61 unless you copy the contents of the PythonScripts folder into the tS folder. The other option is to add 2 lines to the top of your python script:

import sys


This tells python to look inside the PythonScripts folder for modules to load.

Bug: GetMaterial(matidx), the object get material function always returns None.
Tutorials on the Wayback Machine, look at the early years:*/

trueSpace General SDK Notes(copied from wiki)

To change the version of a plugin from v.1638401 in the plugin manager change the RpExamplesPlugin.h from
#define EXAMPLE_PACKAGE_VERSION1 1 // cmdprompt package version



#define EXAMPLE_PACKAGE_VERSION1 1 // cmdprompt package version


#define EXAMPLE_PACKAGE_06192010 3 //my june 19 2010 version


will change the version to v.1635403
//from kernel.h

   //enum RtPixelFormat
   BFMT_UNKNOWN    = 0;
   BFMT_A8R8G8B8    = 1;
   BFMT_A16B16G16R16    = 2;
   BFMT_A32fB32fG32fR32f    = 3;
   BFMT_R8    = 4;
   BFMT_R16    = 5;
   BFMT_R32f    = 6;
   BFMT_FORCE_DWORD    = -1;
  // } ;

trueSpace General Script Notes(copied from wiki)

Clinick’s Clinic on Scripting #1: VBScript or JScript?

Special Edition Using Jscript, Including OOP in chapter 4

  1. Node.NearValue script property. Similar to Node.Value, but allows to specify short node name, if you want to access neighbor node from your script.
   * So instead of:
         o Node.Value( System.ThisOwner + “/Memory”, “A”) = 10
   * You can now use:
         o Node.NearValue( “Memory”, “A”) = 10
  1. Node.LookupParentValue script property (get only). The property look up parents for specified connector value. This can be useful for larger script projects with hierarchical structure – to access ‘common project parameters’ from all activity bricks without need to link to exported connector.
   * Example:
         o numPlayers = Node.LookupParentValue(“numPlayers”)
  1. Per widget visible/invisible settings in Desktop preferences.
   * Widgets saved in \scripts\desktop.widgets.xml, you can add your custom widgets here.

The way I understand the RsPackage.Install() command, it creates and or writes to the Plugins.xml file located in the Scripts folder. When you open tS761 the init.js file runs. In this script you will notice the RsPackage.Import(‘plugins.xml’); command. I believe the reset.js runs when a user Resets the Default Context. In that script you will notice two commands: ScriptObject.ImportScripts(0); ScriptObject.UpdatePck(0); As I understand it, this command reads the Scripts/ScriptCommands folder and loads all of the scripts within, into tS761 in the System/Scripts/Commands node. The scripts have to be named from within the Script Editor’s Attribute area in order for this to work right. This is how I loaded all of the scripts included in the last Unofficial Update. You will notice an OnNewScene script which gets called when you run Generate New Scene.

Space.Select() – select multiple nodes from text string separated by semi colons, node paths in the list must not have leading spaces

Node.Selection() – returns a selection list with a semicolon delimination, but has leading spaces in each nodes path so needs to be adjusted to work with Space.Select

sel = Node.Selection();
selArray = sel.split(";");
re = /^\s/; // whitespace in first character position
sel = selArray[0].replace(re,"");
if(selArray.length > 1)
		sel = sel + ";" + selArray[i].replace(re,"");

Node.Select – select one node



LE. – (L E dot) undocumented LE commands

Activity.Run(scene + “/second”);//runs after the calling script is done

ScriptObject.Execute(scene + “/second”);//runs immediately pausing the calling script

Scripts with the same command input connection will run in the order that they are connected. No parallel processing from parallel connections.

Script can combine different selection types like edge plus triangle.
sdk docs “structIRiTSBCommand.html” has “SuggestTSStateByAlias” command which is used to “Call to execute a Modeler’s action(click on a Modeler’s button)”. download Hexplorer

and running it on the tsxapi.dll file. Do a search for “Button” and one by one you can find the aliases for all the modelside buttons. Also works with items found by searching for “Panel”.

Modelspace(trueSpace 6) Button Icon production

24 bit bmp format, background color about (192,192,192), size 30×22

Workspace Button Icon production

truespace button icon –

paint shop pro 32 bit tga, background color about (118,118,118), select background, invert and save to alpha, size 26×26
photoshop – same, but can also do bmp format in 32bit

Link Editor Panels Editor

   * Tab order edit field in control property window.
   * Expand / shrink control size functions.
         o expand enlarges object size until it touches neighboring controls.
         o shrink minimizes size of selected object so that it fits a gap under the control.
   * Controls snapping in Panel Editor:
         o edges of the selected control are snapped to edges of remaining controls during panel editing.
         o this feature can be turned off in panel properties dialog.
   * Decorative control
         o use it to fill empty spaces, to create separating lines and to create "radio group"-like looking panel
         o use "fill gaps" function (located in decorative control properties dialog) to automaticaly clone this control to every hole in the panel
         o use Bottom/Right checkbox to fine-tune line position or to change orientation of the "U" shape
   * moving edited control using arrows snaps to grid and other controls too
   * hold ctrl while moving edited control to turn of snapping
   * Holding shift while sizing a control resizes all controls in the same row/column.

If you add a new connector to a script used inside the Widgets it won’t work right away. Restarting truespace will unstick it.
MeshModifiers.WeldPairs() script command does not work. It is the script version of the Edge Weld Tool for trueSpace 7.1

//functions for generating random guid for marker display

function S4() {

return (((1+Math.random())*0x10000)|0).toString(16).substring(1);


function guid() {

return ("{" + S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4() + "}");


//functions for generating random guid for marker display

function S4() {

return (((1+Math.random())*0x10000)|0).toString(16).substring(1);


function guid() {

return (“{“ + S4()+S4()+“-“+S4()+“-“+S4()+“-“+S4()+“-“+S4()+S4()+S4() + “}”);


Toolbar Prototype notes

create a toolbar by normal means – will often end up in a frame named “ToolbarFrame”

find the Toolbar inside Windows Manager Space inside the ToolbarFrame

type a name into the Prototype field of the Toolbar node and a prototype will be created inside the Toolbar Prototype Encapsulator

to recreate the toolbar – create a toolbar(drag and drop a button from another toolbar), find it’s Toolbar node and type the same name into the Prototype field and the toolbar will be recreated

OpenToolbarfromPrototype does not return the name of the node created
WScript Shell

//WshShell = WScript.CreateObject(“WScript.Shell”);

WshShell = new ActiveXObject(“WScript.Shell”);


matrix multiplication

   myMatrix.SetPitch(-90);// myMatrix = -90 deg pitch => last rotation
   myMatrix.Mult(rollMatrix);// rollMatrix (this is the second rotation) * myMatrix => myMatrix
   myMatrix.Mult(yawMatrix);// yawMatrix (this is the first rotation) * myMatrix => myMatrix
   final result in myMatrix is yaw then roll then pitch

trueSpace Collada Export


Workspace: If the copy textures option is not selected, image references with made up names(file_0, file_1, file_2) are created in the dae file with a relative path in the same location as the dae file.

Modelspace(procedural textures): If the copy textures option is not selected, the collada file will refer to texture files file_0… in the same location as the dae file, but no texture files will be created.

Modelspace(texture map): If the copy textures option is not selected, the collada file will refer to the texture directly but in a bad format and using an absolute path instead of relative.

Workspace: If copy textures option is selected then a folder with the same name as the dae file is created and the texture files(file_0…) are created in the folder and relative paths are created in the dae file to these textures.

Modelspace(procedural textures): If copy textures option is selected a folder with the same name as the dae file is created and texture files are created in it.

Modelspace(texture map): If copy textures option is selected an empty folder with the same name as the dae file is created(BUG), the texture file is copied to the same path as the dae file not into the new folder and the dae file will refer to the original texture file using absolute addressing in a bad format.(BUG)

Workspace texture in modelspace is treated the same way as modelspace procedural texture, but if the model is altered through point edit then a texture is created in the “Rs Tmp Textures” folder and it will act like a modelspace texture map export.

Normal map textures are referred in an xml “extra” tag, because these maps are not directly supported by the collada standard.

The diffuse and specular tags in the dae file from truespace always refers to the same texture.(BUG?)
The modelspace and precompiled workspace textures will export diffuse, alpha and normal maps.

Workspace materials composed of the various shaders bricks use the InputBitmap node to define the textures used. The InputBitmap nodes “Input usage” connector determines how it is exported, “DIFFUSEMAP” goes to diffuse, “NORMALMAP” goes to normal. Chapter 5 pg 143 of the truespace manual has a list under the heading “Material Compatibility”. The only maps listed are diffuse and normal. No alpha map is listed, but experimentation shows that if “ALPHAMAP” is typed into the input usage field an alpha texture is created for the collada file.
Vertex paint does not export even though the exporter has an option for it.(BUG)

Modelspace skeletons exports as a hierarchy of nodes/nulls made from truespaces bones and joints instead of actual joint nodes and no skinning information is exported.

trueSpace Tips & Tricks


The startup menu (accessible by holding the CTRL key while starting trueSpace) allows you to start trueSpace in any real time mode, as well as start a “clean” trueSpace session without automatically loading any stored configurations and projects.

[From United3dArtists forum author marcel]

You know TS is not a perfect software because it have a lot of bug. Most of them can be resolved when you know a trick like this (model side only):

– If you have a problem when you try to edit an object (TS crash), try to export the object with luuv (.obj) then import the new object and put it instead of the bad TS object in the scene. Edit mode could work now. I think because there is a bad thing saved with the TS object.

– if TS crash when you change the material of an object (wireframe), most of the time it is when TS do a render of the object. to avoid this problem use solid mode before apply a new texture. with solid mode TS don’t use Lightwork to show the new material on the screen.

– if TS crash when you change the view on a windows (ex: when you create a cam then open a windows), be sure you are on wireframe mode before you selected the cam icon of the windows to change the view.

-The best way to clean a bad TS scene (most of the time it is a problem with both side together) is to save each object (model, light, cam,…) as .cob then close TS, open TS, bridge off, open a new scene and load all the object to create a new scene without problem and keep brigde off.

– if you work on model side but you need a tool from workspace (displacement, hair,..) create a temporary scene, put bridge on and do what you need on the workspace. then on model side save the result as a .cob object. Turn bridge off and open your scene to add the new object.

– a .scn file can be ten time smaller than the same created with both side and with less problem. Be carefull about that and you can to continue to work with the model side with less RAM allowed for the workspace and more RAM for you.


Files to delete for “clean” session, may also help some model side problems


The Windows Manager Space node under Project has an attribute called “ShowFullPath”. Change this from 0 to 1 to show the full paths of nodes under Project in the title bar.
info panel math: +,-,*,/,sin,cos,arcsin,arcos,ln,log,exp,sqrt,PI

soft paint has a morph mode to paint one morph into another

truespace can save bvh files

LE panel editor – shift + size a control will effect entire row/column

It is possible to change topology after a vertex morph already defined

Primitive tool

   * Adding a cube. There are 3 modes how to add a cube.
         o Diagonal – this is Modeler way. LClick to define first corner, drag and rclick do define second corner.
         o Edges – define cube by defining two edges. First click & drag defines bottom X edge. Second click&drag defines Z edge.
         o Corners – cube is created after adding 4 points. (you can either click or drag to use xy or z movements).
   * For adding torus, sphere, cylinder, cone there are 2 modes.
         o Diameter – define diameter for base, by ldrag, rdgar defines height.
         o Radius - define center + radius for base, by ldrag, rdgar defines height.
   * Adding text has only one mode; ldrag + rdrag defines orientation of text XY plane rotation.
   * Primitive employs extensive snapping.
   * You can specify height directly by snapping to other objects during rdrag. Primitive base can be precisely aligned by
constraining movement to 1D and aligning with other objects like in rdrag mode. Constraining can be done either by locking
axes or locking to edges / faces.
   * You can specify edge endpoint (diagonal, radius…) in plane mode directly by snapping to other objects by holding ALT key.
   * ALT key can be used to force snapping even if cursor is in nosnap range defined by added primitive and nosnap radius
found in tool preferences panel.
   * To finish primitive tool, rclick in player view.
   * To access primitive preferences panel, rclick on appropriate tool button. To access primitive tool preferences panel,
rclick on any primitive tool and change preferences panel aspect to default.

Select by bounding box => smaller object has higher priority

Workspace View - Transparency
   * New Show hidden faces option in object and layer render attributes (Player - Rendering) allows to display otherwise
invisible faces of transparent objects.
   * New Transparency Mode option allows choosing transparent faces sorting option. No solving mode displays objects without
reorder. Triangle sort option is a bit slower and uses distance of triangles from the viewer to draw distant triangles first.
Transparency mode option is ignored when Show hidden faces is not enabled.
   Snapping & constraints
   * Snapping and constraints are used to allow high precision modeling. Snapping tools compute nearest position that may be
useful (grid point, vertex, edge…) and constraints lock movement to specified direction(s). These tools are accessible from
Player toolbar. Tool is activated by clicking on it; additional tool properties are accessible by rclicking on the tool icon.
Panels for snapping tools are located in preferences encapsulator (/Preferences/Snapping/ and /Preferences/Snapping/Point edit
   * Snapping & constraints can be combined and activated together. For example you can have active grid snapping and snap to
edge at once. Then when moving or drawing a polygon nearest point will be used as a snap position. This is also valid for
constraints, for example when constraining movement to two non-parallel planes movement will be constrained to their
   * You can have as many snapping managers as you wish, movement widget tools are now extended to contain snapping group
name. In this way you can add special controls to widgets that will cause snapping to selected elements, whereas other
controls can move without snapping or constraints. (Interesting?)

General Snapping & constraints

   * Grid snapping – snaps to grid when moving. There are two modes for grid snapping – Absoulte and Relative. Absolute mode
snaps in selected coordinate system where origin is defined by Offset parameters, Relative mode takes widget position as an
origin (so it snaps to original position). Mode is changed by checkbox near offset parameters. Step defines density of the
grid. When set to 0, snapping along that axis is disabled:
   * Axes locks – can be used to lock movement direction to selected axes(X,Y,Z checkboxes). If you check 2D in ortho view
than X and Y axes will be mapped according to camera view when using orthogonal views. Angle specifies rotation of axes in 2D
views and allows rotating constraint axes according to your needs.

Point edit Snapping & constraints

     Showing properties panel will show default aspect of point edit snapping tools. Panel contains settings for both vertex
snapping and lock to selection constraint.
     Vertex snapping snaps selected vertices to various positions when they are moved. Snap to vertices enables vertex to
vertex snapping. Snap to edges enables vertex to edge snapping. Edge points specifies count of internal edge points that
vertices will be snapped to. This setting requires that edge snapping is enabled. Setting to 0 will turn snapping to edge
mid-points off. Snap to faces controls vertex to face snapping.
     Lock to selection constraint tool allows to constraint movement to specified plane or edge similar to axes locking.
Select a face or edge and press Set button to use face or edge plane as constraint direction.
   Note: Both vertex snapping and lock to selection have advanced panels that are accessible by changing aspect of point edit
snapping panel. 
   * Vertex snapping:
         o Snap Pairs control whether to snap widget position or perform snapping between vertices and all enabled elements.
         o Snap distance defines radius for snapping in screen pixels. In 3D depth is also restricted to snap distance, in 2D
depth is ignored.
         o Marker specifies vertex size and color for position when it is not active.
         o Snap defines vertex size and color for vertex when snapped.
         o Only face edges will disable snapping to internal face edges.
     Select lock:
           Marker color and Transparency define properties of marker that is displayed to show movement constraints.

Using point edit snapping & constraints

     To use the tool point edit snapping, enable required snapping modes, make a selection and move it with point edit widget.
           When vertex gets snapped, snap will be showed by displaying snapped vertex with Snap color.
           If you snap any vertex to edge or triangle and hold shift, tool will show guide line and movement will get
constrained to that edge or plane.
           If you have enabled edge points and you snap to edge, snapping positions will be evaluated also outside that edge.
           Possible movement will be shown by rectangles with Marker properties.
     Snapping to face and pressing shift will constraint to 2D plane.Not so sure about that
           When constraints are active, snapping continues to work and you can move vertex and snap it to selected snapping
           Following image shows case when vertex was snapped to face and shift was pressed. Then the vertex was moved in XZ
plane (the plane was rotated to constraint space) and snapped to face.
           Yellow dashed lines show constraint space, top yellow triangle shows face triangle that defines constraint plane,
middle yellow triangle shows face that vertex is snapped to.
           When guideline is showed, you can use Ctrl to specify perpendicular direction constraint. With Ctrl pressed, your
movement will be constrained to perpendicular motion to edge or face. (Is this true?)
     Snapping for other tools work similarly.

Using Lock to selection

   * To use the tool, in point edit mode select face, two faces or edges.
         o When selecting face, movement will be constrained to that face. This will be visualized by showing 2 arrows from
face center.
         o When selecting two faces, movement will be constrained to edge defined by intersection of two planes.
         o When selecting edges, movement will be constrained to 1D.
   * This tool is useful when modeling in 2D views where 3rd coordinate can be automatically computed from constraints (for
example when modeling a roof on a house).
   * To set constraint, make a selection and press Set button in Point edit snapping panel. To remove constraints, press Reset
Polygon draw
   * Polygon draw tool allows directly drawing faces or edges during point edit mode.
   * Activate the tool by clicking on Polydraw tool icon in Player toolbar.
   * When selected object is not in point edit mode tool will activate it.
   * You add vertices connected by edges, by clicking on the mesh faces.
   * To modify vertex position during polygon draw, drag existing vertex.
   * To add new vertex on the edge, click on it.
         o When hovering above edge, Polydraw tool shows highlite of vertex that will be added.
         o To remove the vertex, move the vertex you want to delete to another vertex.
         o Tool will not allow creating invalid geometry. When trying to create bad polygon highlite will show in red.
         o To close the loop, click on the first vertex.
         o You can draw polygon across multiple faces, but edges need to pass thru edges or vertices on neighboring faces.
         o When you draw acceptable set of edges, Polydraw will change highlite to selection color.
               + When you activate other widget tool in this state, tool will finish without closing whole polygon. This
behavior is intended for drawing edges or adding vertices.
Snapping and Polydraw
   * You can use snapping with Polydraw:
         o simply enable or disable snapping & constraint tools when drawing polygons.
         o Activate guideline by snapping current vertex to edge and press shift key. If you want to move in perpendicular
direction, hold shift and ctrl.(that ctrl bit part may not work)

Extract a deformed mesh from a character by running the Flatten History tool. Open 2 Link Editor windows one to the scene and one to the Actor node. Ctrl – drag the mesh node out of the Actor and into the scene.

C++ handle to window

truespace 6

HWND tswnd;
tswnd = tsxGetMainViewHwnd();

truespace 7.6

HWND tswnd;
// get Window manager package
CComPtr spKernelPackage;
hr = CRpExamplesPlugin::GetKernelPackage(&spKernelPackage);
if (FAILED(hr))
   return hr;
CComPtr spPackage;
hr = spKernelPackage->FindPackage(DEF_GUIDNAME(CRpWinMng), &spPackage);
if (FAILED(hr))
   return hr;
CComQIPtr spWinPackage = spPackage;
// get windows manager node
CComPtr spWinMgrNode;
hr = spWinPackage->GetWindowsManagerNode(&spWinMgrNode);
if (FAILED(hr))
   return hr;
CComQIPtr spWinMng = spWinMgrNode;

trueSpace Scripting Matrix

Matrix multiplication



last rotation
myMatrix.SetPitch(-90);// myMatrix = -90 deg pitch

(this is the second rotation)
myMatrix.Mult(rollMatrix);// rollMatrix * myMatrix => myMatrix

(this is the first rotation)
myMatrix.Mult(yawMatrix);// yawMatrix * myMatrix => myMatrix

myMatrix is yaw 22 deg then roll 13 deg then pitch -90 deg

Local matrix from world matrices

theMatrix = Node.Value(bindgroup + "/" + subNode, "WldMatrix");
parentMatrix = Node.Value(bindParent, "WldMatrix");
parInvert = parentMatrix.Invert();

//now theMatrix contains local instead of world

trueSpace Scripting Selection

Space.Select() – select multiple nodes from text string separated by semi colons, node paths in the list must not have leading spaces

Node.Selection() – returns a selection list with a semicolon delimination, but has leading spaces in each nodes path so needs to be adjusted to work with Space.Select

sel = Node.Selection();
selArray = sel.split(";");
re = /^\s/; // whitespace in first character position
sel = selArray[0].replace(re,"");
if(selArray.length > 1)
		sel = sel + ";" + selArray[i].replace(re,"");

Node.Select – select one node