Open topic with navigation
<viz>.pick
This command returns the current geometry object that the mouse is pointing at
<viz>.pick( |
|
info = False |
mode = viz.WORLD |
pos = [-1,-1] |
eye = viz.BOTH_EYE |
all = False |
ignoreBackFace = False |
computePath = False |
ignoreClipped = False |
) |
|
info = False
If the value is True, it causes the pick command to return a VizIntersect object.
mode = viz.WORLD
This flag specifies whether to perform the pick operation on the world or screen. This can be either viz.WORLD or viz.SCREEN
pos = [-1,-1]
Position on screen to perform pick, in normalized units. If this is not specified then the current mouse position will be used.
eye = viz.BOTH_EYE
The eye to perform the picking on. Can be viz.BOTH_EYE, viz.LEFT_EYE, viz.RIGHT_EYE. If stereo mode is enabled, the command will automatically adjust the mouse coordinates for the specified eye.
all = False
If True, this command will return all the intersections, not just the first one.
ignoreBackFace = False
If True, back facing polygons will be ignored during the intersection test.
computePath = False
If True, the name_path and object_path attributes of the viz.Intersect object will be computed.
ignoreClipped = False
If
True, intersections that are clipped by clip planes (
<node3d>.clipPlane) will be ignored.
Remarks
If info is False, this command will return a node3d object that the mouse is pointing at, unless picking was disabled on the node3d object.
If info is True, this command will return a VizIntersect object.
The following is a list of fields of the
viz.Intersect object:
valid | True if an intersection occurred, False if it didn't. |
point | The point of intersection with the object. |
normal | The normal vector of the intersect point. |
object | The node3d object that was intersected. This will be the lowest level node3d object within the scene hierarchy. You can prevent specific nodes from appearing as the intersect object by disabling viz.INTERSECT_INFO_OBJECT on them. In this case, the first parent node with this attribute enabled will be reported as the intersect object. |
name | The name of the sub-node that was intersected. |
object_path | A list of node3d objects representing the full path to the intersected object within the scene hierarchy. This value is only computed if the computePath option is True. |
name_path | A list of sub-node names representing the full path to the intersected object within the scene hierarchy. This value is only computed if the computePath option is True. |
Nodes that have
viz.PICKING disabled will not appear in the results.
Intersection tests can be optimized for certain nodes by using the
viz.OPTIMIZE_INTERSECT_HINT flag with the
<node3d>.hint command. This hint can significantly increase memory usage though.
Return Value
<node3d:geometry> object or VizIntersect object, depending on specified mode
Example
node = viz.pick()
if node.valid():
print('The mouse is over a geometry object')
See also