RE: r

Date : Thu, 21 Jul 2005 16:09:23 +0100
To : <XSI(at)Softimage.COM>
From : "kim aldis" <kim(at)aldis.org.uk>
Subject : RE: r
If you're generating numbers using particle properties as seeds, you may
also want to think about some kind of perlin noise or turb function.  Perlin
noise is just great for this kind of stuff.

> -----Original Message-----
> From: owner-xsi(at)Softimage.COM 
> [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Alan Jones
> Sent: 21 July 2005 15:54
> To: XSI(at)Softimage.COM
> Subject: Re: r
> 
> Thanks, but this is for expressions. If anyone's curious how 
> to do it with JScript here's an ugly function that breaks 
> easily. Apply this as a scripted event to your particle and 
> it'll rotate it to a random direction based on its ID.
> 
> function NextRandomNumber()  {
>   var hi   = this.seed / this.Q;
>   var lo   = this.seed % this.Q;
>   var test = this.A * lo - this.R * hi;
>   if (test > 0)
>     this.seed = test;
>   else
>     this.seed = test + this.M;
>   return (this.seed * this.oneOverM);
> }
> 
> function RandomNumberGenerator(seed) {
>   var d = new Date();
>   this.seed = 2345678901 +
>     (seed * 0xFFFFFF);
>   this.A = 48271;
>   this.M = 2147483647;
>   this.Q = this.M / this.A;
>   this.R = this.M % this.A;
>   this.oneOverM = 1.0 / this.M;
>   this.next = NextRandomNumber;
>   return this;
> }
> 
> function random(lrn, urn) {
>   // Random LowerRange Number (lrn)
>   // Random UpperRange Number (urn)
>   // return Math.round((urn - lrn + 1) * rand.next() + lrn);
>   return Math.floor((urn - lrn + 1) * rand.next() + lrn); }
> 
> var rand = new RandomNumberGenerator(inParticle.ID);
> 
> var xNum = random(-60, 60);
> var zNum = random(-60, 60);
> 
> var v1 = XSIMath.CreateVector3();
> v1.x = xNum + inParticle.Rotation.X;
> v1.y = inParticle.Rotation.Y;
> v1.z = zNum + inParticle.Rotation.Z;
> inParticle.Rotation = v1;
> 
> Cheers,
> 
> Alan.
> 
> On 7/21/05, Nils Koesters <nils(at)mcs.st-and.ac.uk> wrote:
> > The XSI help file says
> > 
> > randBool(17)
> > 
> > Generates a random number between 0.0 and 1.0 at each frame. The 
> > sequence is the same each time you play the scene back.
> > 
> > 
> > Dunno if that helps.
> > 
> > Otherwise just generate them for your frame once somewhere, 
> store them 
> > and reuse them.
> > 
> > Regards
> > Nils
> > 
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the 
> following text in body:
> > unsubscribe xsi
> >
> 
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following 
> text in body:
> unsubscribe xsi
> 
> 

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

  • References:
    • Re: r
      • From: Alan Jones <skyphyr(at)gmail.com>

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.