[Closed] Interface: rayMeshGridIntersectOps
anyone knows how to use this new-in-3dsmax6 and “advanced” interface to intersect something with meshes? i ve found this and tried,failed. The interface introduction has not any example,frustrating. :banghead:
thanx,
javabeans
The latest update of the Help for 7.5 has at least all methods documented. If you don’t have it, grab it from the Discreet site!
ftp://ftp.discreet.com/pub2/web/products/3dsmax/maxscript75_updated_help.exe
I am trying to come up with some useful example for the next update…
Here is an example:
(
resetMaxFile #noprompt --reset the scene
theSphere = Sphere radius:40 segs:50 pos:[100,200,300] --create a sphere
theGeoSphere = Geosphere radius:100 segs:3 pos:[100,200,300] --create a geosphere
theFacesArray = #() --init. an array to collect face selection
rm = RayMeshGridIntersect() --create an instance of the Reference Target
rm.Initialize 10 --init. the voxel grid size to 10x10x10
rm.addNode theSphere --add the sphere to the grid
rm.buildGrid() --build the grid data (collecting faces into the grid voxels)
theGSMesh = snapshotasmesh theGeoSphere --grab the TriMesh of the Geosphere
for v = 1 to theGSMesh.numverts do --go through all verts of the Geosphere
(
thePos = getVert theGSMesh v --get the position of the vertex
theNormal = -(getNormal theGSMesh v) --get the normal of the vertex, reverse direction
theHitsCount = rm.intersectRay thePos theNormal false --intersect the ray with the sphere
if theHitsCount > 0 then --if have hit anything...
(
theIndex = rm.getClosestHit() --get the index of the closest hit by the ray
theFace = rm.getHitFace theIndex --get the face index corresponding to that indexed hit
append theFacesArray theFace --add to the face array to select the face...
)
else
format "The Ray % Missed
" v
)
ms = mesh_select() --create a mesh select modifier
addModifier theSphere ms --add on top of the sphere
select theSphere --select the sphere
max modify mode --go to modify panel
setFaceSelection theSphere 1 theFacesArray --set the selection in the MeshSelect
subObjectLevel = 3 --go to face selection level
)
This creates a sphere and a geosphere, then it shoots rays from each vertex of the geosphere and selects those faces that are being hit on the sphere’s surface.
You could use the IntersectRay method to do the same, but this should be much much faster, especially with hi-res meshes with hundreds of thousands of polygons…
thanks a lot for your detailed and heartly help. i appreciate this so much.
regards
javabeans