Randomize Elements

18 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.
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

lightcube's picture

Thanks for sharing

Thanks for sharing Swordslayer. I made a scripted plugin identical to this last year but never released it because I couldn't figure out the right transformation calculation to get the element rotations to always rotated from the element centers. No need to finish it now.

PS. You are on a rampage lately with all these great shares. I think you are working on a Flawless Victory.

_______________________

Shawn Olson

Developer of Wall Worm

Comment viewing options

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