Crack Geometry Script
Hi!
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!
Cheers Kieran.
[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]
Comments
How do I run this, install
How do I run this, install this? What do I do with this code? Instructions for non-application developers would be nice! :) Because I'm sure NOT a programmer.
Hi Kieran,Thank you very
Hi Kieran,
Thank you very much for reply. Now its working fine with max 9 & 2009.
And I appreciate, this is a really really great tool.
Its my fault, previously I was trying it with max 7.
Great work :) keep it up man.
------------
BlackFoxEye
mmm firstly awesome a
mmm firstly awesome a reply!
the only thing that really spring to mind is, are you using version 9 or above?? seems silly but thought i would ask. :)
I have updated the script slightly and have noticed substantial stability!
NOTE-the size and position of the object no longer matter!! yay! was easier then i thought.
Heres the script again!
[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 hard coded 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 original 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. - Process breaks if the crack planes are too small compared to the user object - Crash's the script if objects aren't "water tight" - Crash's teh script if the object is too far from world zero. - If the crack scripted is used on already cracked mesh, sometimes removes part of the orignal object. _______________________ */ rollout kobCracks "Crack Geometry" ( edittext _oName "Name" fieldWidth: 160 height:16 spinner _pAmount "Crack Density" type:#integer range:[1,20,8] spinner _pSegs "Crack Detail" type:#integer range:[10,30,20] spinner _pNoiseHieght "Crack Shear" range:[0,120,55] spinner _pSmoothAmount "Internal Smooth" range:[0,90,65] button _create "Create Cracks" width:150 height:50 tooltip:"Crack Object!"--this should eventually name the seperate chunks! -- create planes from the spinners value 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 X = $.max.x - $.min.x Y = $.max.y - $.min.y Z = $.max.z - $.min.z maxDis = (amax X Y Z)* 1.2 for j = 1 to _pAmount.value do ( p= (plane()) p.name = uniquename "cutPlanes" if (j == 1) then _firstPlane = p p.length = maxDis p.width = maxDis p.lengthsegs = _pSegs.value p.widthsegs =_pSegs.value p.wirecolor = [random 0 255,random 0 255,random 0 255] --adding noise modifier to plane addModifier p (Noisemodifier()) 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))] --adding smooth modifier to plane addModifier p (smooth()) p.modifiers[#smooth].autosmooth = on p.modifiers[#smooth].threshold = _pSmoothAmount.value --rotates planes in "for" a random value from 0 to 360 degrees rotate p (eulerAngles (random 0 360) (random 0 360) (random 0 360)) --convert to edit poly convertTo p (Editable_Poly) objPos = $.position p.position = objPos 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() ) 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" 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> hope this helps! Kieran
[/geshifilter-blockcode]Kieran Ogden-Brunell | www.kobfx.com | www.vimeo.com/kobfx
Hi Kieran,It seems really
Hi Kieran,
It seems really nice script. I tried to use it, but I am getting an error on line "ProCutter.CreateCutter #(a) 1 True True False True True"
And a popup message came with "Unknown property: "CreateCutter" in undefined".
So can you please tell me about this error?
------------
BlackFoxEye