Particle creation expression algorithm

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2012
Particle creation expression algorithm

Im playing around sticking particles to goalU and goalV on a planar surface but rather than have them randomly placed, I want them in an ordered fashion just as if I was to goal them to the vertices. The point is I dont want them on the vertices, I want them on the UVs.

Okay so I came up with a crude looking expression in creation (and it works) but Im wondering if there is a better algorithm out there. I guess I could try and call a procedure from outside but can this be done and is it wise?

The following code basically checks the particle ID using a series of if statements and adjusts parameters accordingly, the problem is I would need to write this out 20 times. It would be nice if it was more user friendly.

if(particleShape1.particleId<20) {
particleShape1.goalU=linstep(0,19,particleShape1.p  articleId);

if(particleShape1.particleId>19 && particleShape1.particleId<40) {
particleShape1.goalU=linstep(20,39,particleShape1.  particleId);

if(particleShape1.particleId>39 && particleShape1.particleId<60) {
particleShape1.goalU=linstep(40,59,particleShape1.  particleId);

if(particleShape1.particleId>59 && particleShape1.particleId<80) {
particleShape1.goalU=linstep(60,79,particleShape1.  particleId);

if(particleShape1.particleId>79 && particleShape1.particleId<100) {
particleShape1.goalU=linstep(80,99,particleShape1.  particleId);

if(particleShape1.particleId>99 && particleShape1.particleId<120) {
particleShape1.goalU=linstep(100,119,particleShape  1.particleId);
  03 March 2012
Is it correct that you want to create a grid of particles on your surfaces with 20 particles in u and 20 in v direction?

If yes than I'd try something like this:

 float $uStep = (float)(particleId % 20)/20.0;
int $vInt = (int)((float)particleId /20.0);
float $vStep = (float)$vStep/20.0;
 goalU = $uStep;
 goalV = $vStep;

With the modulo sign (%), uStep should vary from 0 - 1.0 for every 20 particles and vStep goes from 0 - 1.0 as well but will increase only every 20th step.
__________________ -

Last edited by haggi : 03 March 2012 at 09:30 AM.
  03 March 2012
You make it look so easy, thanks heaps.
  03 March 2012
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:05 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.