IBMPlaneSensor2D
IBMPlaneSensor2D.mp4
Description
A Rectangle shape can be dragged by use of a PlaneSensor2D whose translation_changed output is routed to the
translation field of the Transform2D containing the rectangle. The check boxes at the top left of the screen
allow the PlaneSensor2D's enabled and autoOffset fields to be set true or false. When disabled the rectangle
cannot be dragged.
The translation_changed, trackPoint_changed and offset from the PlaneSensor2D are routed via Valuators, to
convert the values to strings, so they can be displayed in Text nodes at the top of the screen. Offset will
be set after dragging, when the mouse is released, but only when autoOffset is set true.
The radio buttons at the bottom of the screen allow the PlaneSensor2D's minPosition and maxPosition to be set.
When a button is selected the translation of the rectangle is set back to (0,0) and the offset is set back to
(0,0) too so its back in the center and will commence dragging from there.
There are six min/max position values which affect the bounds over which the rectangle can be dragged:
- (0,0) (-1,-1) Rectangle dragging is unbounded as PlaneSensor2D maxPosition (x,y) is less than
minPosition (x,y) so translation_changed values are unconstrained.
- (-150,-150) (150,150) Rectangle is bounded to positions in the range -150 <= x <= 150, -150
<= y <= 150.
- (0,-150) (0,150) Rectangle is constrained to x=0 and -150 <= y <= 150 so it has limited
movement up and down along the y-axis.
- (-150,0) (150,0) Rectangle is constrained to -150 <= x <= 150 and y=0 so it has limited
movement left and right along the x-axis.
- (0,0) (0,-1) Rectangle can move up and down with no constraint.
- (0,0) (-1,0) Rectangle can move left and right with no constraint.
The translation_changed will reflect the above limits as can be seen by dragging the shape and observing the
values. When bounded the x and/or y value should never go outside of any bounds that have been set via the
minPosition and maxPosition.
Screenshot
Snapshot taken during dragging
Back to main index