Links make the source object's transform, or position/orientation/scale matrix, the destination object's transform. In addition, Vizard links also allow for some manipulation of the source's transform before it is given to the destination object.
The viz.link(source, destination) command creates a task every frame to copy the transform matrix of the source to the destination.
The viz.link command returns a link object that exposes a number of functions for modifying the behavior of the destination object.
By setting the "mask" of the link, the destination takes a specific combination of position, orientation and scale of the source. Below, we create a link that only affects the orientation of the destination.
If you want to use the destination object of a link as the source object of another link, use the link object instead. For example, take the chain of objects tracker > node1 > node2. First the link is established between tracker and node1:
Rather than link node2 to node1:
node2 is linked to link1:
The example code below demonstrates the correct method for creating a chain of links:
Source and destination objects have some object-specific options available to them with the <link>.setDstFlag and <link>.setSrcFlag methods. The specific flags are only applicable to specific linkable types. For example, geometry node objects have a viz.ABS_GLOBAL link flag option. When this flag is set as a source flag with <link>.setSrcFlag, the link retrieves the transform from the source node in absolute world coordinates. When this flag is set as a destination flag with <link>.setDstFlag, the transform is applied in absolute world coordinates. This is useful when a source or destination is a child of another object.
Linking objects to sensors is an easy way to use the position and orientation data provided by tracking devices. This is useful if you want to "zero out," or reset the reference frame of the sensor data. Links have a built-in reference frame setting capability with their <link>.reset command. The reset command can zero the position and orientation of sensors.
Position reset works by calling the <link>.setOffset(x,y,z) command. The link offset moves the position of destination in it's parent's reference frame before any operators are applied. Therefore, calls to <link>.setOffset will overwrite position resets. Orientation resets are implemented through the creation of an operator. A call to <link>.reset( viz.RESET_OPERATORS ) will remove the orientation reset.
Geometry nodes added to the orthographic screen can link to a position on the screen. This gives orthographic nodes resolution independent positioning. The possible link locations are the corners, the midpoints on each screen side, and the center.
You can also apply the source orientation data from one object and the position data from another to a destination node. For an example script, see the \examples\linking\mergeLinking.py script. In this example, the orientation information comes from the blue marker, while the position information is provided by the red marker. The viz.mergeLinkable( positionSource, orientationSource ) command creates a linkable object that gets its position and orientation from two different nodes.
If you would like to setup a "grab" like relationship between nodes, use the viz.grab(handNode, grabbedNode) function. The link created with viz.grab preserves the position and orientation of the grabbed object relative to the hand. An example script is located at \examples\linking\grabbing.py.
The <link>.remove command deletes the link object and ends the link relationship. If you just want to temporally suspend the link, then you can use the <link>.disable and <link>.enable functions.
Linking Basics- Introduction to linking.
Operators on Links- More operator examples and implantation discussion.
Link Command Table- List of relevant link commands.
Transform Basics- Introduces the position/orientation/scale matrix associated with all 3D nodes.