Fracture Voronoi

284 votes
Version: 
1.1

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 :)

AttachmentSize
FractureVoronoi_v1.1.ms10.85 KB
FractureVoronoi_v1.0.ms4.67 KB

Comments

Comment viewing options

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

the pcloud is a temp objects

the pcloud is a temp objects so this must be enough fixing:
Display_Until:animationRange.end life:(animationRange.end + 1)

AttachmentSize
FractureVoronoi_v1.1_FiX.ms 10.96 KB

my recent MAXScripts RSS (archive here)

Martijn van Herk's picture

- err... the whole breaking

- 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

Garp's picture

Brilliant! It looks like

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's picture

I checked your script and I

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

LandShark13's picture

Great work man thank you!

Great work man thank you!

Garp's picture

This has happened to a few

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

Damian's picture

Hi, thanks for share this

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's picture

very nice.^_^ thanks.

very nice.^_^
thanks.

summer

drummond's picture

Cheers for the detail Garp,

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

Drummond

notapix's picture

hi, tnk for your script. i

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 :)

Comment viewing options

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