[Released] Mesh Destruction "Piecemaker"

Hello,

finally I released Piecemaker. With Piecemaker you will be able to destroy meshs into pieces and even destroy these pieces into even more pieces.

Piecemaker is an Unity editor Extension written in C# which will pre calculate the destructed meshs based upon a mother/father mesh and various user options.

You can extend or change almost every aspect of Piecemaker. You want to use a prefab for every piece? No problem just add it. You want to add custom behavior without using a prefab? No problem, just extend a special baseclass. You want an other destructable Component and not the one Piecemaker provides? No problem, just extend the same special baseclass as in the last sentence.

Its even capable to destroy without precalculation. How is this possible? Piecemaker delivers a Tools class which is perfectly capable to be used by any script you will or want to use.

Want to see a little demonstration?

Asset Store: Piecemaker - Mesh Destruction | Tools | Unity Asset Store
Introduction video: http://www.youtube.com/watch?v=I9n9SwHQxQA
An older sample video: http://www.youtube.com/watch?v=lQ1pziX9_so
Webplayer demo for the Slicer Component (dynamic destruction): Unity Web Player | WebPlayer

The original showcase thread: http://forum.unity3d.com/threads/82715-Piecemaker-(Destruction-Creator)

Questions, comments or reports, are welcome.


Some small guideline:

Dont go atomic, dont use too many destruction levels, if you split your initial mesh in 16 fragments and this generated fragments again in 9 fragments and these again into 4 fragments you create up to 736 fragments, even on a good PC, this is a serious performance impact.

A better way here is to keep the desctruction level low and use particles for the destruction of the smallest fragments, they will spawn faster and Unity is able to update these particles more efficient.

Prebreak if possible, you want to destroy a building, with a complex roof, many walls, eg.? Better separate the walls into an extra mesh and destroy the mesh parts, you receive a better control over the destruction process (Walls break differently than a roof) and you can control the destruction levels way better than destroying the whole house mesh. Also colliders will dont pose a threat to you and your environment.

Keep it simple, you want to destroy a dragon figure with wings, tail, horns and many legs. Well its perfectly possible, but Piecemaker works faster and better with low polygon meshs. Many polygons will result in a big memory footprint (the generated meshs need to be loaded from and saved to the harddisc) which increases the overall memory consumption of your application.

Also a fragmented high poly model will result in many triangles which need to be rendered, keep this in mind.

Mesh collider are fine but also very hard to calculate, try different collider settings to see what performes best in your environment. Even if piecemaker uses mesh colliders as default colliders, a box collider may be enough to satisfy your needs. Also its much faster on mobile plattforms.

Open world is nice, but keep your meshs closed.

1 Like

Hey… congrats on releasing the package!!

We just grabbed a copy and thought I’d shoot through some immediate feedback. It was no biggy, but when I first opened Piecemaker the panel was obscured by unity’s application bar. It might be some kind of dual monitor issue?? I’m running my main unity project window on my left monitor (which is my secondary monitor attached to my mac book pro), and have my dock running on my right (mac book pro screen), hence why the unity application bar is on the right screen. I’ll attach a screen grab from my macbook pro monitor so you can see what I mean.

Anyway, all that was need was to grab the bottom right corner to resize the panel and the whole panel snapped into view… now on to breaking stuff!!! Cheers!

Jason

Hello Marrrk,

sorry if I am just too decaffeinated to properly get this part, but - does this only work on primitive meshes or can I destruct a ā€œcomplexā€ hand-made (e.g. imported from Cheetah) and finished prefab as well?

Hello, thanks for your feedback.

@jrdata2k:
Thank you, I will have a look into this, I even have a slight idea what the problem may be.

@c-Row:
Yes, you can destroy complex objects, Iam sorry that this was not visible in the introduction video. But there are certain limitations:

  • currently no Bone data is supported → these data will be ignored, but everything else will work, so you can break it
  • meshs like a tube may cause problem with the calculation of the slice/cut area, in my test cases it was never a problem but theoretical it could happen. They will be destructable but you may see some strange triangles

wow this is awesome and just what I was looking for, however I did noticed there are no particles after breaking objects, is it possible to add particle effects to the destruction event?

Sure, but this needs some preparation, you can either create an own Prefab which you want to use as a template for every destructable/shard/piece or you could add an own Applicator class which will be called for every shard/piece, in this applicator you are able to add particle effekcts or whatever you want :slight_smile:

Hey Marrrk,

Getting some great results so far, but after having a bit of a play (and being a software coder) I thought I might offer some hopefully constructive reports/feedback:

• is there anyway that the load/save preset functionality can remember the previous folder that a save or load occurred in?
• if closing piecemaker could it produce a temporary preset, so that reopening it immediately reloads the same settings?
• I’m finding that after loading a preset it doesn’t always reload the correct mesh, it sometimes loads the next mesh in my list… if it’s any help, my fbx had two mesh objects, I had one previously selected, but the other is selected when reloading the preset.
• Also, reloading Material 2 seems to act a little strange… sometimes it doesn’t reload at all, it just says None with no material selected, but other times it says None but upon clicking the search icon I find that my material is actually selected, but remains saying None after selecting my material and closing the selection panel.
• would it be possible to optionally pass a prefab reference instead of just a mesh?
• I’m finding that only the first material on my mesh comes through, if you could add prefabs it might help adding multiple materials seeing as most prefabs generated from importing an fbx should have a mesh renderer with the array of materials assign to the mesh. At the moment I’m having to go in and reassign my second missing material to all of my shards
• Some of the explanations for the options/parameters in the piecemaker interface are little abstract, perhaps some examples might help with what they do or how they affect the end result – for instance the prefab template instruction talks about LevelPropertiyApplicators of which I’ve no idea what it refers to (also the word Property has a superfluous ā€˜i’ in its name).
• On the same note as above; After playing around I now understand perfectly what ā€˜levels’ mean… but at first it was not overly apparent what it meant… I think it was just a first impression thing.
• I’m still not sure what ā€˜search and split’ means??
• how does the prefab template work? Does it simply instantiate the prefab and add the created shard mesh to the instance? I’m sure I will figure it out, but again it’s not apparent how this will work without trying it first.
• is there a reason why the collider selection is MeshOrBox? I’m guessing the logic makes a smart decision about which is more appropriate, but could there be an absolute mesh setting, at least to use on level 1 shards.
• I’m finding that the uv’s generated for the cut material are applied nicely on one axis, but stretch on another… =) hehe, I just read your note re: how should uv’s be applied… lol … a set of cube, atlas, spherical uv mapping to add to the plane setting would be brilliant. However I have no idea about how to code this.
• when shards are generated is it possible to add an optional transform parent? I can see that adding them to the parent object they are generated from might cause undesired physics behaviours… but some way of organising them in the heirarchy view would be great.

Hopefully my tone wasn’t read as being rude, it’s hard to get that across in text… I hope it’s all constructive. Anyway, well done, I think with a bit of polishing it will be an even greater tool!! I might post more feedback after using it some more if you’d be interested.

Cheers!!

Jason

ps: I have got a couple of crashes, nothing too bad, but had one during a process calculation (I’ve only had around a 100 shards being generated)… another during a runtime test, which I think was after hitting stop then play pretty soon after.

Hey Marrrk,

One more for now:

• I find that I commonly need to regenerate a broken mesh until I get a ā€˜stable’ mesh… ie. for the ones that don’t work, I drop the level 0 prefab into the scene to see how it will hold up and some generated shard stacks must have several overlapping physics bodies and the entire mesh explodes… whereas after re-generating a couple of times I’ll end up with a more stable mesh. I know it must be difficult, but is there some way to ensure non-overlapping shards, perhaps a post calculation process.

Hello jrdata2k, thank you for your very very good and helpful reply.

I can save the folder and use the last used directory, its possible and I will add this into the next version.

I will add this feature, good idea.

Thats very strange, do both meshs share the same name or something like this? I will open a bug entry for this and investigate this problem.

Do you mean the second Mesh Material or the Cut Area Material, both cases are bad, I will investigate this.

I could use this prefab as prefab for each level and extract the mesh from the meshfilter for the Piecemaker processing step, is this ok?

This is a bug, a very strange one as I tested this feature, after selecting a mesh for every submesh a material slot will be created, do you mean you want a variable count of material slots? I can add this.

I will review the descriptions and create a document with more explainations and samples.
LevelPropertyApplicators are for example the ā€œDefaultā€ thingy you can check or uncheck on the right side of the Piecemaker Window, its a script class which will apply something for every shard, a coder/scripter can enhance this by inheriting from the base applicator class to do some custom stufff which is not covered by the default applicator I distribute with Piecemaker.

I will enhance the description of this, but I find it hard to explain more than currently.

If your mesh is build of for example 2 spheres, which do not touch each other, this option will create out of these both spheres 2 separate meshs, if you slice a castle horizontally and the upper part will consist of non connected towers, these option will create a separate meshs out of each of those towers.

Exactly as you describe it :slight_smile:

I dont understand this, could you elaborate this any further? MeshOrBox means that a meshcollider will be used, but when this fails for some reason a fallback box collider will be used.

I will have a look into this, at least its easy to create other UV mapping methods :slight_smile:

I see the benefit of this, I can add this feature, should not be too hard.

Yeah its very difficult as Unity does not provide any usable collider vs collider methods (aside from Bounds tests). One way could be to shrink the collider meshs, I wonder why this even occours, do you use MeshCollider (MeshOrBox) for this?

Mark

Hey Marrk,

I should have some time this evening to reply the above, however I have a more pressing issue at the moment. It seems that I can’t compile while the Piecemaker code is living with in my Project.

When I use Piecemaker to generate my destruction prefabs it works without errors (excluding any issues mentioned above). I can run the scene and it still all holds up. However when I try to do a build it fails (I’ll list the errors below). Which is odd, because:
• I don’t have the piecemaker window open while compiling
• all of my shards objects that I’ve generated don’t use any classes at all associated with piecemaker (I have my custom implementation of how the shards are to be used). I’m just using the mesh objects.

There should be nothing in my scene or project that is running or using piecemaker, which I would have thought would mean that those classes would not even be compiled into the build.

However it could be because I’ve added Piecemaker into the Assets/Plugins folder which makes the compiler treat the files differently. I’ll try moving the files. If the errors still occur I’ll be able to just use the piecemaker files in a ā€˜create destruction project’ that I bring the prefabs across into a production project, but I guess that does seem unnecessary. I’ll let you know on the outcome here.

^^^ After all of the above I just found this note on the EditorWindow doc page:
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add ā€œusing UnityEditor;ā€ at the beginning of the script.

This would probably explain the errors that I’ve received seeing as piecemaker scrips are mostly editor only scripts. I’ll try moving it into Assets/Editor folder. Here’s the errors (the one at the bottom of the list was received first):

Just to follow up to the above script location problem. I’ve tried moving the files around and it hasn’t really helped.

After purchasing PieceMaker, the import package dialog appeared and without changing anything (all items were selected), I confirmed the import. This added all of the packages files to this location:

Assets\PieceMaker
(with the package contents underneath the above folder)

  • Editor
  • PieceMakerSample
  • Scripts

I’m thought perhaps the extra root PieceMaker folder isn’t meant to be there. So that the editor scripts end up in Assets\Editor - or is there something that makes all subfolders called Editor live within the UnityEditor namespace?

I originally moved the files under Plugin because I’m mostly coding in unity javascript and wanted to make sure the c sharp scripts were compiled before js and didn’t know that editor scripts needed to be in a particular folder.

Anyway, after moving the files around and compiling again, I got almost the same 4 errors, except the last one was now this one instead:

)

It seems you need to add using UnityEditor to scripts maybe??

I’ve tried simply removing all piecemaker scripts to compile, but then all of the prefab shards that are generated from piecemaker have ShardContainer, DestroyWhenNotVisible PiecePureDestructable components added on the original prefabs which causes all other kinds of problems. I’ll need to write a script to run through and remove all of those components and update the prefabs.

Also to confirm:

• because I am coding in Javascript I do actually need to put the non-editor clases (the piecemaker files found in the Scripts folder) into Assets/Plugins so that they are compiled before JS is

ALSO … a note for anyone else reading this. Don’t let this turn you off Piecemaker – Marrrk has created a really great little tool. These are really just teething issues. It’s pretty great seeing some huge model you’ve created be totally destructed into tiny pieces!!!

I can confirm that blasting models is quite satisfactory and creating a game making use of this tool surely will add a great deal of interaction and visual richness!

I can recommend it to everybody, also because it’s completely scalable and useable practically in any situation.

Great job!

@jrdata2k: I will review this this evening and I hope to give you a solution for your problem. Its very strange that the UnityEditor namespace could not be found. At least it worked for me, but i understand the meaning of the errors. Maybe I need to rewrite some Base Classes for this, should not be hard, its only annoying.

Ok, I found the solution and I am terribly sorry for this kind of mistake. I have send you the updated version which includes some other improvements. As fast as the AssetStore Team reviews the fixed version it will be available to everyone else.

This was a very very bad mistake from my side, I missed to test something and now this happens.

Thanks Marrrk!! I understand the process and it’s pretty hard to be on top of all things that can go wrong. Thanks for looking into it!

I’ll still get around to responding to the first big feedback reply as soon as I can find a moment, cheers!!

Jason

I was building something like this myself, but ran into issues and sidelined it, looks like another purchase for me.

It should always fail… :stuck_out_tongue:
Mesh colliders are really slow and you should not use them for moving objects with a rigidbody… :wink: --Did you run a test to find out how much slower the mesh colliders are compared to a optimized compound collider which behaves basically the same ? :slight_smile: Why donĀ“t you use compound colliders ?

Would be a nice improvement for version 2.x of your asset… :smile:

Hi DynamicHead, the MeshCollider is optional, so you dont need to use this :slight_smile:

I know its slower than any other collider type, but for big shards (like a whole wall) it provides the best results. But I thank you for the idea with the compound colliders, I will make some experiments as soon as I can.

@ddesmond: What kind of issues?

Also here a little preview of something I will provide with the next version:
http://www.dras.biz/Slicer/WebPlayer.html

Its kind of buggy right now, but I think it shows something you might be interested in :slight_smile:

^^^ definitely, now it’s heading in the realms of Wii Sports Resort Fruit Ninja, nice one!