[Closed] RAM-problem with function 'ClosestPointOnSurf'
Hello everybody,
I am struggling for nearly two weeks now finding a solution for my problem (i must admit i am pretty new to MAXscript). It would be great if anyone could give me a hand here! In essence it concerns finding the closest distance between a point and a surface in a workable way for my situation. Let me explain in short what i want to achieve:
I have 256 fixed Points and one moving Object. The Points are the pivot-points of 256 simple Boxes. The Object is a Teapot in my example. The teapot has about 1K to 5K faces.
What i want is that the Boxes (which are normally invisible) become slowly visible when the Teapot comes near enough to one of them. I solved this by loading the ‘ClosestPointOnSurf’ function at startup of 3dsMax, and basically putting a script in the visibility-track of each of the 256 Boxes. The script goes like this:
Box = $Box01
closest = closestPointOnSurf $Teapot Box.pos
dis = distance Box.pos closest
if (dis < 2.0 )
then
visibility = 1
else
(
if (dis > 4.0)
then
visibility = 0
else
visibility = 2-dis*0.5
)
The script works; the boxes become visible between distance 4 to 2. So that is one. But the problem is that fairly quickly the amounts of RAM needed builds up and goes through the roof. So the most important question i have is this: Can i tweak the script in a way that the used RAM is emptied (or a cache is emptied or something similar)? It does not need to happen in real time; i mean i will render the results. This means that the RAM could per instance be emptied after each rendered frame. I am just thinking out loud here. Other solutions are also welcome of course!
Anyone?
P.S. I have read the different threads on the subject and tried the different techniques. Right now i just wonder if i can make the latter technique work somehow.
Thank you!
For the people that doesn’t know what the function ‘ClosestPointOnSurf’ is; it makes use of MeshProjIntersect() and goes like this:
fn closestPointOnSurf surf refPos = (
mpi = MeshProjIntersect()
mpi.setNode surf
mpi.build()
mpi.closestFace refPos doubleSided:true
closestPoint = mpi.getHitPos()
mpi.Free()
return closestPoint
)
Thank you!
Hi, sorry I realize this is a late reply, but you would probably have more luck using this script on particles. With separate boxes, each individual script controller has to be loaded and executed and I think this is where the RAM usage is coming from. With particles, you can just assign the particleAge based on the distance and use a ParticleAge map for the opacity of your material, and you will only need one script to run instead of 256! I would imagine you could do this with a couple orders of magnitude more objects if scripted with particles. Even more if done with Box3.
Hello mSmith!
I actually solved the problem lately using Box#3 software and particles, so your reply is correct! Although, a bit late yes. Thanks for your effort anyway M.Smith!