Page 1 of 1

How to create a Push button to set Matrix value? - Jscript

Posted: 13 Apr 2016, 05:02
by Draise
I have figured out a nodal way of limiting a Matrix value in a child, which is handy.

Now I just need a way to reset a said Objects Matrix, say back to XYZ 0,0,0. How do I do that?

Re: How to create a Push button to set Matrix value? - Jscript

Posted: 13 Apr 2016, 05:43
by Draise

Code: Select all

// Called to execute the command 
function Execute(params)
{


scene = Space.CurrentScene();
theTarget = Node.Select(scene + '/Cube');

targetWldMatrix = System.CreateDO("Math Package/Matrix Float Data");
targetObjMatrix = System.CreateDO("Math Package/Matrix Float Data");
//nodeMatrix = System.CreateDO("Math Package/Matrix Float Data");

targetWldMatrix = Node.Value(scene + '/Cube',"WldMatrix");
targetObjMatrix = Node.Value(scene + '/Cube',"ObjMatrix");



nodeMatrix = targetObjMatrix


				nodeMatrix.SetTransX(3.500);
				nodeMatrix.SetTransY(0.000);
				nodeMatrix.SetTransZ(9.000);

System.Alert("Something should have happened.");
}
I found some transform code that clinton made, tried to modify it, but I'm getting no results, also no error. I am probably getting the wrong data to then not be able to set the data.

How do I get matrix values then have a way to set them?

Re: How to create a Push button to set Matrix value? - Jscript

Posted: 13 Apr 2016, 12:10
by stan
you must put the value back into a matrix con
Node.Value(scene + '/Cube',"WldMatrix") = nodeMatrix;

Re: How to create a Push button to set Matrix value? - Jscript

Posted: 14 Apr 2016, 18:31
by Draise
I gave it a whirl, didn't quite manage personally. No errors, just.. not much happening. I probably need to study more javascript....

Re: How to create a Push button to set Matrix value? - Jscript

Posted: 14 Apr 2016, 21:11
by stan

Code: Select all

function Execute(params)
{
scene = Space.CurrentScene();
theTarget = Node.Select(scene + '/Cube');

targetWldMatrix = System.CreateDO("Math Package/Matrix Float Data");
targetObjMatrix = System.CreateDO("Math Package/Matrix Float Data");
//nodeMatrix = System.CreateDO("Math Package/Matrix Float Data");

targetWldMatrix = Node.Value(scene + '/Cube',"WldMatrix");
targetObjMatrix = Node.Value(scene + '/Cube',"ObjMatrix");



nodeMatrix = targetObjMatrix


            nodeMatrix.SetTransX(3.500);
            nodeMatrix.SetTransY(0.000);
            nodeMatrix.SetTransZ(9.000);

System.Alert("Something does have happened.");

Node.Value(scene + '/Cube',"Matrix") = nodeMatrix;

}

I forgot to put it on the 'in' matrix con or ownermatrix for the movement to register.

Re: How to create a Push button to set Matrix value? - Jscript

Posted: 14 Apr 2016, 21:51
by Draise
Nice, I added a semicolon somewhere, that works! Handy! Thanks Stan. This will come in handy later.