Link_Constraint - superclass: Matrix3Controller; super-superclass:MAXWrapper - 2:1 - classID: #(-2025855132, -1430354431)
A Link constraint is used to animate an object linking from one target object to another.
The Link constraint causes an object to inherit the position, rotation, and scale of its target object.
Constructor
Link_Constraint...
Link ...
Properties
<Link_Constraint>.key_mode Integer default: 0 -- integer; Link_KeyMode
You can choose between three different Key Modes that will determine how keyframes are written on the linked objects as part of the link constraint. These options will provide the following:
0: No Key Mode: No keys are created in any of the objects involved.
1: Key Nodes: Sets keys for some of the objects.
2: Child: Applied keys to the child object only.
3: Parents: Applies keys to both parents and the child object.
4: Key Entire Hierarchy: This applies keyframes to the chosen nodes and their entire hierarchies.
5: Child: Keys the chosen object and the nodes in its hierarchy up to the world.
6: Parents: Keys both parents and the child and all three hierarchies up to the world.
<Link_Constraint>.link_params SubAnim default: SubAnim:Link_Params -- transform
Contains the Link Params Transforms sub-anim, which in turn has three properties - .Position
, .Rotation
, and .Scale
. It contains the offset transform in parent space. This controller will contain keys depending on the .key_mode
settings described above.
Link_Constraint interfaces:
Interface: constraints
Methods:
<node><Link_Constraint>.getNode <index>nodeNumber
Returns the indexed target.
<float><Link_Constraint>.getFrameNo <index>targetNumber
Returns the linking start frame number of the indexed target.
<boolean><Link_Constraint>.setFrameNo <index>targetNumber <integer>frameNo
Sets the linking start frame number of the indexed target. Returns true
on success.
<integer><Link_Constraint>.getNumTargets()
Returns the number of targets.
<boolean><Link_Constraint>.addTarget <node>target <integer>frameNo
Appends the specified node to the target list at the specified frame. Returns true
on success.
<boolean><Link_Constraint>.DeleteTarget <integer>targetNumber
Deletes the indexed node from the target list. Returns true
on success.
<integer><Link_Constraint>.addWorld frameNo:<integer>
frameNo
default value: -99999.
This method sets "World" as a target at the specified frame.
EXAMPLE
s = sphere() --create a sphere at time 100 with animate on s.pos = [200,0,0] --animate sphere 200 units along X over 100 frames b = box() --create a box at time 100 with animate on b.pos = [0,500,0] --animate box 500 units along Y over 100 frames t = teapot() --create a teapot lc = link_constraint() --create a Link Constraint instance t.transform.controller = lc --assign the constraint to the transform controller of the teapot lc.key_mode = 0 --set the key mode to 0 (it is the default anyway) lc.addWorld frameNo:29 --add a World key on frame 29 lc.addTarget s 30 --add the sphere as link target on frame 30 lc.addWorld frameNo:60 --add a World key on frame 60 lc.addTarget b 70 --add the box as link target on frame 70 lc.addWorld frameNo:80 --add a World key on frame 80 lc.setFrameNo 5 90 --changed my mind, move the last (fifth) world key to frame 90! for i = 1 to lc.getNumTargets() do --print all keys' index, time and target format "%: Frame:% - Target:% \n" i (lc.getFrameNo i) (lc.getNode i)
OUTPUT
$Sphere:Sphere001 @ [0.000000,0.000000,0.000000] [200,0,0] $Box:Box001 @ [0.000000,0.000000,0.000000] [0,500,0] $Teapot:Teapot001 @ [0.000000,0.000000,0.000000] Controller:Link_Constraint Controller:Link_Constraint 0 1 true 1 true 1 true 1: Frame:29 - Target:undefined 2: Frame:30 - Target:$Sphere:Sphere001 @ [0.000000,0.000000,0.000000] 3: Frame:60 - Target:undefined 4: Frame:70 - Target:$Box:Box001 @ [0.000000,0.000000,0.000000] 5: Frame:90 - Target:undefined OK