Category Archives: Uncategorized

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_VERSION EXAMPLE_PACKAGE_VERSION1

to

#define EXAMPLE_PACKAGE_VERSION1 1 // cmdprompt package version

//#define EXAMPLE_PACKAGE_VERSION EXAMPLE_PACKAGE_VERSION1

#define EXAMPLE_PACKAGE_06192010 3 //my june 19 2010 version

#define EXAMPLE_PACKAGE_VERSION EXAMPLE_PACKAGE_06192010

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)
	for(i=1;i<selArray.length;i++)
		sel = sel + ";" + selArray[i].replace(re,"");

Node.Select – select one node

Space.Unselect()

%THIS_OWNER_NAME%

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 http://sourceforge.net/projects/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”);

WshShell.Run(“calc”);

matrix multiplication

   myMatrix.LoadIdentity();
   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
 

C++ handle to window

truespace 6

HWND tswnd;
tswnd = tsxGetMainViewHwnd();

truespace 7.6

HRESULT hr;
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;
spWinMng->get_MainWindowHandle(&tswnd);