Notifications
Clear all

[Closed] Maxscript – RayIntersect – Get FACE-ID

Hello All,

i am working on a little script to help with rigging for our team. The objective is allow an object to slide along the surface, and change orientation and position to maintain contact with the give surface.

I wrote a line-by-line workflow, nothing is wrapped into a function, just yet.

here is the code and some comments:

glassSurface = $glass – This is my surface that i am tracking for
eye = $eye – this is object that needs to be aligned with glassSurface (position and orientation)

rayToMesh = ray eye.pos [0,0,-1] – shooting ray from my mesh(eye) DOWN (negative Z)
zPos = intersectRay glassSurface rayToMesh –getting the location of the intersection as vector3
eye.pos.z = (zPos.pos.z + 0.005) – adjusting the Z-Position of the eye-mesh

This is all working as i expect, but i need to set the rotation on my EYE-mesh, and to do this, i need to get the FaceNormalDirection from the FACE, at which the
intersectRay happens.

How would i go about getting that FACE-ID ? – This is main question.
polyOps or MeshOps – GetFace – needs to have the MESH(glassSurface) and the FACE-ID to get the face, but i dont have that information at hand.

Once i get the face – i can then get its normals, and give the eye.dir – a proper orientation.

any help/tips appreciated. Ask question if you need more info!

Thanks for the time guys!

2 Replies

I was looking at the
mouseTrack

and in docs, the return can be a FACENUM, but i am not in need of the moustrack. just the facenum of the IntersectRay.

Thanks,

ok, i figured it out. Was not paying enough attention to the output of the IntersectRay.

in addition to the Position Vector that i get, if i ask
myReturnedRay.dir
it returns the Direction of the normal, of the face, that was intersected, which is what i needed.