ScriptSpot

Script

Fracture Voronoi

By Garp · 2009-04-05

Version
1.1
Votes
292
Description

This script breaks any mesh while preserving its volume.

Additional Info

v1.0: The object is broken in a number of chunks equal to 'Nb Parts' to the power of 'Iterations', using Voronoi cells. The final number appears on the 'Break' button. The creation process is visible in the viewport. For a similar result, it is faster to use several iterations with a small number of parts than creating all the parts in one iteration. Note that the original object is just hidden, not deleted. v1.1: In this version, the code has been improved and runs much faster. But there is no viewport feedback any more. Materials: - the outer faces keep their original material IDs and the new faces are assigned a unique ID. The value that appears by default is the highest ID in use (by the original object) + 1. - mapping coordinates (if any) are preserved and somehow 'projected' onto the new faces. - an extra planar mapping is applied to all the pieces at once and set on its own channel, typically for use with 3D procedural maps, so the pattern flows continuously from piece to piece but sticks to them when they are moved apart. Hierarchy: - when using several iterations, it is possible to keep the intermediate generations of parts. - when linked, each part is parented to the one it is derived from. - generations are set on their own layers, which are hidden except for the last one. Enjoy :)
Attachments

Tags: fragmentation, fracture, voronoi, division

Comments (77)

works in 2020

flathole · 2019-06-19

Fouinard's suggested fix to the script still works if your timeline is over 100.

Breaks in 2019

ALZHEM · 2019-03-07

I was looking forward to use this script but sadly it gets sluggy, and nothing happens. It creates 10 objects, a plane and that's it. You have to kill the script for Max to go back to normal speed :(

Gregsanders · 2017-04-15

Thanks for this script, version 1.1 did not work for me but version 1.0 works perfectly. I will let you know if I can get the other one to work, I have to check a few settings.

Thanks

Nick Wollage · 2016-09-15

Thanks for this super script:)

error

projectdelta6 · 2015-10-07

**update**
so I restarted max and then it works fine... odd
**update**
Hi I used this(v1.1) on one project and it worked perfect...

Now on another project when I try to use it to break apart a sphere Max throws an error
---------------------------
MAXScript Rollout Handler Exception
---------------------------
-- No ""+"" function for undefined

on line 149(thePlane.pos = (aCoords[i] + aCoords[j]) / 2)

I don't know what is wrong

Attachments

Fouinard · 2017-12-18

By default pcloud particles have a life of 100 frames, if your timeline is beyond that, the particles are deleted and the script can't get their position, you need to put your timeline between 0 & 100f or modify the script on line :

pSys = pcloud emitter:obj formation:3 total_number:nbParts quantityMethod:1 viewPercent:100 seed:(random 0 100) Display_Until:5000f life:5000f

now particles can be used until frame 5000...

Awesome!

x_OL · 2015-01-26

Very good function! Sanks!
This function can replace the Fracture function from reactor in older versions of Max.
But Autodesk inventing new useless features at this time! :)

Attachments

The picture you posted is

JokerMartini · 2015-10-07

The picture you (x_OL) posted is irrelevant. I don't understand why you posted it.

help please, help

couchise · 2015-01-25

extra cool and useful script but, unfortunatly only 1.0 version work for me,
have an error message after applying the 1.1 version.
on the file attachements there is a screen shot of that message.
any body can help, please.

kind regards.

Attachments

Works Great

DavidAnatolie · 2014-08-11

Nice script, I just wish Autodesk can integrate something like this into 3ds Max, maybe inside the MassFX tools.

Download

Bacon · 2014-06-30

How do I download this? Every time I click on the link I get this: -- * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-- * FRACTURE VORONOI - v1.1 - april 2009 - 3ds max 9 *
-- * *
-- * Divides an object in parts (Voronoi cells). *
-- * - several iterations; *
-- * - original UVs are preserved and 'projected' onto *
-- * the new faces; *
-- * - simple planar mapping is applied to a new channel *
-- * and consistent throughout the new parts; *
-- * - new material ID is applied to the new faces; *
-- * - can keep intermediate generations; *
-- * - can build hierarchy. *
-- * *
-- * GARP - 2009 *
-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

( -- start script

global rltFractureVoronoi
try destroyDialog rltFractureVoronoi catch()

rollout rltFractureVoronoi "F.R.A.C.T.U.R.E"
(
groupBox boxSetUp "" pos:[5,0] width:116 height:83
fn geometryFilter obj = superClassOf obj == GeometryClass
pickButton pbObject "Pick Object" pos:[10,11] width:106 height:25 filter:geometryFilter tooltip:"object to fracture"
spinner spnNbParts "Nb Parts: " pos:[09,41] width:106 height:16 range:[2,1000,10] type:#integer enabled:false
spinner spnNbIter "Iterations: " pos:[28,61] width:87 height:16 range:[1,10,1] type:#integer enabled:false

groupBox boxMat "" pos:[5,81] width:116 height:89
spinner spnNewID "New Mat ID:" pos:[24,93] width:91 height:16 range:[1,100,1] indeterminate:true type:#integer enabled:false
checkBox cbKeepMat "Keep Material" pos:[12,110] checked:true enabled:false
spinner spnNewCh "New Map Ch:" pos:[32,133] width:83 height:16 range:[1,10,3] type:#integer enabled:false
checkBox cbRWMS "R-W Map Size" pos:[12,150] checked:true enabled:false

groupBox boxHierarchy "" pos:[5,168] width:116 height:48
checkBox cbKeepGen "Keep Iterations" pos:[12,179] checked:false enabled:false
checkBox cbLinkGen "Build Hierarchy" pos:[12,196] checked:false enabled:false

groupBox boxCreate "" pos:[5,214] width:116 height:109
button btnCreate "Break in 10" pos:[10,225] width:106 height:25 tooltip:"pick object first" enabled:false
radiobuttons rdoColor "" pos:[12,253] width:72 height:32 labels:#("Multi Color","Uniform") default:1 columns:1 enabled:false
colorPicker cpParts "" pos:[70,270] fieldWidth:20 height:12 visible:false
radiobuttons rdoCenter "" pos:[12,288] width:72 height:32 labels:#("B.Boxes Centers","Vo.Cells Centers") default:1 columns:1 enabled:false

groupBox boxProgress "" pos:[5,321] width:116 height:49
progressBar pbProgress "" pos:[10,335] width:106 height:15 value:0 color:[0,96,0]
label lblProStatus "" pos:[10,351] width:100 height:17

local theObject -- holds the original object

on pbObject picked obj do
(
pbObject.text = obj.name
theObject = obj
spnNbParts.enabled = true
spnNbIter.enabled = true
spnNewID.enabled = true
cbKeepMat.enabled = true
spnNewCh.enabled = true
cbRWMS.enabled = true
cbLinkGen.enabled = true
btnCreate.enabled = true
btnCreate.tooltip = "start creating parts"
rdoColor.enabled = true
rdoCenter.enabled = true
cpParts.color = obj.wireColor
cpParts.visible = true

when obj deleted do
(
btnCreate.enabled = false
btnCreate.tooltip = pbObject.text + " has been deleted!"
pbObject.text = "Pick Object"
)

undo off
( -- gets new mat ID for new faces
m = edit_mesh()
addModifier obj m
spnNewID.value = amax(for i = 1 to obj.numfaces collect getFaceMatID obj i) + 1
deleteModifier obj m
)

) -- end on btnMesh picked theMesh

on btnCreate pressed do
(
undo off
(
disableSceneRedraw()
clearSelection()
start = timeStamp()

local nbParts = spnNbParts.value
local nbIter = spnNbIter.value
local keepGen = cbKeepGen.checked
local linkGen = cbLinkGen.checked
local aPartsStart = #()
local aPartsEnd = #()
local aAllParts = #()
local aAllCoords = #()
local thePlane = plane width:1 length:1 widthSegs:1 lengthSegs:1 -- plane helper for slice plane
local theMesh = editable_mesh()
local abortBreaking = false

lblProStatus.caption = " Breaking..."

-- BREAKING UP
---------------

-- clean copy (no custom attributes, keyframes, weird transforms, etc
theCopy = copy theObject
theCopy.name = "toto"
resetXForm theCopy
convertToMesh theCopy
theMesh.mesh = theCopy.mesh
theMesh.transform = theCopy.transform
theMesh.pivot = [0,0,0]
resetXForm theMesh
convertToMesh theMesh
delete theCopy

-- material and UVs
if cbKeepMat.checked do theMesh.material = theObject.material
addModifier theMesh (uvwMap mapChannel:spnNewCh.value realWorldMapSize:cbRWMS.checked)
convertToMesh theMesh
setFaceSelection theMesh #{}

-- parts creation
aPartsEnd = #(theMesh)
for iter = 1 to nbIter while not abortBreaking do
(
aPartsStart = aPartsEnd
aPartsEnd = #()

for obj in aPartsStart while not abortBreaking do
(
aPartsTemp = for i = 1 to nbParts collect copy obj
pSys = pcloud emitter:obj formation:3 total_number:nbParts quantityMethod:1 viewPercent:100 seed:(random 0 100)
aCoords = for i = 1 to nbParts collect particlePos pSys i -- fill with random coordinates
delete pSys
for i = 1 to nbParts - 1 do for j = i + 1 to nbParts while not abortBreaking do -- for each pair of coords
(
thePlane.pos = (aCoords[i] + aCoords[j]) / 2
thePlane.dir = aCoords[j] - aCoords[i]

addModifier aPartsTemp[i] (sliceModifier slice_type:2)
addModifier aPartsTemp[j] (sliceModifier slice_type:3)
aPartsTemp[i].slice.slice_plane.transform = thePlane.transform
aPartsTemp[j].slice.slice_plane.transform = thePlane.transform
addModifier aPartsTemp[i] (cap_holes())
addModifier aPartsTemp[j] (cap_holes())
convertToMesh aPartsTemp[i]
convertToMesh aPartsTemp[j]

if keyboard.escPressed do abortBreaking = queryBox "Do you want to abort and delete already created parts?"
) -- end i loop
aPartsEnd += aPartsTemp
aAllParts += aPartsTemp
aAllCoords += aCoords

total = nbParts * ((nbParts^nbIter - 1) / (nbParts - 1))
prog = 100 * aAllParts.count / total
pbProgress.value = prog
pbProgress.color = [200 - prog * 2,prog * 2,0]
) -- end obj loop
) -- end iter loop

if not abortBreaking then
(
lblProStatus.caption = " Finalizing..."

-- TIDYING UP
--------------

delete theMesh
delete thePlane
hide theObject

-- intermediate generations
if not keepGen and nbIter != 1 do
(
ind = 0
for i = 1 to nbIter - 1 do for j = 1 to nbParts^i do
(
ind += 1
delete aAllParts[ind]
aAllCoords[ind] = undefined
)
aAllParts = for obj in aAllParts where not isDeleted obj collect obj
aAllCoords = for c in aAllCoords where c != undefined collect c
)

-- coordinates
if rdoCenter.state == 1 then centerPivot aAllParts
else for i = 1 to aAllParts.count do aAllParts[i].pivot = aAllCoords[i]
resetXForm aAllParts
convertToMesh aAllParts

-- new faces ID
newID = spnNewID.value
for obj in aAllParts do
(
for f in getFaceSelection obj do setFaceMatID obj f newID
setFaceSelection obj #{}
)

-- names
if not keepGen or nbIter == 1 then
for i = 1 to aAllParts.count do aAllParts[i].name = theObject.name + "_Part_" + i as string
else
(
for i = 1 to nbParts do aAllParts[i].name = theObject.name + "_Part_" + i as string
indP = 0
indC = nbParts
for i = 1 to nbIter - 1 do for j = 1 to nbParts^i do
(
indP += 1
for k = 1 to nbParts do
(
indC += 1
aAllParts[indC].name = aAllParts[indP].name + "_" + k as string
) -- end k loop
) -- end j loop
) -- end else

-- layers
-- (comment out this block if you don't want any layer, intermediate generations will not be hidden)
-- (FROM HERE...)
if not keepGen or nbIter == 1 then
(
if layerManager.getLayerFromName (theObject.name + "_Parts") == undefined then
theLayer = layerManager.newLayerFromName (theObject.name + "_Parts")
else theLayer = layerManager.getLayerFromName (theObject.name + "_Parts")
for obj in aAllParts do theLayer.addNode obj
) -- end if
else
(
aTheLayers = for i = 1 to nbIter collect
(
if layerManager.getLayerFromName (theObject.name + "_Gen_" + i as string) == undefined then
layerManager.newLayerFromName (theObject.name + "_Gen_" + i as string)
else layerManager.getLayerFromName (theObject.name + "_Gen_" + i as string)
)
for i = 1 to nbIter - 1 do aTheLayers[i].isHidden = true
ind = 0
for i = 1 to nbIter do for j = 1 to nbParts^i do
(
ind += 1
aTheLayers[i].addNode aAllParts[ind]
) -- end i loop
) -- end else
-- (...TO HERE)

-- hierarchy
if linkGen do
(
if not KeepGen or nbIter == 1 then for obj in aAllParts do attachObjects theObject obj move:false
else
(
for i = 1 to nbParts do attachObjects theObject aAllParts[i] move:false
indP = 0
indC = nbParts
for i = 1 to nbIter - 1 do for j = 1 to nbParts^i do
(
indP += 1
for k = 1 to nbParts do
(
indC += 1
attachObjects aAllParts[indP] aAllParts[indC] move:false
) -- end k loop
) -- end j loop
) -- end else
) -- end if linkGen

-- colors
if rdoColor.state == 1 then for obj in aAllParts do obj.wireColor = random black white
else aAllParts.wireColor = cpParts.color

lblProStatus.caption = " Done in " + (formattedPrint ((timeStamp() - start) / 1000.0) format:".1f") + "sec."

enableSceneRedraw()
completeRedraw()
)
else
(
delete thePlane
delete theMesh
delete aAllParts
pbProgress.value = 0
lblProStatus.caption = " Stopped"
enableSceneRedraw()
) -- end test abortBreaking

) -- end undo off

) -- end btnCreate pressed

on spnNbParts changed val do
(
btnCreate.caption = "Break in " + ((val ^ spnNbIter.value) as string)
)

on spnNbIter changed val do
(
btnCreate.caption = "Break in " + ((spnNbParts.value ^ val) as string)
cbKeepGen.enabled = val != 1
)

on rltFractureVoronoi close do
(
enableSceneRedraw()
CompleteRedraw()
callbacks.removeScripts id:#FVcbID01
)

) -- end rollout rltFractureVor

createDialog rltFractureVoronoi 126 375 60 130

) -- end script

MaximilianPs · 2014-07-08

Left button, "save as" or "save object as"

vorks fine on 2015 - now this

robobear510 · 2014-06-18

works fine on 2015 - now this is what I realised so far, there are at least 5 more great free scripts or plugins that I constantly add to every version of max - like this one - max doesn't offer anything similar to this one - and it offers voronoi geometry generation

- it's like, why don't they just pay you 0.01% of their revenue and buy you plugin and pay the support off of you guys, you would be much happier, and max customers would be even more happier not needing to update - or for newbies, even more fetures

- I guess the corporations are really really slow, and this is how it works - after 20 or so versions max finally got out an outliner that c4d, modo and almost any other package has.. and it's one of the most expensive softwares out there - and still you cannot open more than one file inside of it - like in any other software package - and not to mention the start up times - the longest of any software package, ever - and bugs that go back to version 4

- and the fact they mentioned that "look see we have new features, we're not gonna shut it down" looks just like they want to shut it down in a few more versions - and who is going to decide that - a manager that just needs to keep percentages up year after year, not the same earnings, more earnings, he gets payed just for that, if he doesn't do it, someone else will

- if more money comes out of Maya - they will switch to just Maya - there is no logical reason for them to keep a software that earns less, like with softimage, doesn't matter what the community thinks or feels, any corporation does this - it turns into a headless monster, their products are not for humans, the products are for reproducing more moneyz

.. anyway, here's one rant

- and a great intuitive plugin you have there just keep it updatin :)

Hey mariss.

Garp · 2013-01-30

Use VoroFrag instead. It's way better and faster.

Flat Objects

mariss274 · 2013-01-30

I have been using 3D max in school and I am currently using Fracture Voronoi and massfx in a project. My project is a blender that blends up different types of fruit when they are dropped in. Everything has gone well so far except Voronoi will only break up my blueberries which are spheres. When I apply it to my apples, strawberries and raspberries, it gives me a bit of trouble. The apples, strawberries and raspberries are organic shapes because I had to move vertices to create the look. Voronoi causes the apples to go flat and the other to berries to shrink.

Would anyone be able to help me fix this?

Thank you,
Marissa

How to install the script in 3ds max

svet_lana_kouz · 2013-01-20

I couldn't find either any information about installation of the fracture voronoi script. I installed it as follows: opened my 3ds max, chose MAXScrip Menu and New Scrip there. I copies and pasted all the script text there and saved it in \Programm Files\Autodesk\3ds max**\Scripts as facture_voronoi_v1.1.ms. Closed "New Script" window. To run the script I chose MAXScript menu, clicked "Run Script" and chose the saved file. Hope, my experience can be of any use to somebody. Good luck!

dbrooksie7 · 2013-12-05

Thank you!

fadly lilik · 2012-10-24

why I can not take Voronoi Fracture. . . whether due to my ignorance. . . Can you help

Thanks for Script

Rogerio Nobre · 2012-09-24

Very useful script! Thanks for sharing.

Not really.

Garp · 2012-06-06

What it could use though is a faster algorithm. Right now it's about the worst possible way of doing it.
And the code is damn uggly.
One day I'd like to try something like the DeWall algorithm. One day...

JokerMartini · 2012-06-06

You ever consider further developing this?

Hi.

Garp · 2012-04-02

Could it be that you used it outside the 0-100 frame range? If so, it's a bug I never came around to fixing. The script creates particles inside the mesh and uses their positions for the pieces. By default, the particles disappear after frame 100, hence the 'undefined'.
If it's not it, then I have no idea.

"No ""+"" function for undefined" problem fixed

HillBilly · 2012-04-19

Thanks Garp,I had the very same problem when running the script and it works fine now that I'm running it inside the 0-100 range!

Small Problem

Socratis · 2012-04-02

Hi there I'm pretty new in 3dsmax and decided to use this script for a wall im building. When I select a brick(a box) and i click break into x pieces a MAXScript Rollout Handler Exception comes up saying --No ""+"" function for undefined. Why would that error come up? Thanks!

Material mapping

skye19 · 2011-12-08

Firstly, great plugin.

Secondly, the mapping for my material, however, does not stay the same which is a problem for me. Is there a way to fix this so that it remains intact before and after fracture?

I'm using version 1.1 which states that the mapping remains, but this is not the case for me. I have an object with a rock texture material that breaks at a certain time. It will look weird if the material mapping changes suddenly before it fractures.

thanks!

Fracture Voronoi

missterlobster · 2011-12-07

Truly brilliant script - so so useful. Cant wait for the next version - hopefully soon :)

thankes for script

KAREEM.MAX32BIT · 2011-11-25

I so have fun by this script and I thanke you

Hey

Garp · 2011-07-21

Sorry for not anwering earlier, peeps. I haven't touched this script in ages.
I'm looking at the code and it's really uggly. Sure it works but, hmm, that's just plain bad programming.
Currently fiddling with various Delaunay/Voronoi algorithms. So maybe a version 2.0 is in order?
Not right now but I hope soon enough.

Thanks for all the kind words :)

Slight script enhancement

Script_Butler · 2011-05-09

Hello.

I was wondering if it was easy to add an option to add some noise to the plane thats created and have options to adjust the noise parameters.

I only as because currently the fractures are all straight edges and i'd like to have some smoothness and curvature to them.

Can it also be changed to convert to editablepolys rather than editable meashes?

Are these something you think could be added?

Create a macro for it.

Garp · 2011-02-03

macroScript runFractureVoronoi
category:"MAX Script Tools"
internalCategory:"MAX Script Tools"
buttonText:"Fracture"
toolTip:"Fracture Voronoi"
(
    fileIn "C:\\...\\FractureVoronoi_v1.1.ms"
)

Paste this in a new script window, change the path to wherever it is saved on your hard drive, evaluate it once and close the window without saving (the macro has been saved to the userMacros folder).
From the Customize UI dialog > Toolbars panel > MAX Script Tools category, drag it from the Action list to your toolbar.
Et voilà.

HarryPotter · 2011-02-03

Uhmm...
How can i put this script on a Toolbar?
Can't find it through Customize UI...

Thanks!

Expanding Elements?

kearns892 · 2010-10-02

Is there a relatively simple method for achieving an effect similar to that in the photo where the fragments are slightly spaced apart?

Garp · 2010-10-02

@pokoy: I suppose it's possible, though I wouldn't know how. Sorry about that (and the late answer).

@kearns892: say you have a geosphere at [0,0,0]. Break it, select all the fragments and run something like
for obj in selection do obj.pos *= 1.2
in the listener.
This would effectively add 20% to each distance from the origin.

pokoy · 2010-08-31

Awesome script, having much fun with it!
I'd like to request following workflow feature: is it possible to map the 'break' operation to a key instead of clicking 'choose object' first?
This way you'd just select the object you want to break, press the hotkey and it would break with the current settings. This would greatly speed up the process when breaking many parts.

Suzume · 2010-08-10

Will try this script, thx for posting this one here.

Garp · 2010-06-29

Thanks for the feedback, tumblingweed.

I haven't played much with particles, but surely there's a way to keep materials and mapping when replacing particles with objects. Someone else might step in.
Or maybe you're better off asking on a regular 3ds max forum, like maxforums.org.
Sorry I can't be of more help mate.

tumblingweed · 2010-06-29

Thanks for the speedy reply Garp :)

tumblingweed · 2010-06-29

Another kind soul on maxforum.org gave me some help and Iv got the planet textured and breaking apart now, again this script is just pure awsome!

Garp · 2010-06-29

Yep, I saw you over there.
I knew there was an easy way :)

tumblingweed · 2010-06-29

Awsome script I'v been having endless hours of fun with it. I'm fairly new to Max and I'm having some trouble with keeping my materials on the object i want to fracture, After I break my object up the texture remains on it but when I use particle flow to destroy the object (using sdeflectors with some scripting I picked up from a tutorial) the materials on my object disappear leaving a stock bland colour. After I hide the original object and use the particle flow to generate the new object it doesnt appear on my view port anymore either. I have hunted all over google for an answer and just decided to ask for help. Attatched is the image of my object after I use the break option.

Kind Regards

Attachments

SepiaRainfall · 2010-04-29

Hi, thanks for sharing this script.

I tried using this script to break a hollow object. It creates geometries inside the object. Is there a way to change that?

Garp · 2010-04-29

The script uses repeatedly Slice (with Remove Top or Bottom) + Cap Holes modifiers. So it has the same limitations. With hollow objects, like a Tube primitive, max does a 'best guess' to cap holes with a concave contour and sometimes a polygon goes the wrong way.
Try to break the object manually a couple of times first.

artrager · 2010-04-11

Perfect for stone walls! I use the manual iteration technique: Make an initial break, choose the largest resultant, break, choose again, break, and so on... This can be done rather quickly and is somewhat controllable. Since there is no undo, I save the scene each time if the result was satisfactory or reopen the last save if it wasn't. When all the stones are created I chamfer the edges, check for flaws, make repairs, then add modifiers to taste!

Garp · 2010-04-17

Nice tip, artrager.
To save time, you can use the hold/fetch shortcuts instead of saving ;)

birket · 2010-04-09

Really great script and just might save me on a difficult stone wall I am trying to model.

It seems the best way to break a wall into, for example, 1000 parts is to have Nb Parts as 10 and Iterations set to 3. However, this creates large, visible straight lines in the finished wall.

Presumably, leaving iterations to 1 but upping Nb Parts instead would solve this, however, even trying to set Nb Parts to 100 on my machine (quad core, 8GB, XP64) the machine sits there for ages (as yet it hasn't finished building!).

Is this just the nature of the script?

Garp · 2010-04-10

The amount of calculation grows exponentially with Nb Parts as it deals with pairs of cells, not just cells. That's why I added an Iterations parameter. But as you noticed, the lower the number of iterations the more fractures across the whole model for the same amount of final pieces.
However it shouldn't be that long on your machine. On a 5 years old computer (a single Athlon at 1.97GHz and 1GB of RAM on XP32) 1 iteration of 100 parts takes about 50 seconds (and around 20 minutes for 1000 parts). With your specs it should be a lot faster.

But for a stone wall this script might not be the best way to go, as you'll probably get some very big chunks and some very small ones.

Joe007 · 2010-03-01

Great script Garp!

Garp · 2010-03-01

Yeah! Joey's here!!
Thanks for the point, buddy :)
(and about time too!)

Garp · 2010-01-21

Sorry for the late answer.
I tried the various solutions and they all seem to do the trick. Thank you guys.
I'll go for the 'at time 0' though. Not because it's mine, but it's the shortest to type! ;)

And a big thanks to everybody else for the kind words.
Much appreciated.

artrager · 2010-01-18

Thanks Garp!

I have been modeling landscape elements of rocks and stones by hand. With a few clicks this script produces far better results in a fraction of the time! (pun intended ;)

Anubis · 2010-01-18

the pcloud is a temp objects so this must be enough fixing:

Display_Until:animationRange.end life:(animationRange.end + 1)
Attachments

Garp · 2010-01-17

Brilliant! It looks like you've nailed it.

- Setting the part from 'pSys = pcloud...' to 'delete pSys' in a 'at time 0' context should solve the problem (?).

- 'snapshotAsMesh': that part is definitely messy for no good reason. I didn't know that method then (and haven't touched the code since).

- err... the whole breaking process is already in an 'undo off' context (or should be, I'll check again).

Thanks a lot for all the inputs, Martijn. :)
I'll work on a plugin version in 2 or 3 months (SDK, C++, fist time, yay!). That'll make it run much MUCH faster. I'll make the changes then.

Cheers.

Martijn van Herk · 2010-01-18

- err... the whole breaking process is already in an 'undo off' context (or should be, I'll check again).

Yup you're right, it's already there!
I'm not sure if 'at time' will work for the pcloud, but what you could try is setting its birth time to a large negative value and its lifespan to a large positive value.

Martijn

LandShark13 · 2010-01-15

Great work man thank you!

Garp · 2010-01-15

This has happened to a few others.

At some point in the code, a particle system is created to fill the object with a specific number of particles (Nb Parts), then the particle coordinates are collected and the particle system is deleted.
I checked that part several times, had it checked by others and nothing. It seems to come from the particle system that, for some unknown reason, doesn't work as it's supposed to.
From your message, 'particle index out of range: 1', it looks like the particle system created 0 particle. I have no idea why this happened (nor have I been able to reproduce it).
If I gain some understanding in the future I'll correct the script accordingly. But it seems to come from a bug in the particle system. Can't tell for sure.
Sorry for not being more helpful.

If anyone wants to have a look at the code, search for the part from 'pSys = pcloud...' to 'delete pSys' (3 lines).

Martijn van Herk · 2010-01-16

I checked your script and I think I know why this happens. You're creating a PCloud object without setting the lifespan of the particles (which is set to 100f per default). So when the timeslider is on frame 101 or higher when running the script, the PCloud will not contain any particles anymore.

Hope you don't mind me giving some other points of advice while I'm at it ;)

Here's a quick way of creating a snapshot of the selected object's mesh:
local theMesh = mesh mesh:(snapShotAsMesh $)

Another thing you might want to try is turning off undo during fracturing which might speed up the process a bit.

Cheers,
Martijn

Damian · 2010-01-14

Hi, thanks for share this script. I just started using it and I don't know if I'm doing something wrong, but it doesn't work for me, sometimes. Usually, I get this message:

"-- Runtime error: Particle index out of range: 1"

and then the script crashes.

I'm using 3ds max 2010.

Help, please!!!

one808 · 2009-12-15

very nice.^_^
thanks.

notapix · 2009-12-10

hi,
tnk for your script.
i have a question please:
could I get a hint of which mode to use to animate all the broken parts of the object?

(sory my bad english).

ciao :)

Garp · 2009-12-10

Thanks for the kind words, guys and girls. That's really nice!

@drummond: the cell centers are generated at random inside the object's volume and true voronoi cells are created from them. If there's more than 1 iteration, the process is repeated. So only parts derived from a same previous part (from the previous iteration) are correct voronoi cells in regard to each other.
If you need control over the cell centers, I have a previous script that accepts coordinates from a text file. Look for 'Voronoi Cells'. That script was experimental. So it's quite slow. But it gets the job done.

drummond · 2009-12-11

Cheers for the detail Garp, I have found the other script which does exactly what I want. Thanks for the great work

Drummond

drummond · 2009-12-04

Hi Garp,

is this true Voronoi sub-div? How are the spatial centre points established from the users selected objects?

Nice script regardless

hawkarena · 2009-11-30

Just pick click & break its amazing, thank u very much.

Salve of Allah

capcaverna · 2009-11-27

simply usefull, niceeeeeeeeee

99019803 · 2009-11-24

GOOD,thanks very much

kutsanan · 2009-06-26

Thanks for it

cagataykoroglu.blogspot.com

Garp · 2009-04-16

Ciao Michele!
How's the weather in Roma? (I was there 2 weeks ago)

Michele71 · 2009-04-16

The weather in Rome is beautiful (a bit less for the earthquake in Abruzzo). When you return to Rome let me know!

Ciao
Michele71

Michele71 · 2009-04-15

Truly a great and useful script! thanks Garp!! :)

Grazie, grazie e ancora grazie!!!

Garp · 2009-04-15

Thanks for the thanks, people :)

aphexx, the script doesn't need any other file and it was written with max 9 (not 2009), so it's not a compatibility problem.
Did that happen once or every time you run it?
Also, does it happen as soon as you click on the Break button or does the progress bar move a little before it stops?

The script uses a PCloud particle system to gather coordinates within the object's volume. It looks like it didn't create the right amount of particles, so the array of coordinates gets some undefined values.
You're not having problems with particles, by any chance, like a missing dll?

aphexx · 2009-04-15

hi thanks for your script. i'm using max 9 and get a "--No ""+""function for undefined" error. in this line:

thePlane.pos = (aCoords[i] + aCoords[j]) / 2

i gt it, when pressing "break in xx" button. the objects duplicates then a couple of times. but the script crashes then.

do i have to install some supporting scripts? or is it simply not functioning under max 9?

thanx anyway!

sascha

 

zjlong · 2009-04-14

Thanks for sharing! It is a very useful tool for our modeling work.

zwick · 2009-04-06

nice plugin. it creates pretty clean geo, and it free.
thanks, Garp

Garp · 2009-04-09

thanks for trying it :)