Tutorial Home / Complex Interactions / Creating Drag Sensors

return to Complex Interations


Overview

There are many types of sensors that can be built into your Synthetic Environments. You will recall that in the last section we created a TouchSensor when we animated the battery cover. This is the most commonly used sensor in VRML.

Sensors must be "wired up" or routed to something to have any effect. The Keyframe Animator created all the necessary sensors and routes for us in the last exercise. This time we'll be wiring up our own sensors using the Outline Editor.

The available sensors are:

TouchSensor User clicks on, or rolls mouse pointer over object to trigger event
PlaneSensor User clicks and drags to move an object in the local X-Y plane (left-right, up-down)
CylinderSensor User clicks and drags to rotate an object around its Y (up-down) axis
SphereSensor User clicks and drags to rotate an object freely around all axes
ProximitySensor Event is triggered when user enters a specified zone
VisibilitySensor Event is triggered when object enters or exits the user's view
TimeSensor When activated by one of the above sensors or a script the TimeSensor outputs the absolute time plus fractional values between 0.0 and 1.0 for a specified duration. It is used to "drive" animation interpolators.
Collision* Not technically a sensor at all but a special grouping node. It does, however, generate output events when the user collides with the group so it is worth mentioning with the other sensors.

All the above sensors can be found on the Create Extras toolbar (View Menu > Toolbars > Create Extras).

For this exercise we are only concerned with the first 4 (touch and drag) sensors. To attach one of these sensors to an object simply select both the sensor and the object and Group them together.

Note: As most sensors are not visible in the viewport you must select them in the Outline Editor.

back to top | return to Complex Interations


Required Files

Download and unzip the following file (using WinZip) into the relevant folder of your working directory.

camera_animated.zip (46.6Kb)

This file contains:

Note: memstick_textured.wrl and battery_textured.wrl are no longer included in the zip archive as it is assumed you already have them in the models folder of your working directory.

back to top | return to Complex Interations


Tutorial

Launch Cosmo Worlds and Open the file camera_animated.wrl

We are going to create and "wire up" a CylinderSensor to allow the user to rotate the lens of the camera.

Create a CylinerSensor by clicking on the icon on the Create Extras toolbar.

The sensor will not be visible in the viewport but you'll be able to see it at the bottom of the scene graph in the Outline Editor as shown.

Drag the CylinderSensor up the scene graph.
Drop it under the Transform that we named lensRotationGroup.

Expand the CylinderSensor node and click on the arrow next to rotation_changed. The arrow will turn red indicating we have started our route.

denotes the field outputs values
denotes the field accepts input values
denotes the field is both outputs and accepts input values (exposed field)

To complete the route expand the Transform named lensRotationGroup, click on the detail icon to see all the currently unused properties then click on the input arrow of rotation.

A line joining the 2 properties (rotation_changed to rotation) indicates a successful route.

Note: see that the 2 properties are of the same type (rotation). This is indicated by the icon on the left of the property. You can only route properties that are of the same type.

If you make a mistake with a route you simply hold down and click on one of the end points of the route to delete it.

 
If you are half-way through a route and change your mind then click on the Clear Well button under the Outline Editor.
If you Preview your work now you should be able to click and drag on the lens to rotate it 360°. Now we have to constrain the rotation to 180° only.  

Expand the CylinderSensor and click on the detail icon

In the fields minAngle and maxAngle enter 0 and 3.14 respectively as shown.

Note: You will recall from the Background tutorial that angles are measured in radians and 3.14 radians = PI = 180°.

Save your work.  
Preview in Cosmo Player.  

back to top | return to Complex Interations