A tool for grabbing objects in the scene. The following command creates a Grabber object:
Command |
Description |
grabber.Grabber(usingPhysics=True, usingSprings=True, highlightMode=highlighter.MODE_OUTLINE) |
usingPhysics: This should be set to True if used in an environment with physics enabled. When set to True, an invisible collide sphere at the grabber location is used for detecting intersections. Otherwise, a distance test is used for detecting intersections. usingSprings: Specifies whether or not springs are used for grabbing. highlightMode: Can be highlighter.MODE_ARROW, highlighter.MODE_OUTLINE, highlighter.MODE_BOX |
The following methods are available on the Grabber object:
Method |
Description |
<Grabber>.grab() |
Activates the grabber and grabs the nearest intersecting object. |
<Grabber>.grabAndHold() | Activates the grabber and grabs the nearest intersecting object. The command should be called on subsequent frames to hold the object. |
<Grabber>.getIntersection() |
Returns the nearest intersecting object. |
<Grabber>.release() |
Releases the grabbed object. |
<Grabber>.addItems(items) |
Adds objects to the grab list. items: a list of Vizard nodes. |
<Grabber>.setItems(items) |
Sets which objects in the scene the grabber is allowed to grab. items: a list of Vizard nodes. |
<Grabber>.removeItems(items) |
Removes objects from the grab list. items: a list of Vizard nodes. |
<Grabber>.remove() |
Releases any object grabbed and removes the grabber. |
<Grabber>.setUpdateFunction(updateFunction) |
Sets the update function that gets called every frame. The update function calls methods on the tool based on the state of input devices. |
The following events will get triggered when a grab, release, or intersection occurs:
Event |
Description |
grabber.GRAB_EVENT |
This event is generated when an object is grabbed. It provides a single event structure e with the following attributes: e.object: The grabber object e.grabbed: The object grabbed |
grabber.RELEASE_EVENT |
This event is generated when an object is released. It provides a single event structure e with the following attributes: e.object: The grabber object e.released: The object released |
grabber.UPDATE_INTERSECTION_EVENT |
This event is generated when the object intersecting the grabber changes. It provides a single event structure e with the following attributes: e.object: The grabber object e.new: The object currently intersecting the grabber. Returns None if there is no object. e.old: The object that previously intersected with the grabber. Returns None if there was no object. |