Tag Archives: trueSpace

Question Messagebox

The trueSpace scripting question messagebox can be hidden behind the main display. This is a solution to that problem.

// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
function Question(strText)
{
	var nSecondsToWait = -1;
	var strTitle = "Question";
	// values are hexadecimal
	var MB_YESNO = 4;
	var MB_SYSTEMMODAL = 4096;//1000L force on top
	var MB_ICONQUESTION = 32;//20L question mark symbol

	var nType = MB_YESNO+MB_SYSTEMMODAL+MB_ICONQUESTION;
	var IDYES = 6;
	var IDNO = 7;

	var shell = new ActiveXObject("WScript.shell");
	var button = shell.Popup (strText, nSecondsToWait, strTitle, nType);

	if(button == IDYES) return true;
	return false;
}

if(!Question("Special mesh processing\nDo you wish to continue?")) {
params.ConValue("abort") = 1;
return;
}

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