Game Development Community

FxFoliageReplicator uses a non-pure randomizer

by Tim Holt · in Torque Game Engine Advanced · 05/01/2006 (2:40 pm) · 5 replies

While reading over the source code for the fxFoliageReplicator random placement code, I realized that it has a calculation method which is not random. Depending on your application you may or may not want to leave it as is.

Specifically the calculation method creates a pseudo random distribution, however there is a greater distribution of points towards the center of the radius. Your foliage count will taper out on the edges. This actually might be what you want, but it might not.

Here is an image that represents how the foliage is currently placed....

www.orst.edu/~holtt/images/nonrandom.jpg
and here's a true random distribution...

www.orst.edu/~holtt/images/random.jpg
For a good writeup on this particular problem, see mathworld.wolfram.com/DiskPointPicking.html.

I had done some work with this for Half-Life 2 (see developer.valvesoftware.com/wiki/CShotManipulator) for the shot distribution. Ends up the Source engine uses the true random distribution of shots, when the non-random (more shots in middle) almost makes more sense for bullet spread.

#1
05/29/2006 (2:51 pm)
Interesting, I'd like to use that code for my bullet spread but my C and Calculus (especially calculus) skills are crap.

edit: Using TorqueScript, of course ;)
#2
05/29/2006 (3:43 pm)
Good catch. I have noticed the placement to be denser in the middle. Id love to have this fixed but my math skills are quite lacking.
#3
05/30/2006 (9:55 pm)
Any math gurus out there that can convert those formulas to C++ code?
#4
05/30/2006 (10:03 pm)
I've actually got a revised version of the foliage replicator that uses the non-random distribution. It lets you choose what distribution style you'd like to have. It also can do a distribution in a rectangular area as well.

Note to self: post to forums when I get to work in the morning...
#5
06/27/2006 (7:10 pm)
Hey Tim, I think you lost that note =)