INTRODUCTION TO
MOTIONLINKS
A motionlink connects a source of position and orientation
information to a target that will move corresponding to the data
read from the source object. Normally the source object of a
motionlink will be a sensor but it could also be path. The target
types for a motionlink can be a viewpoint, movable, transform, or
nodepath. The information for a motionlink is stored in a
WTmotionlink object.
Motionlinks are extremely easy to create, enable, disable, and
delete. While these are not the only functions that work with
motionlinks they are the ones we will cover here.
Creating a new motionlink
WTmotionlink_new
Creates a new motionlink object and connects a target to a
source of position/orientation information.
SYNTAX:
WTmotionlink *WTmotionlink_new(void *source, void
*target, int SOURCE_TYPE, int TARGET_TYPE);
ARGUMENTS:
source -- The source of the
position/orientation information this can be a pointer to
a sensor or path.
target -- The target of the position/orientation
information this can be a pointer to a viewpoint,
movable, transform,
or nodepath
SOURCE_TYPE -- One of the predefined types
WTSOURCE_SENSOR or WTSOURCE_PATH
TARGET_TYPE -- One of the predefined types
WTTARGET_VIEWPOINT, WTTARGET_MOVABLE, WTTARGET_TRANSFORM,
or WTTARGET_NODEPATH
RETURN TYPE:
A pointer to a type WTmotionlink
Assignment 11
project definition:
- Creates a universe with a bordered window in monoscopic
mode..
- Create a cylinder that has a height of 40, a radius of 5,
12 tessellation lines, is single sided and gouraud
shaded.
- Create a sphere with a radius of 10, 12 lat and long
divisions, is single sided, and gouraud shaded.
- Create a movable geometry node for the cylinder whose
parent is the root node.
- Create a movable geometry nodes for the sphere whose
parent is the root node.
- Create and instance of the movable node containing the
sphere as the 2nd child of the root node
- Set the translation of the movable geometry containing
the first sphere to (0,-20,0)
- Set the translation of the movable geometry containing
the second sphere to (0,20,0)
- Set the rgb color of the sphere to red (255,0,0)
- Set the rgb color of the cylinder to blue (0,0,255)
- Set the rendering style of the sphere geometry to
wireframe.
- Prebuild all the geometries
- Zooms the view in the window
- Create a task function that is associated with the node
containing the cylinder. The function should rotate the
cylinder in its parent reference frame around the Y axis
by 15 degrees each time through the simulation loop.
- Add the mouse to the universe as a sensor
- Attach the mouse to the viewpoint using a
motionlink
- Create an action function that allows the user to:
- press q to quit
- press p to print the scene graph from the root
node. (use WTnode print)
- press i to obtain the extents, midpoint, and
radius of each node
- press I to obtain the extents, midpoint, and
radius of each geometry.
- Press t to translate the spheres and cylinder
along their local X axis.
- Create a function that uses the WTnode_translate
function and takes as an argument the node to
translate, three floating point values for the
translation values, and the frame in which to
translate.
Enabling as Disabling Motionlinks
Every motionlink as an enabled property that can be set to
TRUE or FALSE. By disabling the motionlink the target is no
longer update with the source information. This is an easy way
for the user to remove a link and still keep it around for future
use. A good example of this would be toggling the mouse between
navigation mode and pick mode.
WTmotionlink_enable
Enables and disables a motionlink
SYNTAX:
void WTmotionlink_enable(WTmotionlink *link, FLAG
enabled);
ARGUMENTS:
link -- The motionlink in question
enabled -- If this argument is TRUE then the link is
enables if FALSE then the motionlink is disabled
RETURN TYPE:
void
Assignment 12
project definition:
- Creates a universe with a bordered window in monoscopic
mode..
- Create a cylinder that has a height of 40, a radius of 5,
12 tessellation lines, is single sided and gouraud
shaded.
- Create a sphere with a radius of 10, 12 lat and long
divisions, is single sided, and gouraud shaded.
- Create a movable geometry node for the cylinder whose
parent is the root node.
- Create a movable geometry nodes for the sphere whose
parent is the root node.
- Create and instance of the movable node containing the
sphere as the 2nd child of the root node
- Set the translation of the movable geometry containing
the first sphere to (0,-20,0)
- Set the translation of the movable geometry containing
the second sphere to (0,20,0)
- Set the rgb color of the sphere to red (255,0,0)
- Set the rgb color of the cylinder to blue (0,0,255)
- Set the rendering style of the sphere geometry to
wireframe.
- Prebuild all the geometries
- Zooms the view in the window
- Create a task function that is associated with the node
containing the cylinder. The function should rotate the
cylinder in its parent reference frame around the Y axis
by 15 degrees each time through the simulation loop.
- Add the mouse to the universe as a sensor
- Attach the mouse to the viewpoint using a motionlink
- Create an action function that allows the user to:
- press q to quit
- press p to print the scene graph from the root
node. (use WTnode print)
- press i to obtain the extents, midpoint, and
radius of each node
- press I to obtain the extents, midpoint, and
radius of each geometry.
- press t to translate the spheres and cylinder
along their local X axis.
- Create a function that uses the WTnode_translate
function and takes as an argument the node to
translate, three floating point values for the
translation values, and the frame in which to
translate.
- Press f on the keyboard to toggle the motionlink
from enabled to disabled and disabled to enabled.
You should also print a message to the user
indicating weather they are in pick or navigation
mode.