  | | | Instanciated particles fade on impact | Instanciated particles fade on impact 2005-05-18 - By Bradley R. Gabe
Back Hi Alex-
It may be possible to do what you want all in particle land, but if you can't get this working, you could try using the CGS_PlotParticles plugin available at our site (www.cg-soup.com/downloads/plotparticles.zip)
If I had to do what you were doing, I'd probably duplicate my blossoms, then make sure each one has a unique material. I would write a script that would determine the frame at which the blossom hit the ground or were close to the ground, then set keys on transparency. The script loop would look something like this:
// Get the current selection and frame range var coll = GetValue('SelectionList'); var Fs = GetValue('PlayControl.In'); var Fe = GetValue('PlayControl.Out');
// Set the distance for testing object near ground var range = 0.1;
// Set the timespan in frames for fading transparency to 0 var span = 30;
// For each frame, test every object for(var frame = Fs; frame<=Fe; frame++){
// Check each object from selection for(var i=0; i<coll.count; i++){
obj = coll(i);
// If the object is less than range... if(obj.kinematics.global.posy.value < range){
// Get a pointer to the material transparency... // This will vary based on your own material setup // In this case, there is a constant material connected directly to the material input var mat = obj.material; var transR = Dictionary.GetObject(mat + '.Constant.transparency.red'); var transG = Dictionary.GetObject(mat + '.Constant.transparency.green'); var transB = Dictionary.GetObject(mat + '.Constant.transparency.blue'); var transA = Dictionary.GetObject(mat + '.Constant.transparency.alpha');
// Build an array of keyframes for fadeout var keyArr = [frame, 1, frame + span, 0];
// Apply the keyframes to the trans params transR.AddFcurve2(keyArr); transG.AddFcurve2(keyArr); transB.AddFcurve2(keyArr); transA.AddFcurve2(keyArr);
// Remove the object from the collection so it doesnt set keys again coll.Remove(obj); } } } // End Script
Sorry about the pitch... but for those who run into situations like this a lot, or other situations that need more involved scripting or custom tools to help out of a jam, you can subscribe to our Cuppa Soup service.
-Brad CG Soup
>Sorry to bother you all again.. in particle hell at the moment !!! > >After semi succesfully creating my trees, the client has decided she >wants blossom to fall from the trees... > >I have it going pretty well.. I have 14 different blossom shapes which >are being instanced.. however when they hit the floor, I want them to >stick then fade away. >If they weren't instnaces I would just alter there alpha levels.. but >as they are instance I cant get that to work ??? > >Is this possible.. and if so can some one give me a few pointers please !! > >thanks in advance > >-- >kind regards > >Alex Dinnin > >--- >Unsubscribe? Mail Majordomo@(protected) with the following text in body: >unsubscribe xsi
<html> <body> Hi Alex-<br><br> It may be possible to do what you want all in particle land, but if you can't get this working, you could try using the CGS_PlotParticles plugin available at our site (<a href="http://www.cg-soup.com/downloads/plotparticles.zip" eudora="autourl" >www.cg-soup.com/downloads/plotparticles.zip</a>)<br><br> If I had to do what you were doing, I'd probably duplicate my blossoms, then make sure each one has a unique material. I would write a script that would determine the frame at which the blossom hit the ground or were close to the ground, then set keys on transparency. The script loop would look something like this:<br><br> <font face="Courier New, Courier">// Get the current selection and frame range<br> var coll = GetValue('SelectionList');<br> var Fs = GetValue('PlayControl.In');<br> var Fe = GetValue('PlayControl.Out');<br><br> // Set the distance for testing object near ground<br> var range = 0.1;<br><br> // Set the timespan in frames for fading transparency to 0<br> var span = 30;<br><br> // For each frame, test every object<br> for(var frame = Fs; frame<=Fe; frame++){<br> <x-tab> </x-tab><br> <x-tab> </x-tab>// Check each object from selection<br> <x-tab> </x-tab>for(var i=0; i<coll.count; i++){<br> <x-tab> </x-tab><x-tab> </x-tab><br> <x-tab> </x-tab><x-tab> </x-tab>obj = coll(i);<br><br> <x-tab> </x-tab><x-tab> </x-tab>// If the object is less than range...<br> <x-tab> </x-tab><x-tab> </x-tab>if(obj.kinematics.global.posy .value < range){<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab><br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// Get a pointer to the material transparency...<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// This will vary based on your own material setup<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// In this case, there is a constant material connected directly to the material input<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var mat = obj.material;<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var transR = Dictionary.GetObject(mat + '.Constant.transparency.red');<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var transG = Dictionary.GetObject(mat + '.Constant.transparency.green');<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var transB = Dictionary.GetObject(mat + '.Constant.transparency.blue');<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var transA = Dictionary.GetObject(mat + '.Constant.transparency.alpha');<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab><br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// Build an array of keyframes for fadeout<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>var keyArr = [frame, 1, frame + span, 0];<x-tab> </x-tab><x-tab> </x-tab><br><br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// Apply the keyframes to the trans params<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>transR.AddFcurve2(keyArr);<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>transG.AddFcurve2(keyArr);<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>transB.AddFcurve2(keyArr);<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>transA.AddFcurve2(keyArr);<br><br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>// Remove the object from the collection so it doesnt set keys again<br> <x-tab> </x-tab><x-tab> </x-tab><x-tab>   ; </x-tab>coll.Remove(obj);<br> <x-tab> </x-tab><x-tab> </x-tab>}<br> <x-tab> </x-tab>}<br> }<br> </font>// End Script<br><br> <br> Sorry about the pitch... but for those who run into situations like this a lot, or other situations that need more involved scripting or custom tools to help out of a jam, you can subscribe to our Cuppa Soup service. <br><br> -Brad<br> CG Soup<br><br> <blockquote type=cite class=cite cite="">Sorry to bother you all again.. in particle hell at the moment !!!<br><br> After semi succesfully creating my trees, the client has decided she<br> wants blossom to fall from the trees...<br><br> I have it going pretty well.. I have 14 different blossom shapes which<br> are being instanced.. however when they hit the floor, I want them to<br> stick then fade away.<br> If they weren't instnaces I would just alter there alpha levels.. but<br> as they are instance I cant get that to work ???<br><br> Is this possible.. and if so can some one give me a few pointers please !!<br><br> thanks in advance<br><br> -- <br> kind regards<br><br> Alex Dinnin<br><br> ---<br> Unsubscribe? Mail Majordomo@(protected) with the following text in body:<br> unsubscribe xsi</blockquote></body> </html>
|
|
 |