Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Any way to determine interference in MaxScript?
  RSS 2.0 ATOM  

Any way to determine interference in MaxScript?
Rate this thread
 
32237
 
Permlink of this thread  
avatar
  • rgames
  • Posted: 19 July 2009 05:10 PM
  • Total Posts: 9
  • Joined: 19 July 2009 11:55 PM

Greetings all - I’m new to MaxScript and 3DS Max and am trying to find out if there’s a way to determine interference between objects in MaxScript.

I wrote a script that generates a bunch of spheres (2500 - 10000) and associated trajectories based on some complicated particle dispersion physics that I’ve developed in another code.  I’m animating these trajectories in 3DS Max.  That part works fine.

Here’s the question: I’d like to insert an object into the animation and check to see if the spheres ever cross the surface of the other object.  If they do, I want them to stop, so I’d need to delete all keyframes after that point for any sphere that impacts the object.

Is there any way to code that in MaxScript?  I realize it’s probably complicated but if there’s at least some guidance about where to start looking, I’d greatly appreciate it.

Thanks,

rgames



Replies: 0
avatar
  • Akram
  • Posted: 19 July 2009 10:04 PM

you can use the intersects command in maxscript to check whether two objects bounding box and returns true. You should go through all the objects in scene and check with the object u inserted and then if true delete the keys of the objects. Sample code

end_frame 300
insertedobj 
$Plane01
ary 
selection as array
for 
i in ary do
 
(
 
for t in 0 to end_frame by 1 do
 
(
 at time t
 
if (intersects i insertedobj ) then
 (
 deleteTime i t end_frame
 
exit
 
)
 )
)

change the insertedobj to the object u inserted and select all the spheres and run the code.



Akram
Technical Artist,
FxLabs Studios, India
http://akira-techart.blogspot.com/

Replies: 1
/img/forum/dark/default_avatar.png

Thanks - that helps.  It still only uses the bounding box and not the actual surface, so it’s not precisely what I had hoped, but it’s a good start.

Thanks again,

rgames

Author: rgames

Replied: 24 July 2009 09:50 AM  
avatar

Hi there,
There is a function called intersectRay, it performs a raycast from a ray (that can be the direction of your moving object) to a mesh.
So it can give you the position of the closest intersection, the rest looks pretty simple using distance function!

Might be a bit heavy for 10000 objects though…

Good luck!



Replies: 0