Created
August 3, 2015 14:45
-
-
Save JokerMartini/2ff9faaddc2f24b5aa09 to your computer and use it in GitHub Desktop.
Maxscript: Radial sorts objects using the average center position to determine sort.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
local theObjects = objects as array | |
local count = theObjects.count | |
local center = [0, 0, 0] | |
for obj in theObjects do center += obj.pos | |
center /= count | |
fn radialSort obj1 obj2 = | |
in coordSys (transMatrix center) (cross obj2.pos obj1.pos).z | |
qsort theObjects radialSort | |
--check resulting array | |
for i = 1 to theObjects.count do | |
( | |
format "%\n" theObjects[i].name | |
theObjects[i].wirecolor = black + (red*(i/theObjects.count as float)) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment