Detects when the user has pointed at a specific piece of geometry. More...
#include <Inventor/VRMLnodes/SoVRMLTouchSensor.h>
Public Member Functions | |
virtual SoType | getTypeId () const |
SoVRMLTouchSensor () | |
virtual SbBool | affectsState () const |
Static Public Member Functions | |
static SoType | getClassTypeId () |
static void | enableEvents (SbBool OnOffFlag) |
static SbBool | isEventsEnabled () |
Public Attributes | |
SoSFBool | enabled |
SoSFString | description |
SoSFVec3f | hitNormal_changed |
SoSFVec3f | hitPoint_changed |
SoSFVec2f | hitTexCoord_changed |
SoSFBool | isActive |
SoSFBool | isOver |
SoSFTime | touchTime |
A SoVRMLTouchSensor tracks the location and state of the pointing device and detects when the user points at geometry contained by the SoVRMLTouchSensor's parent group. This sensor can be enabled or disabled by sending it an enabled event with a value of TRUE or FALSE. If the SoVRMLTouchSensor is disabled, it does not track user input or send output events.
NOTE: This class does not exist in Open Inventor 10.0 and later.This section may reference portions of the VRML97 specification that are not present in this help file. The complete VRML97 spec is available at http://www.web3d.org .
A SoVRMLTouchSensor tracks the location and state of the pointing device and detects when the user points at geometry contained by the SoVRMLTouchSensor's parent group. This sensor can be enabled or disabled by sending it an enabled event with a value of TRUE or FALSE. If the SoVRMLTouchSensor is disabled, it does not track user input or send output events.
The SoVRMLTouchSensor generates events as the pointing device "passes over" any geometry nodes that are descendants of the SoVRMLTouchSensor's parent group. Typically, the pointing device is a 2D device such as a mouse. In this case, the pointing device is considered to be moving within a plane a fixed distance from the viewer and perpendicular to the line of sight; this establishes a set of 3D coordinates for the pointer. If a 3D pointer is in use, then the SoVRMLTouchSensor generates events only when the pointer is within the user's field of view. In either case, the pointing device is considered to "pass over" geometry when that geometry is intersected by a line extending from the viewer and passing through the pointer's 3D coordinates. If multiple surfaces intersect this line (hereafter called the bearing), only the nearest will be eligible to generate events.
The isOver eventOut reflects the state of the pointing device with regard to whether it is over the SoVRMLTouchSensor's geometry or not. When the pointing device changes state from a position such that its bearing does not intersect any of the SoVRMLTouchSensor's geometry to one in which it does intersect geometry, an isOver TRUE event is generated. When the pointing device moves from a position such that its bearing intersects geometry to one in which it no longer intersects the geometry, or some other geometry is obstructing the SoVRMLTouchSensor's geometry, an isOver FALSE event is generated. These events are generated only when the pointing device has moved and changed `over state; events are not generated if the geometry itself is animating and moving underneath the pointing device.
As the user moves the bearing over the SoVRMLTouchSensor's geometry, the point of intersection (if any) between the bearing and the geometry is determined. Each movement of the pointing device, while isOver is TRUE, generates hitPoint_changed, hitNormal_changed, and hitTexCoord_changed events. hitPoint_changed events contain the 3D point on the surface of the underlying geometry, given in the SoVRMLTouchSensor's coordinate system. hitNormal_changed events contain the surface normal vector at the hitPoint. hitTexCoord_changed events contain the texture coordinates of that surface at the hitPoint, which can be used to support the 3D equivalent of an image map.
If isOver is TRUE, the user may activate the pointing device to cause the SoVRMLTouchSensor to generate isActive events (e.g. press the primary mouse button). When the SoVRMLTouchSensor generates an isActive TRUE event, it grabs all further motion events from the pointing device until it releases and generates an isActive FALSE event (other pointing device sensors will not generate events during this time). Motion of the pointing device while isActive is TRUE is referred to as a "drag". If a 2D pointing device is in use, isActive events will typically reflect the state of the primary button associated with the device (i.e., isActive is TRUE when the primary button is pressed, and FALSE when not released). If a 3D pointing device is in use, isActive events will typically reflect whether the pointer is within or in contact with the SoVRMLTouchSensor's geometry.
The eventOut field touchTime is generated when all three of the following conditions are true:
See "Concepts - Pointing Device Sensors" for more details.
enabled | TRUE |
description | "" |
metadata | NULL |
SoSFBool | set_enabled |
SoSFBool | set_description |
SoSFNode | set_metadata |
SoSFString | description_changed |
SoSFBool | enabled_changed |
SoSFVec3f | hitNormal_changed |
SoSFVec3f | hitPoint_changed |
SoSFVec2f | hitTexCoord_changed |
SoSFBool | isActive |
SoSFBool | isOver (Note: Not implemented) |
SoSFTime | touchTime |
SoSFNode | metadata_changed |
SoVRMLTouchSensor::SoVRMLTouchSensor | ( | ) |
Constructor.
virtual SbBool SoVRMLTouchSensor::affectsState | ( | ) | const [virtual] |
Returns TRUE if a node has an effect on the state during traversal.
The default method returns TRUE. Node classes (such as SoSeparator) that isolate their effects from the rest of the graph override this method to return FALSE.
Reimplemented from SoNode.
static void SoVRMLTouchSensor::enableEvents | ( | SbBool | OnOffFlag | ) | [static] |
Enables/disables events for all SoVRMLTouchSensor objects.
If you have created several objects of this class, you can disable/enable events for all of them with a single call to this method.
static SoType SoVRMLTouchSensor::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoVRMLNode.
Reimplemented in SoVRMLGeoTouchSensor.
virtual SoType SoVRMLTouchSensor::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoVRMLNode.
Reimplemented in SoVRMLGeoTouchSensor.
static SbBool SoVRMLTouchSensor::isEventsEnabled | ( | ) | [static] |
Queries if events are enabled for all objects of this class.
String that describes the sensor. NOTE: field available since Open Inventor 5.0
NOTE 2: This field is not compatible with VRML97. If you specify a non-default value for this field, when this node is written to a VRML file, the file will contain this incompatible field and standard VRML97 file readers will not be able to read it.
Enables (TRUE) or disables (FALSE) the sensor.
Output event sent when cursor is on shape.
Output event sent when cursor on shape.
Output event sent when cursor on shape.
Output event sent on button press/release.
Output event sent when cursor on shape.
Output events sent on button release.