Vizard 7 » Command Index » Vizard modules » viz » <viz:phys>.intersectLine
7.7

<viz:phys>.intersectLine

Intersects a line segment with physics shapes in the physics simulation

<viz:phys>.intersectLine(  
begin  
end  
all = False  
)  
begin
[x,y,z] start position of line segment
end
[x,y,z] end position of line segment
all = False
If true, returns a list of VizIntersect objects for all intersected physics shapes

Remarks

The parameters begin and end must both be cordinates in this form [x,y,z].

Return Value

A VizIntersect object.

Example

floor = viz.add('tut_ground.wrl')
shape1 = floor.collidePlane()
box = viz.add('box.wrl')
shape = box.collideBox()
def FireLine():
    line = viz.MainWindow.screenToWorld(viz.mouse.getPosition()+[0])
    dir = viz.Vector(line.dir)
    dir.setLength(200)
    begin = line.begin
    end = line.begin + dir
    info = viz.phys.intersectLine(begin,end)
    if info.valid:
        info.object.color(viz.BLUE)
vizact.onmousedown(viz.MOUSEBUTTON_MIDDLE,FireLine)

See also

<window>.screenToWorld
<node3d>.collideBox
<node3d>.collideNone