Notifications
Clear all

[Closed] Distance visualizer

Hey people!

I’m trying to do a script that would give viewport realtime feedback of a distance between sets of objects. Basically, the desired result is:

In a first try I did messed around with vertex colors, assigning a unique color to all the objects within a certain distance threshold using this code (in the following example assigning the red color)

polyop.SetFaceColor obj 0 #all (color 255 0 0)

and the using this code to display the vertex colours

setCVertMode i true
setShadeCVerts i true

and when the loop finalizes going through all objects, I’d do a scene redraw with “redrawViews()”

The problem is, as many of you may already know, is that this runs very slow for realtime feedback and that all the objects must be editable poly in order to work. Is this normal for vertex colors? I guess it’s slow because the script must go through each face of each object to assign a color and that alone can be very time consuming if you have a couple of hundreds of objects.

So, if Vertex Color is not the way to go, what’s the better alternative? WireColor?

I’m all open to suggestions/help!

Cheers!

8 Replies

Hi davius,

I’ve uploaded a file. The script is in the Text shape. Unfortunately I’m a bit busy so it’s the quickest/ugliest way to do it, but it will give you something to start with.

Hey! Much appreciated! Will take a look and come back to you!

Thanks!

Thanks Nick! That’s more or less what I thought doing! Very clean and effective code! Works like a charm and one can even copy/instance those boxes that the script keeps working since the array is composed of all objects named box*! Very clever! Thanks a lot!

So, wirecolor is the way to go then? If the objects have some materials applied guess you gotta collect those materials and take them out of the objects in order to view the wirecolor, right? And then apply those materials back?

Interestingly, running the script as a script controller (as you did Nick) is waaaay faster than running it through a proper MaxScript (with rollouts, spinners and such). Our code is essentially the same, but I don’t know why on earth it runs so much faster on a script controller!! :shrug:

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

your codes are absolutely different. you are changing vertex colors but Nick is changing object wirecolor. that makes the difference. the using of a controller doesn’t matter.

but if you want to use vertex colors you can find my post about how to set them faster. and where i tell why polyop.SetFaceColor method is very slow.

No Denis! I said that I initially used VertexColors but found them to be extremely slow. So I went and used wirecolor instead but still, it’s slower in my script than using a script controller. The only difference is that, in my script, the vertex colors are changed everytime you change the spinner values using

on spn_spinner changed val do

and then proceeds the same code as Nick posted.

Anyway, I’m searching for a thread you started telling how to make VertexColors run faster (faster than Wirecolor?) and see what results I get.

Thanks!! And… after all the help I got from you guys here I finally finished my first script and posted it at scriptspot http://www.scriptspot.com/3ds-max/scripts/randomizatorrt

I’m aware that the script might have tons of ugly code/bad scripting but I’m looking to improve it as far as I can and learn along the way. If you have any suggestion please post at scriptspot or drop a line here!

Again, thank you very much guys! This Max community is just great! Never seen so many coders willing to help other getting on board the scripting bandwagon!

Hey Denis, is this the thread you were referring to? http://forums.cgsociety.org/showthread.php?t=1059920