View Full Version : Particle Question:spriteTwist

 Antilles05 May 2003, 01:58 AMHello, i am making an animation of some titles that blow away like dust or smoke. (the title and particles will be composited later in another program via an animated mask) The particles are rendering as sprites with a small smoke .tga applied. At the present moment they change their scale and opacity as I want, and I have them all being created with a random twist applied, so no two sprites look too similar But i want to take it a step further. As the animation progresses, i want each sprite to randomly twist at a constant speed. To clarify, each sprite will rotate at a constant speed, but each sprites speed rotation and direction of rotation will be different and random. How would i do this? BTW, this is just for a friends project, not a film or something so I dont want it to be a huge long process, a quick line of code with an explanation is all thats required. Thanks a lot for reading!
svenip
05 May 2003, 08:20 AM
first you create two own attributes

myTwist (float - scalar)
myTwistPP (float - Per Particle)

and also create the build in twistPP;

creation expression :

myTwistPP = rand(-1,1) * myTwist;
twistPP = 0;

runtime expression :

twistPP += myTwistPP;

thats it. you can now adjust the twistSpeed by the extra attribute myTwist in the channelBox.

Antilles
05 May 2003, 04:01 AM
ok i will check this out and depending upon the result i get, i will choose whether or not to thank you for responding.

hehe im kust kidding, thanks for the help, im sure it'll work.

EDIT: do you mean spriteTwistPP instead of twistPP?

EDIT#2: It works perfectly, but i had to alter your expressions with the spriteTwistPP instead of TwistPP. Thanks a bunch, this is really cool!

so_hi
05 May 2003, 10:17 AM
//This answer is asuming that you have a lifespanPP on your
//sprites. I can explain it without but it is much more involved.

//particle1 is the name I am using for this script.

//You need to create these PP array atributes

//custom:
// holding
// holdTwist

//preset:
// spriteTwistPP
// lifeSpanPP

//Note:make sure you hit the add propertes for this particle type
//button before you start these expressions

//Creation
//First you need a random value that it is going to twist to
//over its lifespan.

\$picker = ceil(rand(0,2));

if(\$picker ==1)
particleShape1.holding = rand(20,180);
else
particleShape1.holding = rand(-20,-180);

//This method of randommizing allows you to have a minimum
//amount of twist (this case 20 degrees of twist +-), keeps the
//value from being too close to or equal to 0
//this value can be tweaked for how much twist you want on them

//next the random initial twist

particleShape1.holdTwist = rand(0,180);

//next this sets the actual spriteTwistPP to the holding value;

particleShape1.spriteTwistPP = particleShape1.holdTwist;

//lifespan set to a random value between .5 and 1 seconds or 12
//to 24 frames

lifespanPP = rand(0.5,1);

//end Creation ==================

//Runtime

//this expression twists the sprite over it's life time the amount
//kept in the holding array

particleShape1.spriteTwistPP = particleShape1.holdTwist + (smoothstep(0,particleShape1.lifespanPP,particleShape1.age)* particleShape1.holding);

//It is twisted in a function curve with a slow out and in

//Hope this helps.

//E.

//I commented everything you should be able to basically
//copy and paste this post into the expresion editor

CGTalk Moderation
01 January 2006, 03:00 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.

1