Randomize Elements

11 votes
Version: 
0.03a
Author Name: 
Vojtech Cada

 Randomize elements the easy way. Slow as hell with complex models (500k poly and more).

Additional Info: 

Installation: Copy the .ms file to your scripts\startup folder or run as a script if you only want to try it out. The modifier will be available in the Modifier List.

Notes: If you want to exit the Generate loop, hold the Esc key. When using Show Once update option and switching to baseobject/different modifier in stack and back, you have to click the Update button once again to show the randomization. Exercise caution when using this for complex meshes.

Credits: The original getMeshElements function comes from Jorge Rodríguez (aka PolyTools3D).

Version Requirement: 
3ds Max 2016
AttachmentSize
randomizeElements.ms8.67 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pixamoon's picture

Thanks for sharing

Thanks for sharing +1 great tool

joelauduo's picture

Thank you very mush~

Great help to me :)
If you can make function like this script, That's perfect!
http://www.scriptspot.com/3ds-max/scripts/super-detach script
Thanks again!

Swordslayer's picture

Thanks for the stack trace

Bummer, I've used a non-standard +- character there and it gets merged with the closing " character :/ Re-upped the file saved in UTF-8, not sure if that can help. If not, open the file in script editor, notepad or other text editor and delete all the "±" (or use the attached randomizeElements_replaced.ms file where I've already done it).

Thanks for patience and hope you will find the modifier useful.

AttachmentSize
randomizeElements_replaced.ms 8.61 KB
joelauduo's picture

Thanks you for help~

Not old, 3dsmax2016 ext1 sp2

-- Error occurred during fileIn in "C:\Program Files\Autodesk\3ds Max 2016\scripts\startup\randomize_elements.ms"; line number: 144
>> MAXScript Auto-load Script Error - C:\Program Files\Autodesk\3ds Max 2016\scripts\startup\randomize_elements.ms Exception:
-- Syntax error: at ?, expected
-- In line: spinner spnPosY "? p <<
-- Error occurred during fileIn in "C:\Program Files\Autodesk\3ds Max 2016\scripts\Startup\randomize_elements.ms"; line number: 144
-- Error occurred in anonymous codeblock; filename: C:\Program Files\Autodesk\3ds Max 2016\scripts\Startup\randomize_elements.ms; position: 4744; line: 144
>> MAXScript FileIn Exception:
-- Syntax error: at ?, expected
-- In line: spinner spnPosY "? p <<

Swordslayer's picture

Old max version, maybe?

Check the requirements, it only works with max 2016 and higher. The .mse is just an encrypted version of plaint-text .ms, that won't help you.

joelauduo's picture

Thanks for sharing but can't work

can't work idont know why
please up .mse thank U

lightcube's picture

I'll share it with you

I'll share it with you tomorrow. I had some hacky caching to get it to work, yes :) But it was mostly OK except rotations odd in some occasions.

_______________________

Shawn Olson

Developer of Wall Worm

Swordslayer's picture

Center code, like getting

Center code, like getting center? Sure, that part IS easy (well, there's not much to complicate it, accumulate all the positions, divide by vertex count, done), what is usually harder is getting all the mesh elements in an efficient manner. Didn't even try the obvious method getElementUsingFace -> getVertsUsingFace here because I've been bitten by it quite a few times before. The memory usage with big meshes is huge (and I mean really huge... and I have in mind meshes around the mark of 1M polygons and let's say 20k elements). The method I was talking about comes from this thread at cgtalk.

If you have some time to spare, you could try comparing speed and memory consumption of both methods and post the results - now that would be interesting, having never benchmarked it inside a modifier, I might be wrong here.

Btw. out of curiosity, what method did you use to get the object mesh in the simpleMod? And did you have any sort of caching in place? If you don't mind attaching the file, I'd like to have a look, otherwise I'll keep asking stupid questions :) I know you can save the mesh as #maxObject but I keep wondering if there's some clever way to save <vertexSelection> data that would be persistent across sessions. The mapped access makes it much faster to work with, i.e. <vertexSelection>.pos *= TM, boom, done, thousand verts transformed in one go with no overhead nor leaking.

lightcube's picture

I peeked in and honestly the

I peeked in and honestly the center code looks a lot like what I started with. Seems like I was having problems when the object was transformed in the scene. But I was using SimpleMod... which may have been part of my issue. I've got to start playing with the new goodies in 2016.

_______________________

Shawn Olson

Developer of Wall Worm

Swordslayer's picture

My pleasure

My pleasure. Once you get the elements and their centers, the calculation itself is 'translate point from the center to the origin, scale it there, rotate it, move it back, offset it' (or swap the last two if you like) - see the getRandomTM function. For me the part that was always hard to make reasonably fast with complex meshes was getting the elements and that part of the script logic comes from Jorge Rodríguez.

Victory, hmm? Is there a competition? Cool If only there was more time, outside of work I spend very little time with max and the time spent at work is all hard-surface modeling - you know what, have a look at what we do and spread the word, that way I might soon get paid better and work less Wink 
jk, but not really

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.