MeshProjIntersect - superclass: ReferenceTarget; super-superclass:MAXWrapper - 0:0 - classID: #(1266304708, 865233301)
This class exposes an interface that is used by the ProjectionMapping tools to find the projection of one mesh point onto another mesh.
MeshProjIntersect interfaces:
Interface: rayMeshProjIntersectOps
Methods:
<void>SetNode <node>node
Sets the node to perform the intersections on.Multiple nodes can be added to the same instance of the intersector interface. Use the GetHitNode() method to determine which of the nodes added to the intersector was hit.
<void>Build ()
Builds the internal data structures for fast intersections.This method has to be called after adding the nodes.
<void>Free ()
Removes the internal data structures, frees memory.
<boolean>ProjectionFace <integer>triIndex <point3 by value>triBary
Performs a face projection.
The triIndex
argument is the 0-based face index.
The triBary
argument specifies the barycentric coordinates of the point in the face.
Returns true on success, false if no valid projection could be performed.
When performing Projection Mapping, a low-resolution working model and a high-resolution reference model are used. A cage is defined around the working model which has to completely surround the reference model. Every point on the high-resolution reference model corresponds to a point on the low-resolution working model. There can be multiple reference modes for one working model.
To use this method,
Create an instance of the MeshProjIntersect
class.
Call SetNode()
passing the low-resolution working model and call Build()
to generate the acceleration data. It must have a Projection modifier applied.
The Projection modifier must have one or more reference models defined.
Call the ProjectionFace()
method with the face index and barycentric coordinates of any point on the surface of the working model.
As result, the ProjectionFace()
method sets the internal values to hits on the reference models. The method getHitNode()
will return the reference model that was hit, getHitFace()
will return the face index, getHitPos()
will return the position of the hit and so on.See further on this page for details.
<boolean>ClosestFace <point3 by value>point dir:<point3 by value>caged:<boolean> doubleSided:<boolean>
dir default value: [0,0,0]
caged default value: false
doubleSided default value: false
Returns the closest face to the given point is space.
If the optional dir:
keyword parameter is supplied and is not [0,0,0], the closest face in the given direction is detected.
If the optional doubleSided:
keyword parameter is supplied and is true, both facing and backfacing faces will be considered.
Returns true if a closest face has been found, false otherwise.
Currently, you have to call the IntersectRay()
method AT LEAST ONCE before calling the ClosestFace()
method - some internal structures required for closest face calculations are only initialized when performing intersections!The results from the IntersectRay()
call should not be trusted though. See warning further on this page.
<value>GetHitDist hitIndex:<integer>
hitIndex default value: -1
Returns the distance to the hit.
If the optional hitIndex:
keyword argument is not supplied or is supplied as -1, the closest hit is returned. If it is supplied and is a positive integer, the distance to the corresponding indexed hit is returned.See warning below.
After calling the ClosestFace()
method, you MUST NOT specify the hitIndex:
optional parameter when calling any of the following methods! There is only one possible closest face and attempting to pass a value other than -1 can cause instabilities or incorrect results.
<value>GetHitNode hitIndex:<integer>
hitIndex default value: -1
Returns the node that has been hit.
If the optional hitIndex:
keyword argument is not supplied or is supplied as -1, the node of the closest hit is returned. If it is supplied and is a positive integer, the node of the corresponding indexed hit is returned.
See previous warning regarding getting data after a ClosestFace()
call.
<value>GetHitFace hitIndex:<integer>
hitIndex default value: -1
Returns the ZERO-BASED index of the face that has been hit.
If the optional hitIndex:
keyword argument is not supplied or is supplied as -1, the closest face hit is returned. If it is supplied and is a positive integer, the face of the corresponding indexed hit is returned.
See previous warning regarding getting data after a ClosestFace()
call.
The face indexing can change between a geometry primitive and the Editable Mesh version of the same geometry. For example, a plane with just two faces would return a hit as face 0 when using the primitive geometry but 1 for the same hit when using a collapsed version of the same object.
This is normal but quite rarely visible throughMAXScript since no other methods provide access to the actual underlying geometry of primitives - the other intersection and mesh methods operate on objects already converted to mesh.
<value>GetHitBary hitIndex:<integer>
hitIndex default value: -1
Returns the barycentric coordinates of the hit.
If the optional hitIndex
: keyword argument is not supplied or is supplied as -1, the barycentric coordinates of the closest hit are returned. If it is supplied and is a positive integer, the barycentric coordinates of the corresponding indexed hit are returned.
See previous warning regarding getting data after a ClosestFace()
call.
<value>GetHitBackfacing hitIndex:<integer>
hitIndex default value: -1
Returns the backfacing hit.
If the optional hitIndex:
keyword argument is not supplied or is supplied as -1, the closest backfacing hit is returned. If it is supplied and is a positive integer, the corresponding indexed backfacing hit is returned.
See previous warning regarding getting data after a ClosestFace()
call.
<value>GetHitPos hitIndex:<integer>
hitIndex default value: -1
Returns the world position of the hit.
If the optional hitIndex:
keyword argument is not supplied or is supplied as -1, the position of the closest hit is returned. If it is supplied and is a positive integer, the position of the corresponding indexed hit is returned.
See previous warning regarding getting data after a ClosestFace()
call.
<boolean>IntersectRay <point3 by value>point <point3 by value>dir doubleSided:<boolean>
doubleSided default value: false
Performs a ray intersection with the nodes set using SetNode()
from the world space position defined by the point parameter in the direction of the vector specified by the dir parameter.
If the optional doubleSided:
keyword parameter is supplied and is true, intersections will be performed with both the front and the backside of the faces.
Returns true if the ray has hit any faces, false if there was no intersection.
This method is currently considered broken and should not be used to perform actual intersections. Under some circumstances it can return incorrect results.