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

Technical questions, etc..
Post Reply
User avatar
Draise
Captain
Posts: 3051
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

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

Post by Draise » 13 Apr 2016, 05:02

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?

User avatar
Draise
Captain
Posts: 3051
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

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

Post by Draise » 13 Apr 2016, 05:43

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?

stan
Master Chief Petty Officer
Posts: 496
Joined: 21 May 2009, 17:20

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

Post by stan » 13 Apr 2016, 12:10

you must put the value back into a matrix con
Node.Value(scene + '/Cube',"WldMatrix") = nodeMatrix;

User avatar
Draise
Captain
Posts: 3051
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

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

Post by Draise » 14 Apr 2016, 18:31

I gave it a whirl, didn't quite manage personally. No errors, just.. not much happening. I probably need to study more javascript....

stan
Master Chief Petty Officer
Posts: 496
Joined: 21 May 2009, 17:20

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

Post by stan » 14 Apr 2016, 21:11

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.

User avatar
Draise
Captain
Posts: 3051
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

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

Post by Draise » 14 Apr 2016, 21:51

Nice, I added a semicolon somewhere, that works! Handy! Thanks Stan. This will come in handy later.

Post Reply