I would like to simply have a start position and direction. Then check if that vector hits an object/polygon.
Below is how the code used to be structured
dag = nameToDag(mesh_name)
meshFn = om.MFnMesh()
meshFn.setObject( dag )
#This is the Ray being shot
raySource = om.MPoint(source[0])
rayDirection = om.MVector(source[1])
pointsValue = om.MPointArray()
polygonIdsValue = om.MIntArray()
spaceValue = 4
toleranceValue = 0.01
intersectionPoints = om.MFloatPointArray()
ret = om.MFnMesh.intersect(meshFn, raySource, rayDirection.normal(),
pointsValue, toleranceValue, spaceValue, polygonIdsValue )
Now I tried replacing it with:
meshFn.allIntersections( raySource, # raySource - where we are shooting the ray from.
rayDirection, # rayDirection - the direction in which we are shooting the ray.
None, # faceIds - here, we do not care if specific faces are intersected)
None, # triIds - here, we do not care if specific tri's are intersected)
False, # idsSorted - here, we do not need to sort the faceId's or triId's indices.
om.MSpace.kTransform, # coordinate space - the mesh's local coordinate space.
float(9999), # the range of the ray.
False, # testBothDirections - we are not checking both directions from the raySource
None, # accelParams - this object is not applicable here.
False, # sortHits - we do not need to sort the intersection points along the ray.
intersectionPoints, # hitPoints - the array of points which have been intersected.
None, # hitRayParams - we do not need any parametric distances of the points along the ray.
None, # hitFaces - we do not need the id's of the faces intersected.
None, # hitTriangles - we do not need the id's of the triangles intersected.
None, # hitBary1s - we do not need the barycentric coordinates of the points within the triangles.
None, # hitBary2s - we do not need the barycentric coordinates of the points within the triangles.
toleranceValue # tolerance - a numeric tolerance threshold which allow intersections to occur just outside the mesh.
but it is giving the error:
# Error: TypeError: file <maya console> line 100: function takes at most 11 arguments (17 given) #
Can anyone give a basic working example with a plane, or explain what the problem is?
Thanks