  | | | setting initial state on particles (age lost?) | setting initial state on particles (age lost?) 2005-02-19 - By Vince Fortin
Back Sorry I made a big copy/paste mistake... time to get some sleep I guess. The scripted events should read like this:
' // pEvent that retrieves the age% values of the Cloud_InitState and copy it to a pp User Parameter: ' // Every N=1 frame ' // VBScript ' // Per Cloud set oCloudInit = Dictionary.GetObject("cloud_InitState") if InSimFrame = 1 then for i = 0 to oCloudInit.Particles.count -1 set oParticle = oCloudInit.Particles(i) oParticle.attributes("InitAgeNormalized").value = oParticle.Age / oParticle.AgeLimit next end if ' // end
' // pEvent that increments the size using both Cloud and Cloud_InitState age values: ' // Every N=1 frame ' // VBScript ' // Per Particle set oCloudInit = Dictionary.GetObject("cloud_InitState") Age = inParticle.Age AgeLimit = inParticle.AgeLimit if inParticle.Id < oCloudInit.Particles.Count then InitAgeNormalized = oCloudInit.Particles(inParticle.id).attributes("InitAgeNormalized").value inParticle.Size = ((Age / AgeLimit)+ InitAgeNormalized) * 3 ' // end
On Sat, 19 Feb 2005 19:05:42 -0500, Vince Fortin <vfortin@(protected)> wrote: > Hello Sean (and Aloys)! > As mentioned on this list a couple of days ago, you cannot modify the > particle Age value. For some reasons it makes xsi crash! > > What happens when you set an Initial State to a particle Cloud is all > Age values are zeroed and the remainder of each particle's life (in > frames) becomes their new AgeLimit. > Thus, as an example: > particle ID 0 : 20 / 48 (42% of its life) becomes particle ID 0 : 0 / > 18 (0% of its life) > particle ID 1 : 11 / 55 (20% of its life) becomes particle ID 1 : 0 / > 44 (0% of its life) > particle ID 2 : 3 / 51 ( 6% of its life) becomes particle ID 2 : 0 / > 48 (0% of its life) > > Not very convenient I agree! > But there's a solution. Maybe it's not the best but it's working so far... > > Forget about fcurves. You cannot rely on them anymore for the reasons > stated above. You'll need to control your size -or any other > attribute- with scripting. If this is not possible in your shot then > ignore the whole workaround! For this example, we will create a simple > expression to increment the size according to the age%. > > 1) Ok, in your pType, create a float User Parameter named "InitAgeNormalized". > > 2) Then all you need is two simple pEvents: > > ' // pEvent that retrieves the age% values of the Cloud_InitState and > copy it to a pp User Parameter: > ' // Every N=1 frame > ' // VBScript > ' // Per Cloud > set oCloudInit = Dictionary.GetObject("cloud_InitState") > Age = inParticle.Age > AgeLimit = inParticle.AgeLimit > if inParticle.Id < oCloudInit.Particles.Count - 1 then > InitAgeNormalized = > oCloudInit.Particles(inParticle.id).attributes("InitAgeNormalized").value > inParticle.Size = ((Age / AgeLimit)+ InitAgeNormalized) * 3 > ' // end > > ' // pEvent that increments the size using both Cloud and > Cloud_InitState age values: > ' // Every N=1 frame > ' // VBScript > ' // Per Particle > set oCloudInit = Dictionary.GetObject("cloud_InitState") > Age = inParticle.Age > AgeLimit = inParticle.AgeLimit > InitAgeNormalized = inParticle.attributes("InitAgeNormalized").value > inParticle.Size = ((Age / AgeLimit)+ InitAgeNormalized) * 3 > ' // end > > As you can see it's pretty straight-forward. The new particles will > see their age% added with their corresponding old particle's age%. > That means they Init with the correct size value and it will continue > to evolve in time. > Some lines in there will cause errors until you actually SET an > Initial State so feel free to quote them out or mute until you're > ready to initial state your work! > > Any questions? Hope this makes sense, I find it more difficult to > explain than set up ;) > > Vincent > > On Fri, 18 Feb 2005 13:54:27 -0600, Sean Dunn > <sean@(protected)> wrote: > > If I attempt to change the age of my particle through a particle event, > > it crashes XSI. This happens in 4.0 and 4.2. Here are examples of what > > I've been trying, and the result. My test case is just a grid emitter > > that increases particle size with age, with a initial state set at frame > > 40. > > > > Albeit, I just learned how to do particle events today.. Anything I'm > > doing that's obviously wrong, that would obviously *crash* XSI? > > > > // This just causes an error, in the AgeArray assignment. As far as I > > can > > // tell with Jscript, AgeArray contains nothing, on either side of > > // the assignment. > > //Every N=1 frame event > > //Per cloud trigger > > //Code: > > if(inSimFrame==1) > > { > > var init_cloud = Dictionary.GetObject("cloud_InitState"); > > inParticleCloud.Particles.AgeArray = init_cloud.Particles.AgeArray; > > } > > > > // Crashes XSI > > //Every N=1 frame event > > //Per triggered particle > > //Code: > > if(inSimFrame==1) > > { > > inParticle.Age = 10; > > } > > > > // Crashes XSI as well > > //Every N=1 frame event > > //Per cloud trigger > > //Code: > > if(inSimFrame==1) > > { > > var init_cloud = Dictionary.GetObject("cloud_InitState"); > > var dC; > > for(dC=0; dC<inParticleCloud.Particles.Cloud; dC++) > > { > > if(dC<init_cloud.Particles.Count) > > { > > inParticleCloud.Particles.Item(dC).Age = > > init_cloud.Particles.Item(dC).Age; > > } > > } > > } > > > > -- --Original Message-- -- > > From: Aloys Baillet [mailto:aloys.baillet@(protected)] > > Sent: Friday, February 18, 2005 10:55 AM > > To: XSI@(protected) > > Subject: Re: setting initial state on particles (age lost?) > > > > I think the error could come from the fact that the simulated cloud > > and the InitState cloud had not the same number of particles... > > And that's why you should have everything OK with the other solution... > > I hope! > > > > On Fri, 18 Feb 2005 10:26:29 -0600, Sean Dunn > > <sean@(protected)> wrote: > > > My size is based on Age% via an fcurve. As long as I copy the ages > > over > > > through the particle event, it shouldn't need the sizes copied, since > > > they're generated on the fly based on the age, right? > > > > > > The previous chunk of code you gave actually errored, saying that the > > > argument was invalid on line 1. I was definitely set up for Jscript, > > but > > > I think I narrowed it down to that it didn't understand what the > > > Particles member of Incloud1.Value was. I'll try the particle events > > > solution now. > > > > > > Thanks for your help Aloys! > > > > > > Sean > > > > > > -- --Original Message-- -- > > > From: Aloys Baillet [mailto:aloys.baillet@(protected)] > > > Sent: Thursday, February 17, 2005 3:30 PM > > > To: XSI@(protected) > > > Subject: Re: setting initial state on particles (age lost?) > > > > > > Sorry Sean, I think I might have misleaded you... > > > The solution I gave you will only work if there is no change in the > > > particle number and if the size of the particles is constant (this was > > > the case for me last week). > > > Else, you will have to set a particle event for the entire cloud on > > > the first frame, and get the InitState cloud object (with GetObject) > > > and copy the size and the age of the particles from one cloud to the > > > other (copying particle rotations won't work). > > > Don't hesitate to ask more if I am not clear! > > > > > > Aloys > > > > > > On Thu, 17 Feb 2005 17:46:52 +0100, Aloys Baillet > > > <aloys.baillet@(protected)> wrote: > > > > Hello Sean, > > > > Initial States are a big pain... they don't keep Color, UVW, Ages, > > > Sizes... > > > > But You can do a little workaround for this: > > > > Set a scripted operator on the Cloud, connect the initial state > > cloud, > > > > and put this JScript: > > > > > > > > Out.Value.Particles.ColorArray = > > Incloud1.Value.Particles.ColorArray; > > > > Out.Value.Particles.SizeArray = Incloud1.Value.Particles.SizeArray; > > > > Out.Value.Particles.UVWArray = Incloud1.Value.Particles.UVWArray; > > > > Out.Value.Particles.AgeArray = Incloud1.Value.Particles.AgeArray; > > > > > > > > Hope this helps... > > > > > > > > On Thu, 17 Feb 2005 10:34:09 -0600, Sean Dunn > > > > <sean@(protected)> wrote: > > > > > > > > > > > > > > > > > > > > I've been trying to figure out a particle problem for a few hours > > > now.. I > > > > > can't find any references to it online. When I Set Initial State > > on > > > a very > > > > > simple particle system with size based on age, it doesn't keep the > > > initial > > > > > sizes (or, it looks like, any other attribute based on age). It > > > keeps the > > > > > positions, but that is it. Anything based on age goes back to 0. > > Is > > > there > > > > > any way to get around this? I've duplicated the behavior in 4.0 > > and > > > 4.2. Is > > > > > it possible to create a particle event that would store the age as > > a > > > custom > > > > > attribute and then use that to drive the size? ..because that's > > > what I'm > > > > > going to try soon if I can't make it work correctly. And I want to > > > avoid > > > > > requiring a pre-roll animation, since the simulation is heavy. > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > Sean > > > > > > > > > > > > > > > > > > -- > > > > Aloys Baillet - TD / R&D @ La Maison - www.alamaison.fr > > > > > > > > > > -- > > > Aloys Baillet - TD / R&D @ La Maison - www.alamaison.fr > > > --- > > > Unsubscribe? Mail Majordomo@(protected) with the following text in > > > body: > > > unsubscribe xsi > > > > > > --- > > > Unsubscribe? Mail Majordomo@(protected) with the following text in > > body: > > > unsubscribe xsi > > > > > > > -- > > Aloys Baillet - TD / R&D @ La Maison - www.alamaison.fr > > --- > > Unsubscribe? Mail Majordomo@(protected) with the following text in > > body: > > unsubscribe xsi > > > > --- > > Unsubscribe? Mail Majordomo@(protected) with the following text in body: > > unsubscribe xsi > > > --- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |