All posts by Clinton Reese

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);

trueSpace Scripting Matrix

Matrix multiplication

myMatrix.LoadIdentity();
rollMatrix.LoadIdentity();
yawMatrix.LoadIdentity();

yawMatrix.SetYaw(22);
rollMatrix.SetRoll(13);

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();
theMatrix.Mult(parInvert);

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

Node.Select – select one node

Space.Unselect()