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:
| User clicks on, or rolls mouse pointer over object to trigger event | |
| User clicks and drags to move an object in the local X-Y plane (left-right, up-down) | |
| User clicks and drags to rotate an object around its Y (up-down) axis | |
| User clicks and drags to rotate an object freely around all axes | |
| Event is triggered when user enters a specified zone | |
| Event is triggered when object enters or exits the user's view | |
| 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. | |
| 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
Download and unzip the following file (using WinZip) into the relevant folder of your working directory.
camera_animated.zip (46.6Kb)
This file contains:
- camera_animated.wrl
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
|
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 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
|
![]() |
|
To complete the route expand 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 |
![]() |
|
If you make a mistake with a route you simply hold down |
|
| 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 |
|
|
Expand 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°. |
![]() |
back to top | return to Complex Interations