tS Shader VectorFromToComponents

The built in shader components, VectorFromComponents and VectorToComponents have XYZ and W connectors. The W seems to have an effect on the XYZ values, like its a kind of pre-multiplied alpha. The following HLSL scripts use pure XYZ vector math without the W.

Vector3ToComponents

void NewFunction(in RtFloat3 Vector3, out RtFloat X, out RtFloat Y, out RtFloat Z)
{
	X = Vector3.x;
	Y = Vector3.y;
	Z = Vector3.z;
}

Vector3FromComponents

void NewFunction(in RtFloat X, in RtFloat Y, in RtFloat Z, out RtFloat3 Vector3)
{
	Vector3.x = X;
	Vector3.y = Y;
	Vector3.z = Z;
}

Widget Notes

The UI-Widgets Package library has a couple of nodes.

Widget shortcut – can assign shortcuts to the widget as a whole
Widget toolbar – opens a toolbar when the widget is active and closes it along with the widget

The shortcuts only seems to work with simple lower case characters, numbers and some lower case symbols.
The toolbar only works with 1 toolbar at a time. More than one and they sit on top of each other. It seems to open the toolbar near the mouse position.

tS WindowsManager Notes

WindowsManager.CloseToolbar operates on the ID not the Prototype of the toolbar

WindowsManager.OpenToolbarFromPrototype(“Main”, 100, 100, 0, 0); uses the Prototype not the ID these values 100,100 is location, 0,0 are dummy size to just fit the toolbar

//frame snapping constants
//_WindowsManager.h
//enum _tagRtWindowCorner
//} 	RtWindowCorner;
WINDOW_CORNER_TOP	= 0
WINDOW_CORNER_BOTTOM	= 1
WINDOW_CORNER_LEFT	= 2
WINDOW_CORNER_RIGHT	= 3
WINDOW_CORNER_CENTER	= 4
WINDOW_CORNER_VERTICAL_CENTER	= 5
WINDOW_CORNER_HORIZONTAL_CENTER	= 6
WINDOW_CORNER_CLIENT_CENTER	= 7
WINDOW_CORNER_CLIENT_VERTICAL_CENTER	= 8
WINDOW_CORNER_CLIENT_HORIZONTAL_CENTER	= 9
WINDOW_CORNER_LEFT_TOP	= 10
WINDOW_CORNER_LEFT_BOTTOM	= 11
WINDOW_CORNER_RIGHT_TOP	= 12
WINDOW_CORNER_RIGHT_BOTTOM	= 13
WINDOW_CORNER_CLIENT_TOP	= 14
WINDOW_CORNER_CLIENT_BOTTOM	= 15
WINDOW_CORNER_CLIENT_LEFT	= 16
WINDOW_CORNER_CLIENT_RIGHT	= 17
WINDOW_CORNER_CLIENT_LEFT_TOP	= 18
WINDOW_CORNER_CLIENT_LEFT_BOTTOM	= 19
WINDOW_CORNER_CLIENT_RIGHT_TOP	= 20
WINDOW_CORNER_CLIENT_RIGHT_BOTTOM	= 21
WINDOW_CORNER_TITLEBAR_RIGHT_TOP	= 22

//only seems to work for actual corners, and offsets set to 0
//WINDOW_CORNER_CLIENT is target and source is WINDOW_CORNER
//snaps the source frame to the target, the second to the first
//HRESULT STDMETHODCALLTYPE SnapFrameToFrameEx( 
//            /* [in] */ BSTR bszFrameTarget,
//            /* [in] */ BSTR bszFrameSource,
//            /* [in] */ VARIANT iFrameTargetCorner,
//            /* [in] */ VARIANT iFrameSourceCorner,
//            /* [in] */ VARIANT iOffsetX,
//            /* [in] */ VARIANT iOffsetY)

//can not figure this one out at all, same args except no offsets
//STDMETHODCALLTYPE SnapFrameToFrame( 

Saving and Loading Toolbars

If you try to save a toolbar to disk it will save as empty without any buttons. Workaround is to create the toolbar in the Toolbar Prototypes Encapsulator then save the Toolbar Prototypes Encapsulator to disk. Reload into trueSpace in a different location and remove all the toolbars except for the toolbar of interest, optionally rename the encapsulator and save to disk. Now loading this encapsulated toolbar won’t loose the buttons.

trueSpace Toolbar Button Bug?

When a script is called from a toolbar button using ScriptObject.Execute, the script will not be able to read node connection values, Node.Value If the same script is called from a toolbar button using Activity.Run then it can read the values without an error.

As noted in another post the Node.Value will also fail inside a script function set. The fix is to use RsApp.RunScriptBuffer

GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();

will fail when run from a toolbar button because GlobalFS.Parent() has a Node.Value in it.

cmd='GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");GlobalFS.Parent();';RsApp.RunScriptBuffer(cmd);

wrapped in a script buffer command and it works

Truespace Script Buffer

trueSpace scripts create an undo step for each command in the script that changes the graph. So a single script can have many undo steps generated. The trueSpace script buffer will run a collection of script commands in the form of a string and generate only 1 undo.

Function Set variables can be used to pass complex data structures to the buffer.

If Node.Value() is used inside of a function set then it cannot be called directly from a toolbar button. The Node object seems to be incomplete and will fail with an warning message in the log, but no alert dialog like normal errors. If called using the script buffer command the Node.Value function will work when called from a toolbar button.

var cmd = ''
// note that if System.ThisOwner() is included in the buffer tS will crash
var thisowner = System.ThisOwner()
cmd += var owner = "' + thisowner + '";'
cmd += 'System.Trace(owner)'
RsApp.RunScriptBuffer(cmd);