PDA

View Full Version : Random Particle Position and Goal Weight


ssprinkles
12-02-2008, 02:46 AM
Hi,

I'm fairly new to Maya dynamics and I'm trying to work on an effect where particles emit in random positions from a piece of polygon geometry and then when the geometry is animated, the particles stick to the surface.

I've found some great advice on how to make the particles appear in random positions... this is the expression I found on another thread:

$rows = 8;
$columns = 8;
particleShape1.goalWorldTangentU0PP = (trunc(rand(4)*($rows+1))/$rows);
particleShape1.goalWorldTangentV0PP = (trunc(rand(4)*($columns+1))/$columns);

...but when I turn the goal weight back on the particles all snap to a different and more uniform position.

If I am using a piece of geometry as a goal is it possible to have the particles appear in random positions? If it is possible, I would really appreciate any help with how to bring the two ideas together.

Many thanks in advance!

Aikiman
12-02-2008, 03:32 AM
Hi,

You can emit randomly from a surface using a surface emitter and if you want to limit the amount of particles just put a number in the max count on the particle shape. To make them goal at their points of emission you need to create a few particle PP attributes...those being parentU and parentV and also goalU and goalV. Then goal you particles to the object.

Then in creation expression write

parentU=rand(1);
parentV=rand(1);
particleShape1.goalV=parentV;
particleShape1.goalU=parentU;


that should work.

ssprinkles
12-02-2008, 05:33 AM
Thanks for the help but I think I'm still missing something. I was able to get the code you suggested to work and the particles did generate in random positions just as I hoped they would but when I raised the goal weight for the particles to 1 they all snapped from their random position and went to the bottom of the geometry.

How should I be attaching the goal weight after running the expression you showed?

Thanks!

Aikiman
12-02-2008, 06:19 AM
Thanks for the help but I think I'm still missing something. I was able to get the code you suggested to work and the particles did generate in random positions just as I hoped they would but when I raised the goal weight for the particles to 1 they all snapped from their random position and went to the bottom of the geometry.

How should I be attaching the goal weight after running the expression you showed?

Thanks!

Actually you need to create your goal first before you load the pp attrs and run your expression. However it sounds like you may be using nurbs? If so you might need to rebuild the surface so your UVs run from 0-1, that could be your problem. To double check run the code on a poly object and it should run fine.

ssprinkles
12-02-2008, 06:58 AM
Hi,

Thanks for working with me on this. I really appreciate your patience.

I've attached two images, hopefully this will help you see what I'm trying to do.

With the goal set at 0, the placement of the particles is perfect to me. It is very random and looks exactly as I hoped it would. This was done with your script and the goal being at 0.

In the second image the only difference is setting the goal to 1. The particle are still somewhat random but only on 1/2 of the model and the placement of the particles is a little odd.

What I am hoping to do is get the placement of the particles in the first image with the goal set to 1.

The geometry is polygons so I don't think that is the problem.

Any thoughts you might have would be really great.

Thanks again!

Aikiman
12-02-2008, 07:37 AM
Can you post the scene, Ill take a look.

ssprinkles
12-02-2008, 07:45 AM
Hi!

I posted the scene file to Rapidshare because it was too big for the forum. If you haven't used it before you need to wait 30 seconds or so before you download the file...

http://rapidshare.com/files/169423275/particle_test.zip.html

If you have any problem getting the file, please let me know.

Thanks!

Aikiman
12-02-2008, 08:03 AM
http://rapidshare.com/files/169426426/particle_test.mb.zip.html

Working file here hope this helps. You have the incorrect setup just slightly. I deleted all your expressions and you have to add per particle attributes goalU, goalV, parentU and parentV rather than create them as variables. Theres a part called Add Dynamic Attributes > Particle, you'll find them all there.

Hope that helps

ssprinkles
12-02-2008, 08:52 AM
This makes so much more sense now.

Thank you so much for your help! If you were in LA I would buy you a beer!

Thank you again and again!

CGTalk Moderation
12-02-2008, 08:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.