[Closed] Detecting intersection?
Hi, I have a plane-rectangle etc. and I’m trying to provide a position to see if it is within the plane or not. This will all happen on the 2D floor, so no Z axis is used. I couldn’t find how to detect intersections in the reference, and I’m sorta new to maxscript, so is there a command for it?
Since you’re not concerned with the off-plane (z) axis, and you’re testing whether the point is within a rectangular area, I’d say your best bet is to construct a box2 using the plane’s x/y min/max and use contains() to see whether the [x,y] of the point is within the plane:
fn isWithinPlane pt pln =
(
pt_2d = point2 pt.x pt.y
pln_box2 = box2 (point2 pln.max.x pln.max.y) (point2 pln.min.x pln.min.y)
return contains pln_box2 pt_2d
)
Originally posted by gopherCG
Hi, I have a plane-rectangle etc. and I’m trying to provide a position to see if it is within the plane or not. This will all happen on the 2D floor, so no Z axis is used. I couldn’t find how to detect intersections in the reference, and I’m sorta new to maxscript, so is there a command for it?
In addition, you could also do a REAL intersection test using the IntersectRay function which provides ray-to-mesh “collision detection”.
Check out the “How To” tutorials in the MAXScript Online Help 5.x.
There is one showing how to move objects down to an arbitrary surface by projecting a ray from the objects’ pivot points to the surface of a mesh. You might find the way useful.
Btw, when the IntersectRay returns undefined, there is no intersection and you know the point does not reside on the tested mesh. When there is an intersection, you will get both the world coordinate the ray hit the surface and the normal at that point.
The nice thing about this method is that you can test against ANY surface, not only a flat rectangular plane (a Primitive, an EMesh or EPoly, a NURBS surface, a Patch, anything with polygons!).
Hope this helps.
Cheers,
Bobo
Of course Bobo’s answer fits a more comprehensive set of cases. I was only suggesting another way to get at the solution since the described case doesn’t seem to require a true intersect test:)
RH
Hey, thanks! So I either think of a plane as a box, or a point as a ray.
I’ll use rectangles mostly, but I might use triangles, trapezoids etc.
FYI, this script I’m creating is for semi-automatically constructing a city for my short animation. Bobo, I’ll be using lots of stuff I learned from your tutorials, so thanks again!
Originally posted by gopherCG
Bobo, I’ll be using lots of stuff I learned from your tutorials, so thanks again!
You are welcome!
:wavey:
Did I get it right (read fast, may missed some details)? Do u want to detect a collision of an object on a floor? Well, u don’t have necessary detect it. If the floor is z=0 then just detect if the object’s z is bigger then 0 or not.
Mmmm… that’s good for points not for volumes… oops
Originally posted by Artist 3D
[B]Did I get it right (read fast, may missed some details)? Do u want to detect a collision of an object on a floor? Well, u don’t have necessary detect it. If the floor is z=0 then just detect if the object’s z is bigger then 0 or not.Mmmm… that’s good for points not for volumes… oops [/B]
Nope, he is conserned about the other two axes – is the point inside a rectangle?
Since the floor could be any shape, I proposed to get the intersection with the foor’s mesh and see if a face is hit or not. This would let you detect a point inside an arbitrary shape, for example you could take a Text shape, turn into mesh and check whether a point is inside a letter’s meshed areas or not, and still detect the holes in the Bs and Os… (especially if the text reads “Bobo”)
Cheers,
Bobo
First off, sorry to invade and resurrect this ole thread, but this could be cool.
Do you think I could detect the self intersection of this animated wave, (a loft with animated paths) and somehow pass this on to PFlow?
I would also be interested in other ideas and methods of dynamically isolating areas for particle emission and how I might generally make this wave look good with particle systems. I’m aware of and plan on using the MR lume shader,… well here is the recent thread if you like or in case you missed it.
BTW – I would be willing to trade efforts & share resources if someone wants to team up on this for their own reel or project. I’m not really maxscript savvy, but this feels like the push! Tnx,
-Shea