Crack Geometry Script
First time post here, and a first attempt at a script :D
So everyone is aware, I'm a fx artist and want to learn a bit of max script so it can speed my work flow up a little :). At the moment i am not wanting to make full blown tools for a team, just little things for myself.
Also with this script i got everything out of the maxscript help docs, not from tuts or other scripts :)
I got the idea from other scripts out there like MBFacture and the plug-in called Rayfire. both very cool and very useful tools!
This is my first attempt at any sort of script and is basically very buggy :(. but it was more of an exercise in how for loops work...
Anyways thought i might just post it so people could give me some feedback on it!
Again this is my very first attempt at doing a script, so please be gentle!
[geshifilter-blockcode] /* Created by Kieran Ogden-Brunell March 2009 This script should break a selected object into chunks Good for stone/rock debris --FOR LATER REVISION-- ______________________ - Pick button for object -List box for multi objects -bounding box function to drive crack plane sizes (currently this is a hardcoded value of 120 in scene size) -dialog box for user enable cancel or continue -save "tick" option, so scene is saved before calculation -tick option to keep orginal mesh -Iteration feature to run the simulation over the first pass cracks - minimum size threshold for breaking on first pass and iteration _______________________ KNOW ISSUE"S _______________________ -Crash's MAX randomly if used to much. -Crash's MAX if gc() is used -Process breaks if the crack planes are too small compared to the user object _______________________ */ rollout kobCracks "Crack Geometry" ( edittext _oName "Name" fieldWidth: 160 height:16 spinner _pAmount "Crack Density" type:#integer range:[1,20,5] spinner _pSegs "Crack Detail" type:#integer range:[3,12,7] spinner _pNoiseHieght "Crack Shear" range:[0,85,55] spinner _pSmoothAmount "Internal Smooth" range:[0,90,24] -- checkbox _keepOrgObj "Keep Original Object" -- on _keepOrgObj changed theState do -- ( -- copy $ -- hide $ -- messagebox ("Your orginal object has been copied and hidden! Please select mesh " ) -- ) button _create "Create Cracks" width:150 height:50 tooltip:"Crack Object!"--this should eventually name the seperate chunks!!!!!!! on _create pressed do ( if _pAmount.value >= 15 then messagebox "WARNING: Could become unstable!" --warns if you have too many planes need a cancel or continue dialog DisableSceneRedraw ( _firstPlane = null for j = 1 to _pAmount.value do -- created the rest of the planes need to complete the spinners value ( p= (plane())--creates plane from the exposed spinner's p.name = uniquename "cutPlanes" if (j == 1) then _firstPlane = p p.length = 150 p.width = 150 p.lengthsegs = _pSegs.value p.widthsegs =_pSegs.value p.wirecolor = [random 0 255,random 0 255,random 0 255] addModifier p (Noisemodifier()) --adding noise modifier to plane p.modifiers[#Noise].seed = random 1 1000 p.modifiers[#Noise].scale = random 45 85 p.modifiers[#Noise].fractal = on p.modifiers[#Noise].strength = [(random 0.0 1),(random 0.0 1),(random _pNoiseHieght.value (_pNoiseHieght.value+5))] addModifier p (smooth()) --adding smooth modifier to plane p.modifiers[#smooth].autosmooth = on p.modifiers[#smooth].threshold = _pSmoothAmount.value rotate p (eulerAngles (random 0 360) (random 0 360) (random 0 360)) --rotates planes in "for" a random value from 0 to 360 degrees convertTo p (Editable_Poly) --convert to edit poly if (j > 1) then polyop.attach _firstPlane p ) -- this is the pro cutter section currently works with one cut a = _firstPlane c = $ ProCutter.CreateCutter #(a) 1 True True False True True ProCutter.AddStocks a #(c) 1 1 Delete a -- Rename objects to the name specified all = $cutPlanes* all.name = uniquename _oName.text ) EnableSceneRedraw() -- gc() ) button _HowToBox "Info" tooltip:"Info" on _HowToBox pressed do ( messagebox "Create an Object or use an existing prop. \n Select the mesh you want to crack. \nPress Create Cracks to Run!" ) button _aboutBox "About" tooltip:"About" --align:#right on _aboutBox pressed do ( messagebox "This script creates cracks in selected objects\nCreated by Kieran Ogden-Brunell 2009" ) ) createdialog kobCracks width:220 height:220 <code>[/geshifilter-blockcode]