Maya Tutorials:explosion using particle instancer

| Comments (17)

In this tutorial I'm going to show you how to generate exploding pieces with particle instancer and particle expressions.


maya tutorial particle instncer explosioninstance a object to particles
maya tutorial particle instncer explosion
Select particle and object in this order
Particle > Instancer(Replacement)
The particles are replaced by the object.

The instanced geometry object can be
a single object, animated or not animated,
and can be a sequence of objects in different shapes or positions.


making exploding pieces

Emitte particles from sphere object as the above,
connect the particles with Gravity and Turbulance fields.

(For more explanation of particle,please refer to
Maya Tutorial:basics of particle)

maya tutorial particle instncer explosion
Make some splinter objects,
(in this example, I made 4 pieces of objects)
select all the objects and the particle in this order
Particle > Instancer(Replacement)


In this step, it seems that only one object is instanced to the particles.

maya tutorial particle instncer explosion
Select particleShape and open the Attribute Editor.
Click General button in Add Dynamic Attributes.

maya tutorial particle instncer explosion
The Add Attribute Window will open,
enter a variable name r_off in Attribute Name,
select Vector, Per Particle,
click Add button

Add Attributes r_spd and rot according to the same procedure as r_off.

maya tutorial particle instncer explosion
Add index attribute with Data Type Float.


maya tutorial particle instncer explosion
In Per Particle(Array) Attributes,
you can see the attibutes, index, rot, r_spd, r_off, are added.


maya tutorial particle instncer explosion
Open the Expression Editor
(Window > Animation Editors > Expression Editor...)

Select Object Filter > Dynamics > Particle,
select particleShape
select Creation radio button (to make Creation Expression), enter expressions below

index = id%4;
r_off = <<rand(6.28),rand(6.28),rand(6.28)>>;
r_spd = <<rand(6.28),rand(6.28),rand(6.28)>>*1;

Click Creat button.

(index = id%4;  4 is number of objects
r_spd = <<rand(6.28),rand(6.28),rand(6.28)>>*1;  1 is multiple of rotation
6.28 is one rotation for the unit of the radian
rand(6.28) a random floating point number between 0 and 6.28)


maya tutorial particle instncer explosion
Select Runtime before Dynamics radio button (to make Runtime Expression), enter expressions below

rot = r_off + r_spd * age;

Click Creat button.

maya tutorial particle instncer explosion
Select particleShape, open the Attribute Editor,
in instancer tab, set Rotation Angle Units to Radians

maya tutorial particle instncer explosion
In particleShape tab
set ObjectIndex to index, set Rotation to rot


Completed.

Copyright (C) 2009 by maya blog:3D CG labo, All Rights Reserved.

17 Comments

great toturial . i learned a lot . thanx

Thank you for your visiting my site and commenting.

Good work. I'm new to this field and your tutorial helped me a lot.

Thank you for your visiting my site and your commenting.

But when I create the expressions for particleShape1,the error report says"// Error: Attribute not found or variable missing '$': Id",there seems some problem with the scrpt "Id%4",can you explain how there comes a variable name "Id"?
Thanks.

I'm sorry very much.
I was wrong in the description.

Id should be a small letter id.
Or, please use particleId.

I corrected the description.

Great again. You should do a tutorial on hypershade. Nobody has done a great and simple explanation on how to make to texture leaves, rocks, or anything else not plastic.

Thank you for your comment again.
I will try to write about hypershade.

Recently, I am writing how to make the eyeball.
Please look at here.

Maya tutorials: making eyeballs and building its materials (1) simple method

Very nice tutorial and very helpful. Although it raises one question and it goes a little something like this: How do you stop the rotation after the instanced object collide with the ground(if you have one)?

Thank you for your comment and question.
I have not tested the collision of the instance.
It is a difficult problem for me.
I write here if it is possible to do.
But please do not expect me so much.

Thanks for the reply,what I do want to know is how to stop the rotation at a certain frame. Any ideas?

The "collisionTime" attribute is
more than -1
when the particle collides.

So, please add the "collisionTime".
(It is in the Particle Tab of the Add Attribute Window.)
And add new attribute "flag"
according to the same procedure as "index".

Add the below to the Creation Expression:

flag = 0;

Change the Runtime Expression:

if(collisionTime > -1) {
flag += 1;
}

if(flag > 0) {
velocity = <<0,0,0>>;
rot = <<0,0,0>>;
}
else {
rot = r_off + r_spd * age;
}

The instanced object will stop there
when it collides.
How about this method?
If this helps you, I am glad.

Hello, can you please post some more information on this topic? I would
like to read more.

I will.

Thank you for your comment

Hi Imanishi... Thank u for this great tutorial. I would be very greatfull, if you could explain more, when particle instances collide with ground. I tried it but it doesn't work. And if you can point me, how can i make it stop after 2 seconds when it collide?!? Thank u very much...

G.

Please add new attribute "stime"
and count frame 60,
then stop particle.

if(collisionTime > -1) {
flag += 1;
}

if(flag > 1) {
stime += 1;
}

if(stime > 60) {
velocity = >;
rot = >;
}
else {
rot = r_off + r_spd * age;
}

we can use "noise" instead of "rand()" function in the "Runtime before dynamics" section simaulating the same effect with less codes generated. For per partical micro simulation , we can use "(sind())+noise() or dnoise()"joined functions for the vector based simulation.

Although you did a great task, thanks!

Links

[privacy policy]
We use third-party advertising companies to serve ads when you visit our Web site. These companies may use information (not including your name, address email address or telephone number) about your visits to this and other Web sites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
QLOOKアクセス解析
search this site