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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2012   #1
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.goalV=0;
particleShape1.goalU=linstep(0,19,particleShape1.p  articleId);
}

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

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

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

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

if(particleShape1.particleId>99 && particleShape1.particleId<120) {
particleShape1.goalV=0.25;
particleShape1.goalU=linstep(100,119,particleShape  1.particleId);
}
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 03 March 2012   #2
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.
__________________
www.renderwiki.com - www.openmaya.net

Last edited by haggi : 03 March 2012 at 09:30 AM.
 
Old 03 March 2012   #3
You make it look so easy, thanks heaps.
__________________
www.jeremyraven.co.nz
Vimeo
 
Old 03 March 2012   #4
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 08:45 PM.


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