Notifications
Clear all

[Closed] pipe maker script and collision detection

Im working on a script that makes pipe work, the sort you get in ships and industrial places, well thats the idea anyway, you can get the script to add valves and joints and stuff like that once your done making the main pipe itself. all that part works well and I’m happy with it. see the picture below for an idea of what it can do but also you can see a lot of intersecting going on and thats the problem I’m having, The auto build part of the script works, but a lot of the time I find the spline will be crossing over its self or going inside some other object. in short I would like to be able to stop the script drawing the spline/pipe if the section its about to draw would intersect with a part of itself or something else.

so what is the best way to do collision detection ?
what do I need to read up on to do this ?

Thanks for reading and I hope someone can point me the right way with this

19 Replies

Well the standard max intersection function is intersectray, or intersectrayex, but I think they only work with geometry so they won’t work on splines.

I think your second best bet might be to look up the math behind calculating point–>line intersections (it’s not that hard), then while creating your splines run that function on the knot you’re creating with regards to all of the segments of all of the other splines. Then setup a conditional test like…f there’s no intersection, keep building…if there is one, form a joint.

A second solution might be to have the script convert pipes to meshes after each one finishes, then while building the next pipe, shoot rays in the direction of the pipe at all the other meshes and see if there’s an intersection.

thanks for the info dude. I’m going to have a read up

LOL…looks like that old Windows screensaver!

Very cool looking script, I’ve made stuff like that before, but always by hand Once you get it releasable, would love to give it a try.

  • Neil

no worrys Neil I will put it up on my web site when its ready and post here to let you know…

I think I got the self intersecting thing sorted by using a Voxel array , next Im going to add an intersectray function for other objects.

If you really want to get into this, there’s a great book i picked up. called “essential mathematics for games & interactive applications”.
it has a hole section on intersections and the math behind it.
the best part about the book is that is has all the code in c++ so it’s esier to translate if you don’t understand all the math behind it.

i think the main thing you want to test for is ray intersect line (you can goolgle this)

this way once you figure out the direction you want to shoot your pipe (the ray) you can test for the closest previously created line segment. if your tool only creates pipes at 90 degrees then you can test via closest point along ray (you can find that if you google as well.) which is alot faster.

the math behind this to is preaty simple, you should be able to achive it in ms with out any problems.

cheers,
Los.

thanks for the input there Carlos , I’m doing well with this script so far I got the collision detection working now .

This is absolutely amazing, the kind of script i was thinking!!!

great idea.looks very cool. Although i should think that your average plumber wouldn’t be as enthusiastic.

Page 1 / 2