Vizard 7 » Command Index » Vizard modules » viz » <viz>.intersect
7.6

<viz>.intersect

This command will intersect a line segment with the world

<viz>.intersect(  
lineBegin  
lineEnd  
all = False  
ignoreBackFace = False  
computePath = False  
ignoreClipped = False  
)  
lineBegin
[x,y,z] position of begin point of intersection line segment.
lineEnd
[x,y,z] position of end point of intersection line segment.
all = False
If True, causes intersect to return a list of intersect objects for all intersections, not just the first.
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

This command checks if the specified line segment intersects with any objects in the scene. It will return a viz.Intersect object containing info about the intersection results.

Nodes that have viz.INTERSECTION 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

The return value is a viz.Intersect object or a list of viz.Intersect objects if parameter all is true.

The following is a list of fields of the viz.Intersect object:

Attribute

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.

Example

info = viz.intersect([0,0,0],[0,0,4])
if info.valid:
    print('Intersected with object id:', info.object.id)
    print('Intersected at location: ', info.point)

See also

<viz>.pick
<window>.screenToWorld
<window>.worldToScreen