Phoenix Garden
The Transform Constraint - Printable Version

+- Phoenix Garden (https://roysforum.com)
+-- Forum: Community (https://roysforum.com/forum-103.html)
+--- Forum: Raistin Kane - Research Center (https://roysforum.com/forum-158.html)
+--- Thread: The Transform Constraint (/thread-719.html)



The Transform Constraint - Richter Belmont - 07-24-2024

Will never have been able to archieve my Centaur addon pant without this.

First of all, you need to understand parenting relationship.
In such relation, a given object (child, can also be know as slave) will be connected to an another object (parent, can also be know as master).
The child will inherit all the transform (rotation, translation, scale) of his parent.
When the parent is scaling, the child also scale.
When the parent is translating, the child also translate.
When the parent is rotating, the child also rotate...using the pivot point of his parent.
This mean that if the parent rotate on himself, the child (unleast being at the exact position of his parent) will rotate around around his parent (rather than himself).
This is a real problem when trying to copycat the rotation of other object.

And so what if you want your object to inherit transform from multiple object (like it had multiple parent) and/or from only specific transform (for exemple, inherit from the rotation, but not from translation and scale)?
Here the Transform Constraint come handy.
It allow to copycat the transformation (of a single or multiple type) from an another object (or multiple one if needed).
Influence of each object can even be controlled.

Constraint do not export to .dae (Collada).
So you can't rely on CollaTKane for creating the Transform Constraint for you. (you will have to add it by hand)


Node able to use Transform Constraint are TTransform and object that have access to all the parameter of it (like Tjoint).
In the TTransform node that you want to add some Transform Constraint, you will add this parameter: TBaseTransform.ConstraintArray [ ]; and inside the [ ] of it, you link some TransformConstraint node object.

Example:

Code:
TBaseTransform.ConstraintArray [ TransformConstraint :local_horse_tail_joint02_RotConstraint ];


So let get to the parameter used by the TransformConstraint node object.

TransformConstraint.ConstraintType TransformConstraint.ConstraintTypeEnum
It can have 4 possible value (a TransformConstraint node cannot use more than one):
.Point = copy translation
.Orient = copy rotation
.Scale = copy scale
.Parent = copy all transform translation and rotation.
None of the constraint do scaling.(broken)
According to maya database, there is no constraint doing scaling.


Example:

Code:
TransformConstraint.ConstraintType TransformConstraint.ConstraintTypeEnum.Orient;


TransformConstraint.OrientOffset Vector3f( )
when using rotation type constraint, there is some high chance that the rotation of you object appear to be broken.
This paremeter allow to do the adjustment for correcting the problem.

Example:

Code:
TransformConstraint.OrientOffset Vector3f( 180, 0, -90 );


Constraint.TargetArray [ ];
Inside the [ ] of this parameter, you will link the TTransform node from who you want to copy the transform (can be multiple one)

Example

Code:
Constraint.TargetArray [ TTransform :local_butt_L_joint01_Constraint_Locator , TTransform :local_butt_R_joint01_Constraint_Locator ];


This parameter appear to only support TTransform node, if you want to copy the transform of a TJoint, you will need to create a new TTransform that will use the given Tjoint as parent, and link this newly created TTransform in the array.

Constraint.WeightArray Array_F32 [ ];
For each item linked in the Constraint.TargetArray [ ]; parameter, you will write a number going from 0 to 1 inside [ ] of the Constraint.WeightArray Array_F32 [ ]; parameter.
These number tell the influence of each linked TTransform (0 = no influence, 1 = 100% influence)

Example:

Code:
Constraint.WeightArray Array_F32 [ 0.5, 0.5];


That's pretty all, so I will let you with a complete exemple:
There I want my Tjoint :local_horse_tail_joint02 to copy the rotation of TJoint :local_butt_L_joint01 and TJoint  :local_butt_R_joint01..
Code:
TJoint :local_butt_L_joint01 . {[/color]
[color=#000000]TNode.SNode SJoint :local_Sbutt_L_joint01;[/color]
[color=#000000]TNode.Parent TJoint :local_root;[/color]
[color=#000000]Object.Name "butt_L_joint01";[/color]
[color=#000000]};[/color]
[color=#000000]SJoint :local_Sbutt_L_joint01 . {[/color]
[color=#000000]SSimpleTransform.Translation Vector3f( -0.0478399992, -0.03821999952, 0.07789000124 );[/color]
[color=#000000]SSimpleTransform.Scaling Vector3f( 1.000010014, 1, 1 );[/color]
[color=#000000]SJoint.JointOrientation Vector3f( 9.999999747e-006, 1.636569977, 171.2380066 );[/color]
[color=#000000]Object.Name "Sbutt_L_joint01";[/color]
[color=#000000]};[/color]
[color=#000000]TJoint :local_butt_R_joint01 . {[/color]
[color=#000000]TNode.SNode SJoint :local_Sbutt_R_joint01;[/color]
[color=#000000]TNode.Parent TJoint :local_root;[/color]
[color=#000000]Object.Name "butt_R_joint01";[/color]
[color=#000000]};[/color]
[color=#000000]SJoint :local_Sbutt_R_joint01 . {[/color]
[color=#000000]SSimpleTransform.Translation Vector3f( -0.0478399992, -0.03821999952, 0.07789000124 );[/color]
[color=#000000]SSimpleTransform.Scaling Vector3f( 1.000010014, 1, 1 );[/color]
[color=#000000]SJoint.JointOrientation Vector3f( 9.999999747e-006, 1.636569977, 171.2380066 );[/color]
[color=#000000]Object.Name "Sbutt_R_joint01";[/color]
[color=#000000]};[/color]
[color=#000000]TTransform :local_butt_L_joint01_Constraint_Locator . {[/color]
[color=#000000]TNode.SNode STransform :local_Sbutt_L_joint01_Constraint_Locator;[/color]
[color=#000000]TNode.Parent TJoint :local_butt_L_joint01;[/color]
[color=#000000]Object.Name "butt_L_joint01_Constraint_Locator";[/color]
[color=#000000]};[/color]
[color=#000000]STransform :local_Sbutt_L_joint01_Constraint_Locator Object.Name "Sbutt_L_joint01_Constraint_Locator";[/color]
[color=#000000]TTransform :local_butt_R_joint01_Constraint_Locator . {[/color]
[color=#000000]TNode.SNode STransform :local_Sbutt_R_joint01_Constraint_Locator;[/color]
[color=#000000]TNode.Parent TJoint :local_butt_R_joint01;[/color]
[color=#000000]Object.Name "butt_R_joint01_Constraint_Locator";[/color]
[color=#000000]};[/color]
[color=#000000]STransform :local_Sbutt_R_joint01_Constraint_Locator Object.Name "Sbutt_R_joint01_Constraint_Locator";[/color]
[color=#000000]TJoint :local_horse_tail_joint02 . {[/color]
[color=#000000]TBaseTransform.ConstraintArray [ TransformConstraint :local_horse_tail_joint02_RotConstraint ];[/color]
[color=#000000]TNode.SNode SJoint :local_Shorse_tail_joint02;[/color]
[color=#000000]TNode.Parent TJoint :local_horse_tail_joint01;[/color]
[color=#000000]Object.Name "horse_tail_joint02";[/color]
[color=#000000]};[/color]
[color=#000000]SJoint :local_Shorse_tail_joint02 . {[/color]
[color=#000000]SSimpleTransform.Translation Vector3f( 0, 0, 0.1788700074 );[/color]
[color=#000000]SJoint.JointOrientation Vector3f( 0.1762900054, 0, 0 );[/color]
[color=#000000]Object.Name "Shorse_tail_joint02";[/color]
[color=#000000]};[/color]
[color=#000000]TransformConstraint :local_horse_tail_joint02_RotConstraint . {[/color]
[color=#000000]TransformConstraint.ConstraintType TransformConstraint.ConstraintTypeEnum.Orient;[/color]
[color=#000000]TransformConstraint.OrientOffset Vector3f( 150, 0, 90 );[/color]
[color=#000000]Constraint.TargetArray [ TTransform :local_butt_L_joint01_Constraint_Locator , TTransform :local_butt_R_joint01_Constraint_Locator ];[/color]
[color=#000000]Constraint.WeightArray Array_F32 [ 0.5, 0.5];[/color]
[color=#000000]Object.Name "horse_tail_joint02_RotConstraint";[/color]
[color=#000000]};