trueSpace - convert Joint Matrix to OwnerMatrix - how?

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

trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by Draise »

This is a question about accessing OwnerMatrix values of a joint, or it's OwnerMatrix output. I know they have Matrix values, but I can't export these, and using them to drive anything else makes it very hard to pinput, because it's a WldMatrix, which depends on the world - not local Matrix.

Ideally I would like to pull Local Matrix (OwnerMatrix) values from a bone or joint or IK handle to then use those Matrix values to drive other things, like other object matrixes or morph targets or things of the sort.

How could I do this in Javascript or with nodes? Are trueSpace WS rigs strictly WldMatrix based?
User avatar
Draise
Captain
Posts: 3198
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by Draise »

I can use Clintons Point Constraint script and his new Bake tool, then unhook and render away the rigs that are baked, and use the constrainor to drive the morphs or other matrices - but the workflow I find.. a bit cumbersome. I have to bake, unhook, pre-render, rehook, animate, bake, unhook, pre-render, rehook, modify animation, bake, unhook, pre-render.. a very drawn out workflow.

Aren't there procedural clips? Can't the constraint animation be keyframed into one of those so the renderer works without the script errors?
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by clintonman »

You can use the WldMatrix of the parent and child nodes to get the child node local matrix with some math.

Code: Select all

parentMat = Node.Value(theparentjoint, "WldMatrix");
parentMatInv = parentMat.Invert();

childMat = Node.Value(thechildjoint, "WldMatrix");
childMat.Mult(parentMatInv);
//childMat now holds local matrix
Attached script:
select a joint and run it, creates parented cubes to show that the local matrix is correctly calculated.

Edit: Oops, forgot to attach it
Attachments
local joint matrix.zip
(3.31 KiB) Downloaded 278 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5206
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by trueBlue »

There is a tS761B8.zip\sdk_tS761B8\Examples\RsAnimPlugin\Release\RsAnimPlugin.rsx
Capture.JPG
Capture.JPG (13.93 KiB) Viewed 4413 times
Procedural clip activity node:

Activities extend functionality of nodes. Activity nodes can perform actions and modify object-constraint graph in the way the commands do. They have to implement IRsCommand interface that is used to execute requested actions by calling IRsCommand::Execute method. Activity nodes may combine container and function features of nodes and ability to modify content into one unit, making them ideal candidates for building complex behaviors. Activities are connected to each other using topological connections called control-flow links.
User avatar
Draise
Captain
Posts: 3198
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by Draise »

clintonman wrote:You can use the WldMatrix of the parent and child nodes to get the child node local matrix with some math.

Code: Select all

parentMat = Node.Value(theparentjoint, "WldMatrix");
parentMatInv = parentMat.Invert();

childMat = Node.Value(thechildjoint, "WldMatrix");
childMat.Mult(parentMatInv);
//childMat now holds local matrix
Attached script:
select a joint and run it, creates parented cubes to show that the local matrix is correctly calculated.

Edit: Oops, forgot to attach it
Wow, thanks for this.

I didn't experiment deep enough, but in theory, I put the WldMatrix values of the parent joint in the parent cube then the WldMatrix values of the child joint into the child cube, and that will give me the OwnerMatrix of the child (when I export it?)
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: trueSpace - convert Joint Matrix to OwnerMatrix - how?

Post by clintonman »

Draise wrote:
clintonman wrote:You can use the WldMatrix of the parent and child nodes to get the child node local matrix with some math.

Code: Select all

parentMat = Node.Value(theparentjoint, "WldMatrix");
parentMatInv = parentMat.Invert();

childMat = Node.Value(thechildjoint, "WldMatrix");
childMat.Mult(parentMatInv);
//childMat now holds local matrix
Attached script:
select a joint and run it, creates parented cubes to show that the local matrix is correctly calculated.

Edit: Oops, forgot to attach it
Wow, thanks for this.

I didn't experiment deep enough, but in theory, I put the WldMatrix values of the parent joint in the parent cube then the WldMatrix values of the child joint into the child cube, and that will give me the OwnerMatrix of the child (when I export it?)
First step is to get the WldMatrix of the selected joint and WldMatrix of it's parent joint.
Second is to use that to compute the selected joint Matrix value.
Here it is without the extra stuff. The cubes were just for demonstration. At the end you get the Matrix value of the selected joint

Code: Select all

function Execute(params)
{

	childJoint = Node.FirstSelected();
	if(!childJoint) return;
	if(Node.ConExists(childJoint, "Joint")) {
		System.Trace("child: " + childJoint);
	} else return;
	
	parentJoint = Node.LinkedInputNode(childJoint,"Bone",0);
	if(Node.ConExists(parentJoint,"Root")) {
		parentJoint = Node.LinkedInputNode(parentJoint,"Root",0);
	} else {
		parentJoint = Node.LinkedInputNode(parentJoint,"Bone",0);
	}
	if(!Node.ConExists(parentJoint, "Joint")) {
		if(Node.ConExists(parentJoint, "Skeleton") && Node.SubObjectCount(currentpath) == 0) {
			return;
		}
		parentJoint = Node.LinkedInputNode(parentJoint,"Root",0);
	}

	parentMatrix = System.CreateDO("Math Package/Matrix Float Data");
	parentMatrixInverse = System.CreateDO("Math Package/Matrix Float Data");
	childMatrix = System.CreateDO("Math Package/Matrix Float Data");

	parentMatrix = Node.Value(parentJoint, "WldMatrix");

	parentMatrixInverse = parentMatrix.Invert();

	childMatrix = Node.Value(childJoint, "WldMatrix");
	childMatrix.Mult(parentMatrixInverse);
	//childMatrix === Matrix for the selected joint

}
Clinton Reese

http://clintons3d.com
Post Reply