[Closed] use maxscript ,how to align vertex to face
Hello everyone
I have a question ,use maxscript, how to align vertex to face
Here is a routine that compute the intersection between a plane and a line.
fn planeVectorIntersection planeVert planeNormal projPoint projVector=
(
d=-((planeNormal.x*planeVert.x)+(planeNormal.y*planeVert.y)+(planeNormal.z*planeVert.z))
r=( -( (planeNormal.x*projPoint.x)+(planeNormal.y*projPoint.y)+(planeNormal.z*projPoint.z)+d ) )/( (planeNormal.x*projVector.x)+(planeNormal.y*projVector.y)+(planeNormal.z*projVector.z) )
[projPoint.x+(projVector.x*r),projPoint.y+(projVector.y*r),projPoint.z+(projVector.z*r)]
)
It’s probably a part what you need.
planeVert is a vertex of the face
planeNormal is the normal of the face
projPoint is your point3
projVector is the axis of the projection, for example z=[0,0,1]
the function return the intersection (point3)
Hope this helps a bit.
You can just use Maxscript’s built in function for line/plane intersection, IntersectRay:
oPlane = $YourPlaneObject
MyRay = ray [pos.x,pos.y,pos.z] [dir.x,dir.y,dir.z]
newray = intersectRay oPlane MyRay
if (newray != undefined) do
(
–Place vertex at intersection point
setVert oObject nIndex newray.pos
)
Just look up IntersectRay and IntersectRayEX in the maxscript reference.
Good luck,
Todd Kuehnl
Rapid-TD