Notifications
Clear all

[Closed] collision detection in maxscripting ?

In the maxscript I am creating I want to make sure that the face extrude I do should not collide with already existing geometry. Should I Create a vector with the lenght and direction of the extrude and test that against existing geometry before actually extruding ?

6 Replies
1 Reply
(@rivendale)
Joined: 10 months ago

Posts: 0

Hey Johan, well it depends on how accurate it needs to be. For an easy test sending an intersection ray from the middle of the extrusion onto the other object would be enough I guess…or comparing distances between vertices. You could initially test if the extrusion lies within the boundingbox of the other object to speed it up. If you need it to be very exact you would need to test all the triangles of the extrusion if they intersect any triangels on the other object. Perhaps even test the sides of the extrusion for intersection in cases where you extrude past the other object.

CML

It’s an interesting topic.

Do you guys know of any fast collision detection algorithms for 3d objects?

If you look in the help for Arrays and at the qsort function you can write custom sorting functions.
qsort <array> <function> [start:<integer>] [end:<integer>] [user-defined key args passed to function]

However it’s pretty slow, so I try to avoid it if possible.

/Andreas

…or perhaps there is no need to test triangles like that. I suggest that you send an intersection ray from each of the vertices of the extrusion in the direction of the extrusion before extruding, get the distance to the any intersection points and limit your extrusion to the shortest distance. Of course if you use local extrusion not all polygons will go in the same direction so in that case you migh need to send the ray in the vertices (maybe faces) local direction.

cheers,
CML

thats intresting… i´m currendly thinking of a script like this.
It should prefent boneobjekts from passing through Polys.
I would be intrestet in how fast this rays are. Anybody have done some experiences??

TGM

1 Reply
(@f97ao)
Joined: 11 months ago

Posts: 0

It’s easy to benchmark things in Max.

Just do something like this to benchmark the operation:

benchStart=timestamp()
 
 for i=1 to 100000 do 
     a=4000+444
 print ("Bench: "+(benchstart-timeStamp()) as string)

I would expect the Ray function to be very slow if you want to do it many times.

/Andreas

ya , intersting …

so i want a script to convert a complex building to a very simple one .realy , and just inverse of u want ? and this maybe more complex than make face extrude out but intersting too .