A vizproximity sensor detects when a target is within range. A sensor has both an area and a transformation matrix. The area is determined by a sensor shape while the transformation matrix is based on a source object or fixed location. There are two categories of shapes; 3D shapes and area shapes.
The following image shows sensors based on 3D shapes. The 3D shapes available are box, sphere, or any combination of these:
A. Sphere sensor and ball
B. Box sensor and plant
C. Sphere sensor and avatar head bone
D. Composite sensor and static matrix
The following image shows examples of sensors based on area shapes. Area shapes are not represented with height because they continue indefinitely along the Y axis. The area shapes available are path, polygon, rectangle, and circle:
A. Path sensor
B. Polygon sensor
C. Rectangle sensor
D. Circle sensor
The following command creates a Sensor object:
Command |
Description |
vizproximity.Sensor(shape, source) |
The area of the sensor is determined by the specified shape. The sensors position is determined by the specified source object (e.g. node, view, tracker, bone, matrix) |
Use the following commands to create 3D sensor shapes:
Command |
Description |
vizproximity.Box(size, center=(0.0,0.0,0.0)) |
Box shape. |
vizproximity.Sphere(radius, center=(0.0,0.0,0.0)) |
Spherical shape. |
vizproximity.CompositeShape(shapes) |
Shape composted of multiple shapes. shapes is a list that can contain any number of Box, Sphere, or CompositeShape objects. |
Use the following commands to create area shapes. Area shapes extend indefinitely along the Y axis and are defined using only X,Z coordinates:
Command |
Description |
vizproximity.CircleArea(radius, center=(0.0,0.0) |
Circular area shape. |
vizproximity.RectangleArea(size, center=(0.0,0.0) |
Rectangular area shape.
|
vizproximity.PolygonArea(points, offset=(0.0,0.0) |
Polygonal area shape. points: A list that contains the polygon vertices. offset: Applies a position offset to the polygon. |
vizproximity.PathArea(points, radius, offset=(0.0,0.0) |
Path area shape. points: A list of points that defines the centerline of the path. radius: Distance from the path centerline to path edge. offset: Applies a position offset to the path. |
In addition to the Sensor command, the following utility functions can be used to create sensors using bounding shapes:
Command |
Description |
vizproximity.addBoundingBoxSensor(node, name='', scale=(1.0,1.0,1.0)) |
Create a proximity sensor using the bounding box of a node. name: Name of sub-node to use for the bounding box. scale: Scale factor to apply to computed bounding box size. |
vizproximity.addBoundingSphereSensor(node, name='', scale=1.0) |
Create a proximity sensor using the bounding sphere of a node. name: Name of sub-node to use for the bounding sphere. scale: Scale factor to apply to computed bounding sphere radius. |
The following methods can be called on a Sensor object:
Method |
Description |
<Sensor>.containsPoint(point) |
Return whether the sensor contains the specified point. |
<Sensor>.getShape() |
Return the shape object of the sensor. |
<Sensor>.getSource() |
Return the source object of the sensor. |
<Sensor>.getSourceObject() |
Return the underlying object of the sensor source (e.g. node, view, bone, etc..). |
The examples below shows how to create sensors using a variety of source objects:
Bounding sphere of node
Bounding Box of sub-node
Sphere with avatar bone
Box with tracker link
Composite with group node
Sphere with static matrix
Circle area with avatar
Rectangle area at fixed location
Polygon area at fixed location
Path area at fixed location