Help with particle explosion


#6

So when I add the float of randYOrient in the creation do I write it like this–
Creation:
float $scaleNum = rand (.2,1);
float $randYOrient = rand(360);

particleShape1.customOrient =<<rand(360),rand(360),rand(360)>>;

particleShape1.customSpeed = rand(30,-30);

particleShape1.CustomIndex = rand(0,5);

particleShape1.customScale = <<$scaleNum,$scaleNum,$scaleNum>>;

Runtime:
particleShape1.customOrient += particleShape1.customSpeed;

if (particleShape1.velocity &lt;=.01)

particleShape1.customOrient = <<0,$randYOrient,0>>;

With the above expression I get this error “”$randYOrient" is an undeclared variable."


#7

no you will need to add it by way of the add attributes tab in your particle shape.
Make sure that you have float and PerParticle clicked on then add it that way. defaults to scalar which you dont want
by doing that the particle will understand its an attribute in creation and runtime.


#8

I created a PP attribute called randYOrient. After updating the code, I dont get an error this time but also I dont see any change, the instance geo is still rotating.

Here is a link to my maya file if you have the time that might help.
https://www.dropbox.com/s/gco1o7vw8rzbhym/ParticleExplosion2.ma

creation Expression :
float $scaleNum = rand (.2,1); particleShape1.randYOrient = rand(360);

particleShape1.customOrient =<<rand(360),rand(360),rand(360)>>;

particleShape1.customSpeed = rand(30,-30);

particleShape1.CustomIndex = rand(0,5);

particleShape1.customScale = <<$scaleNum,$scaleNum,$scaleNum>>;

Runtime:

particleShape1.customOrient += particleShape1.customSpeed;

if (particleShape1.velocity <= .01)

particleShape1.customOrient = <<0,particleShape1.randYOrient,0>>;


#9

im at work so i am unable to DL any files.

are your particles cached?
if no try increasing the number on the velocity and see if it makes a difference.

if you cant figure it out i could look tonight when i get home probably something simple now.


#10

I really appreciate the help you are giving me Mandark1011.

Increasing the velocity from .01 to .4 made the instanced geo stop rotating. Thank you :slight_smile:
Now the problem I am having is the instanced geo jumps to a orientation as it settles. Any ideas on how I could fix that ? Also once all the instanced geo settles it vibrates on the ground plane. I increased the GeoConnector Tessellation factor but that didn’t seem to fix the problem.

//youtu.be/frd1Tz5Rnuc


#11

the level of code needed to do that is beyond my ability. you may however find examples on this forum that could help point you in the right direction.

the vibration
Conserve should be set to around .98. 1 means that the particle doesnt lose any energy.
other than that you could set yoru velocity in runtime.
if (velocity <=.4)
{
cusRot << >>;
velocity = 0;
}

your welcome glad i could help you


#12

Thank you.
Adding the “particleShape1.velocity = 0;” to the runtime stopped the Geo from vibrating. Though everything that isnt on the collission plane will then slowly settles in posY until it reaches the ground plane.

I am trying to replicate this effect in maya http://www.youtube.com/watch?v=Io3r6-WOAdU
It gave me some instructions to follow but ultimately was very limited.


#13

one more thing to add to creation AND runtime
vector $pos = worldPosition;

now create a sphere or some geo and translate it just above the ground plane, make a note of its y translate

in runtime

if (velocity <=.4 && $pos.y <= “value of the y translate of your placement object”)
{
what you already have
}

this will only calculate that stop velocity snap to custom orient once the TWO criteria have been met
so stuff in the air will be fine to keep going


#14

nParticles has a feature that computes rotation values based on spherical collisions. (for roundish shapes it can work well). This would be easier than managing your own expressions.
Here is the general workflow:

  1. Select object(s) to instance followed by nParticle shape then do instancer menu.
  2. On particle shape enable “compute rotation” (under rotation block)
  3. Under instancer block set Rotation to “rotationPP”, also enable “allow all data types” and set scale to radiusPP, which will then scale the objects to the particle sizes.
  4. Make sure collisions are on for the particles… self collisions also work for the rotations.

You can set the initial spin when particles are created with a creationExpression for angularVelocityPP:

float $rotSpeed = 1.0;
nParticleShape1.angularVelocityPP = << rand($rotSpeed), rand($rotSpeed), rand($rotSpeed) >>;

Note that if the particles are self colliding the collisions when they overlap when emitted from a point emitter could cause strong rotations.


#15

Thanks for contributing to this thread Duncan. I tried using nParticles and it was a lot easier to get the animated rotations on all the instanced geo. It even settled once the nParticle came to a stop. The only thing it was missing was each instanced piece of Geo felt like it was contained in bounding sphere, so it didn’t roll like a organic shape. Maybe I need to use rigid bodies to get real shape detection ? Also, I didnt understand what the angularVelocityPP code would do. it seemed to have no effect so I left it out. Maybe I was not implementing it right.

And Mandark1011. Again I say thank you for all your help yesterday. With that last piece of code I was able to make all the geo settle to the ground plane but as you can see from the animation I was never able to get the instanced Geo to roll to a natural stop.

From my short time trying to get this effect I would say that nParticles got me a lot closer to the result I was looking for than particles. But neither approches was getting me this result http://www.youtube.com/watch?v=Io3r6-WOAdUHow do you guys think this was achieved nParticles, particles or rigidBodies

//youtu.be/jq_o7dInx1g


#16

glad to help. Yes nParticles are vastly superior to vanilla particles, I rarely use the original ones anymore except in cases where I need vast numbers.

for this type of effect you should probably use a rigid solution for the larger non rubble type pieces. I mostly use instanced debris as small scale filler on effects like this, like little rocks to fill the explosive volume rather than the hero pieces. the spherical collisions are unfortunately all thats available right now but Duncan is workign on something that mimics rigid collisions with Nparticles hopefully we will see something soon :slight_smile:


#17

Mandrak you are indeed a very helpful and nice nature person I have to admit here that you always listen and reply , no matter how long the thread extends in returns of urs help.I also have to respect the patience you have for learners.

Duncan also he is the god on this planet of Maya.

Sir Duncan God gives u more strength and passion to create the impossible and to beat the Houdini.


#18

I’ve attached a simple scene that roughly matches that reference one( there is a old style particle tutorial mention for that scene, by the way, but it seems a bit more complicated than using nParticles ).

I think the main things are getting the scale of the instances about right with respect to the particle radius values, and controlling friction with the surface, bounce, particle size range, drag, emission speed values, etc. The rotation block has parameters that control how much particles slide vs rotate when they collide, as well as how much the rotation slows down when in free fall.

If you are going to have very large irregular chunks then those chunks might be better done with rigids… or perhaps nCloth, which will better collide with nParticles. But keep the smaller bits using the instance technique.

That expression was just to intialize the rotations. In an explosion like this the particle tend to self collide at the start frame which gives them randomized rotations and rotational velocities. However with that expression you could really make them spin fast (or not spin at all) if you wanted. The angularVelocity is the rotational velocity. If you wanted the particle to stop rotating on collision totally you could do stuff like making the angular velocity zero.


#19

You might also check out this thread:
http://forums.cgsociety.org/showthread.php?f=86&t=1095414&highlight=casings

The scene file shellCasings.ma is also available here:
http://area.autodesk.com/blogs/duncan/scene-files-from-my-maya-2014-unfold-presentation


#20

Hi,
I am back with some more questions.
So now I have got a Geo Instance explosion kind of working I now want to create a nParticle trail from each piece of instanced Geo, Another way of explaining this is I want my particles to emit particles. And I was able to do this by selecting my particles and going emit from object. The problem I have now as you can see in the video; The particles continue to emit even after the source particle has landed. Can some one tell me how I can make these particle stop emitting after the source particle has settled.

//youtu.be/JlaNg9dNWK4


#21

This is awesome Duncan !! Thank you.
The thing that isn’t awesome is I am not able to view the expressions, is it because you created this in 2014 and I have 2013 ?


#22

Oh… somehow I must have deleted that expression… its not in the scene( the self collision at the start emission will cause rotations, anyways).

At any rate here it is…(a creation expression):

float $s = 2.0;
angularVelocityPP = <<rand($s),rand($s),rand($s)>>;


#23

I think you didn’t write any expressions for this effect? It’s all achieved by plugging in and tweaking existing nParticle attributes, correct ? I say that because I can’t see any custom expressions.


#24

That’s right… no expressions needed. The expression is just to show how one can control the rotational speed. Particles automatically rotate on collision and self collision. The particles have rotational velocity at the start even without that expression because they are in self collision at the start frame. A limit with using the built in rotation feature is that collisions are spherical only and don’t use the geometry of the instanced object.


#25

Also you asked about stopping secondary particle emission when particles stop moving. Probably the best is to control the emission rate based on the speed of the particle so when they stop moving they stop emitting.

Select the secondary emitter and do nParticles:“Per-Point Emission Rates”. This will create a per particle attribute with the emitter’s name on the first particle system. You can then do a runtime expression to set emission from velocity:

float $rate = 2.0;
emitter2RatePP = mag( velocity ) * $rate;