shatter help


#261

Hey brjig,
sounds like you have an installation problem. First you notice there are two scripts, one is mel for the GUI, the other is Python for the functions. You have the mel script installed ok because the GUI works, so the problem is with your python installation. It is not necessarily the case that you can run python scripts from your script folder.
Obviously, have a look at the docs, but in brief the simplest way is to set the python path in your maya.env file. this can be found on osx in :

~/Library/Preferences/Autodesk/maya/2009/maya.env

it may not be there already so just make a plain text file and save as maya.env , you might have to check permissions on that folder.

in the content of the maya.env file is where you designate your python path (for maya).

so have a line similar to:

PYTHONPATH = /Users/davegreenwood/dev/python

which in my case is a folder I created in my home directory, but can be anywhere you like, you could set your mel scripts folder.

I’m sure this is your problem, good luck.

Dave.


#262

YAY, I got it to work.
it was a installation thing.
okay okay, I knew about the maya.env, but never have I used it, Im just starting to use the userSetup.mel to source scripts and all that.

But it works, and works perfectly. Thanks alot.


#263

Hm… I seem to be having a few problems trying to get it to work as well, I do believe mine is installed properly however.

I keep getting this error in the script editor when I click the Voronoi Shatter button.


 # Error: line 94: list index out of range
 # Traceback (most recent call last):
 #   File "<maya console>", line 1, in <module>
 #   File "C:\Documents and Settings\shall\My Documents\maya\2008\pythonScripts\dg_voroPy.py", line 399, in doVoro
 #	 points = locToPointMVector(sel[1])
 # IndexError: list index out of range # 
 

So, I’m trying to simply break a cube. My steps are, create a cube. Create a volume emitter with no speed (ie particles emit and don’t go anywhere). I then select particles and click the Particles to Locators button. After that I select the cube then select the particles and click the Constrained Particles to Locators (based on what Highend3D says to do). After that I assume I click the Voronoi Shatter button but upon doing so the error above pops up. I’ve tried different combinations with things selected as well, like the cube and then the shatter button, the particles, the locators, the locator group… etc… They all produce that error.

What am I doing wrong? :frowning:


#264

Hi Seth, looks like it’s my poor documentation that got you :slight_smile:

the locator tools are alternative, most of the time you will want to use the constrained version where you select your mesh then shift select your particles, hit the button and get locators inside the mesh.

if you had a slender branched object to break up, or something with thin wall thickness, you might not want to have your locators constrained within the mesh (it’s not necessary for the script to work), then use the plain particles to locators.

After you have used one of these utilities to create a group of locators, in the outliner select your mesh to break, then shift select your locator group. then it’s time to hit the shatter button.

The script does use the bool-op once per cell, so it’s very important to have clean geometry. Also make sure you have no construction history on your mesh to break, or you’ll get a lot of empty transforms at the end.

BTW if anyone has a solution for those residual transform nodes that get left after using an object with history, I’d like to hear about it. It’s certainly not as simple a problem as it appears.

Anyway Seth, hope this gets you going.
Dave.


#265

why don`t you delete history on the object prior making the cuts ?


#266

That works of course, but I decided not to delete history on the original object, instead leaving that to the user to decide. The script duplicates the original object for every cell but oddly when you delete the history on each of those duplicates, you still get all the empty transforms. Of course all history is turned off for operations in the script. I think I’ll have to explicitly delete upstream nodes on the duplicates… just haven’t really had time to look into that yet. Have a look through the script and see what you think.

Dave.


#267

You could perhaps make it optional in the GUI near the Shatter button. A checkbox that, when checked ON would delete the history on said geometry before shattering otherwise off by default (which leaves history in tact).


#268

Would much rather have history deleted. Auto deleting history should result in a slight speed boost as well. So dave, I haven’t had much free time to look at your script, but I know you were using a bounding box method to determine if a cut should be made or not, am I correct? If so are you determining if the cut plane intersects the bounding box? If so what is your solution?


#269

Very nice. Those directions made it work like a charm! Awesome work. If you don’t mind, I may tinker with the UI and add some error checking to help simplify the process?


#270

Michael, here’s what I did…

1, pick the first point from the list of all points (pos A)

2, create a virtual cube around that point, much smaller than the bb of the shattered object.

3, see if any points are in the virtual cube, if not make the cube bigger, if there are, make cuts.

4, after a cut, which obviously reduces the size of the object, check the maximum distance pos A could travel in the BB of the object. Double this distance to make a check radius.

5, exclude all points from the initial list that have already been used, or are outside the check radius.

6, expand the virtual cube and repeat steps 3-6, stop when the virtual cube is bigger than the check radius.

7, the first cell is done, so move onto the next…

basically, the idea is to start cutting from the points that are close to the cell centre (ie within the small virtual cube) so as to quickly reduce the size of the object’s BB ( and therefore quickly exclude too distant points).

Using python was nice for this method as it has great stuff for lists like:

if point in list: or if point not in list:

stuff like that is pretty tricky in mel…

hope that helps

Dave.


#271

go for it Seth, I didn’t put much into the UI so for sure it could use improvement. Also I made this on a mac which does have a few issues with mel UIs ( text alignment and so on).

Let us know how you get on.

Dave.


#272

Cool, I’ll give it a shot… I do know that a few of my UIs in the past have not been mac maya friendly :slight_smile:


#273

seth you/we & dg should combine those scripts we’ve been working on to a shatter dynamics tool.

Dave I’ve been sending Seth some updated scripts to add to his destructor.mel script found on highend3d. basically add nparticles scaled to a % of the BB of the inst debris on each piece, also a script to bake out the result back to regular geometry keys. This makes for a no plug-in, good enough for most shots, fake RBD instanced setup. so they are not colliding with only there center point. and any horrible bad collisions can be fixed once it’s keyed back out. I also could auto run a simplify curve on the bake tool…



//custom PP attrs
//float randPosNegRot
//vector instRotation

 //creation expression
 //collision scale
 int $p = dest_instShape.particleId;
 dest_instShape.radiusPP = ($size[$p])*.5; 	
 //creation dest_instShape
 vector $velocity = dest_instShape.velocity;
 float $angBet[] = `angleBetween -euler -v1 1 0 0 -v2 ($velocity.x) ($velocity.y) ($velocity.z)`;
 dest_instShape.rotPP = <<0, 0, 0>> ;
 dest_instShape.rotPPrate = << $angBet[0] , $angBet[1], $angBet[2] >>;
 
 
 //runtime
 float $mag = mag(dest_instShape.velocity);
 vector $velocity = dest_instShape.velocity;
 float $angBet[] = `angleBetween -euler -v1 1 0 0 -v2 ($velocity.x) ($velocity.y) ($velocity.z)`;
 dest_instShape.rotPPrate += (<<0, 2, 0>>) * $mag;
 dest_instShape.rotPP = (<< $angBet[0] , $angBet[1], $angBet[2] >>) + dest_instShape.rotPPrate;
 
 
 //global float array for nParticle rough scale collisions
 //loop through inst bounding box size set particle id'd radius to size
 string $instObj[] = `listConnections -s on -d off -t transform inst`;
 int $count = size($instObj);
 int $countMinusOne = $count - 1;
 global float $size[];
 int $t = 1;
 for($i = $countMinusOne; $i >= 0; $i--, $t++)	{
 	
 	float $bbox[] = `exactWorldBoundingBox ("instChunk" + $t)`;
 
 	float $magMinBox = mag(<<$bbox[0], $bbox[1], $bbox[2]>>);
 	float $magMaxBox = mag(<<$bbox[3], $bbox[4], $bbox[5]>>);
 	float $boxAvg = ($magMinBox + $magMaxBox)/2;
 	
 	//error correct for no bounding box
 	if ($boxAvg > 1000000000)	{
 		$boxAvg = .001;
 	}
 	
 	$size[$i] = $boxAvg;
 	print ($i + " = " + $t + " = " + $boxAvg +"
");
 
 }
//bake out nParticle sim animation

//for each inst obj
string $instObj[] = `listConnections -s on -d off -t transform inst`;

//duplicate, 
string $dupInstObj[] = `duplicate -rr $instObj`;
group -w -n bakedInstSim $dupInstObj;

//bake to keys
float $currentMinTime = `playbackOptions -q -minTime`;
float $currentMaxTime = `playbackOptions -q -maxTime`;

for ($f = $currentMinTime; $f <= $currentMaxTime; $f++)	{
	//move, rotate to particle point, key
	int $i = 0;
	for($obj in $dupInstObj)	{
		//move
		float $pos[] = `getParticleAttr -at position dest_instShape.pt[$i]`;
		move -absolute $pos[0] $pos[1] $pos[2] $obj;
		
		//rotate
		float $rot[] = `getParticleAttr -at instRotation dest_instShape.pt[$i]`;
		rotate -absolute $rot[0] $rot[1] $rot[2] $obj;
	
		//key
		setKeyframe -at "tx" -at "ty" -at "tz" -at "rx" -at "ry" -at "rz" $obj;
		playButtonStepForward;
		$i++;
	}
}	


 

it’s hacky at this point, altho working. This is the best so far of the rotation expression I’ve gotten. The hard thing about faking RBD rotations is that when they settle in a group they do a lot of quick directional changes that are hard to cut out. Needs to be better.


#274

I am going to try and integrate your changes this weekend at home. I was thinking about this today oddly enough and wanted to ask Dave if he’d be opposed to integrating the Voronoi Shatter stuff into it to try and encompass a whole shatter/instance/sim script without use of plug-ins …


#275

Dave, Seth, that sounds like a great idea.
I have a couple of ideas to fold into that shatter script too. I was going to add some option to put some vertex noise on the cut faces for one.
It looks like this thread has a lot of life in it yet.

Cheers
Dave.


#276

Hey guys, I’ve been using the voronoi script since the first iteration was posted on this thread, and I love it. I appreciate the work you are doing and am anxiously waiting to see what you guys come up with.


#277

If there is anything I can help out with, lemme know.


#278

I came up with another idea :smiley: based heavily on Duncan’s blog post Coins With nCloth. Won’t work in all cases but it will work in some very well.

Shatter a wall with some crack offset, delete all faces except front viewable front faces, do coin technique.

The geo boarders won’t line up once you extrude you’d only to this technique to the areas that are going to be dynamic, and the crack offset is tricky to get right since it will determine how thick the wall can be with self collisions on (my test I turned it off)

The attached file (maya2009) is by no means awesome, it’s just testing the idea/showing it work.

Quick playblast of the test in a earlier state.


#279

UI is much more streamlined and script is much less confusing. This should help aid in understanding the process of shattering now since you don’t need to worry about essentially what you’re selecting. I’ll have the scripts up here tomorrow.

Dave G, I had to make a few very tiny tweaks to the .py script to get the UI to talk to the python def’s … Nothing major though.

Seth


#280

Looks like I was able to get the last few things smoothed out. If there is any glaring problems, please let me know. Here is the updated scripts. To run just source the dg_voro_py_UI.mel script and it will bring the UI up automatically. I also placed this command on my shelf (as long as the script is in your proper /scripts folder) to fire it …


   eval("source \"" + `internalVar -usd` + "dg_voro_py_UI.mel\"");
   

To make the difference in filename I’ve added ‘shUI’ to the zipfile so there is no confusion in the previous version(s).

When loading, this is the UI. Select your Mesh and click the ‘Set’ button.

I added a button to create a Cube Volume emitter with no speed and 0 on the Particle conserve, this way you get static particles off the bat. If you use this button it will also add the new emitter & particles to the proper fields making it easier to select and not having to find them in the viewport or outliner.

Once you’ve got those two elements just hit play and create some particles. If your particles live outside the volume of the mesh use Constrained Particles to Locators otherwise if they’re all safely inside the mesh volume use the Particles to Locators button. Once your Locators are created it will auto-stick the locator group name into the Locator Group field.

If you have a mesh, particles, emitter or locator group already in the field. You can easily wipe them by hitting the Clear button or Select to select those objects if there is something submitted.

As Dave has mentioned, all you need is the Mesh and Locator group, once you have that click Voronoi Shatter. I’ve added error checking so you can’t really do much until you provide the proper data to the right fields. Hopefully this also helps create less confusion on usage too!


I meant to include a checkbox that was defaulted off, that if you check on would automatically delete the history on said geometry. If this is desired I will add it in.