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