PDA

View Full Version : Points intersecting non-convex mesh


thomwickes
04-02-2009, 04:17 PM
Ok, I need to find a way of distinguishing whether points sit inside
or outside a mesh - I have an idea how to do it with convex meshes,
but not with non-convex.

so in this photo

http://farm4.static.flickr.com/3278/3406312071_8ca8aa4df8_o.jpg

I want to select the locators that don't penetrate the mesh surface,
so all the ones outside and inside the cup, but not the ones under the
surface.

I have a feeling this involves some ray casting style stuff and I had
a look at the MFnMesh class, but I don't really know any method of
doing this, let alone how to implament it.

Any help/suggestions would be greatly appreciated.

Thanks

A-OC
04-02-2009, 06:21 PM
I've done this by:

duplicating the mesh
moving the vertices along their normal a tiny amount on one of them
connecting closest point on mesh nodes to both meshes

Then testing the distances from the point being evaluated to the closest one on both meshes, if its closer to the outer mesh then the point is outside.

Hope i'm clear enough.

thomwickes
04-02-2009, 06:28 PM
Makes perfect sense. Thanks a lot.

thomwickes
04-02-2009, 06:29 PM
I guess the scaling up of the duplicated mesh would have to be so remote for it to catch all the particles. This should be accurate enough though. Any idea how fast this is?

A-OC
04-02-2009, 07:56 PM
Who said anything about particles? Oddly enough I originally created this to replace a volume with particles, so how fast, it turned out slower than I thought, it generates a random point inside the BBox, checks if it is inside, if so, it stores the point, when it gets out of the loop it creates the particles.

For 4000 iterations it creates around 1600 particles and it takes about 10.5 secs.

But I was testing the distances with distNodes so I could speed it up just by doing it manually, You know float $d = vec1 - vec2;

thomwickes
04-02-2009, 09:05 PM
Basically replace a volume with a load of random points in space is exactly what I want to do.

I like your method. I kinda wish I was a tools programmer these days, it's much more of a creative job than I'd previously imagined.

Thanks for all your help buddy.

CGTalk Moderation
04-02-2009, 09:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.