Open topic with navigation
<node3d>.intersect
Perform an intersection on the current node and the line segment
<node3d>.intersect( |
|
lineBegin |
lineEnd |
all = False |
mode = viz.REL_PARENT |
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.
mode = viz.REL_PARENT
Reference frame to perform the intersection test in. Can be one of the following values:
viz.ABS_PARENT viz.REL_PARENT | Perform the intersection in the parents coordinate system. |
viz.ABS_GLOBAL viz.REL_GLOBAL | Perform the intersection in the global coordinate system. |
viz.ABS_LOCAL viz.REL_LOCAL | Perform the intersection in the node local coordinate system. |
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 the node. 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:
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
floor = viz.add('tut_ground.wrl')
box = viz.add('box.wrl')
a = box.intersect([0,-1,0],[0,1,0])
a.object.color(viz.BLUE)
Sets the box blue.
See also