Purpose

The WEMRayIntersect allows to intersect a ray with WEM triangle patches. It uses a bounding volume hierarchy (BVH) internally to provide fast intersection. The first hit point is provided as field values. A list of all hit points is given as a marker list.

The precision of the ray intersection is only float precision, since the underlying Embree library does not (yet?) support double precision.

It is also possible to access the BVH wrapper on the outBVH field using:

bvh = ctx.field("outBVH").object()
result = bvh.rayIntersectClosest([30., 0., 0.], [-1., 0., 0.])

and cast rays from Python.

Another alternative is to not use the WEMRayIntersect module at all, but instead create the BVH in Python:

wem = ctx.field("SomeWEMModule.outWEM").object()
bvh = MLAB.createMLBaseObject("WEMBoundingVolumeHierarchy", [wem])
result = bvh.rayIntersectClosest([30., 0., 0.], [-1., 0., 0.])

For more details on scripting, have a look at the MLWEMBoundingVolumeHierarchyWrapper in the MeVisLab Scripting Reference.

Output Fields

outBVH

name: outBVH, type: WEMBoundingVolumeHierarchy(MLBase)
For accessing this object via scripting see the Scripting Reference: MLWEMBoundingVolumeHierarchyWrapper.

Parameter Fields

Field Index

Cast Ray: Trigger Intersect Mode: Enum
Direction: Vector3 Position: Vector3
Hit Bary Coord: Vector3 Ray Far: Float
Hit Face Index: Integer Ray Near: Float
Hit Face Normal: Vector3 Ready: Bool
Hit Patch Index: Integer Update: Trigger
Hit Position: Vector3  
Hit Valid: Bool  

Visible Fields

Intersect Mode

name: intersectMode, type: Enum, default: RemoveDuplicateHits

The intersection mode.

Values:

Title Name Description
All Hits AllHits This collects all hits, so it can contain duplicate hits on neighboring triangle edges or nodes.
Remove Duplicate Hits RemoveDuplicateHits This removes duplicate hits by checking if the hits are close to each other with some epsilon and if they are facing in the same direction regarding the ray direction.

Update

name: update, type: Trigger

Updates the BVH from the input WEM.

Ready

name: ready, type: Bool, persistent: no

Output if the module is ready for ray intersections.

Position

name: position, type: Vector3, default: 0 0 0

The ray origin.

Direction

name: direction, type: Vector3, default: 0 0 0

The ray start direction (should be normalized).

Ray Near

name: rayNear, type: Float, default: 0

The near distance on the ray (the intersection starts from position + direction * rayNear).

Ray Far

name: rayFar, type: Float, default: 3.4028235e+38

The far distance on the ray (the intersection stops at position + direction * rayFar).

Cast Ray

name: castRay, type: Trigger

Casts the ray.

Hit Valid

name: hitValid, type: Bool, persistent: no

Flag if hit is valid.

Hit Position

name: hitPosition, type: Vector3, persistent: no

The hit position (of the closest triangle).

Hit Face Normal

name: hitFaceNormal, type: Vector3, persistent: no

The face normal of the hit triangle.

Hit Bary Coord

name: hitBaryCoord, type: Vector3, persistent: no

The barycentric coordinate on the triangle.

Hit Face Index

name: hitFaceIndex, type: Integer, persistent: no

The face index of the triangle.

Hit Patch Index

name: hitPatchIndex, type: Integer, persistent: no

The WEM patch index of the triangle.