[Include] Simplex Noise Generator
Simplex Noise Generator!

__________________________________________________ __________________________________________________

Description:

This library basically adds a bunch of noise functions that you can use for various things.

So far I've converted the following functions from C++ to PAWN:
pawn Код:
`// Returns a 1D simplex noiseFloat:noise1D(Float:x);// Returns a 2D simplex noiseFloat:noise2D(Float:x, Float:y);// Returns a 3D simplex noiseFloat:noise3D(Float:x, Float:y, Float:z);// Returns a 4D simplex noiseFloat:noise4D(Float:x, Float:y, Float:z, Float:w);// Returns a 1D simplex ridged noiseFloat:ridgedNoise1D(Float:x);// Returns a 2D simplex ridged noiseFloat:ridgedNoise2D(Float:x, Float:y);// Returns a 3D simplex ridged noiseFloat:ridgedNoise3D(Float:x, Float:y, Float:z);// Returns a 4D simplex ridged noiseFloat:ridgedNoise4D(Float:x, Float:y, Float:z, Float:w);// Returns a 1D simplex noise with analytical derivative.dnoise1D(Float:x, &Float:rx, &Float:ry)// Returns a 2D simplex noise with analytical derivatives.dnoise2D(Float:x, Float:y, &Float:rx, &Float:ry, &Float:rz)// Returns a 3D simplex noise with analytical derivatives.dnoise3D(Float:x, Float:y, Float:z, &Float:rx, &Float:ry, &Float:rz, &Float:rw)// Returns a 2D simplex cellular/worley noiseFloat:worleyNoise2D(Float:x, Float:y)// Returns a 3D simplex cellular/worley noiseFloat:worleyNoise3D(Float:x, Float:y, Float:z)// Returns a 2D simplex smooth cellular/worley noiseFloat:worleyNoise2D_F(Float:x, Float:y, Float:falloff)// Returns a 3D simplex smooth cellular/worley noiseFloat:worleyNoise3D_F(Float:x, Float:y, Float:z, Float:falloff)`

I used parts of this for my forest generator, which some of you may have heard of. For those who haven't heard of it, it's a random forest generator. I generated multiple forests over a 3000 unit radius, so it covers all of SA. It has random clearings, camp areas, and rubbish areas. It also has various trees in their own areas (kind of like biomes), bushes, and rocks.

__________________________________________________ __________________________________________________

Examples:

pawn Код:
`main() {    printf("noise1D: %f", noise1D(-45.1231));    printf("noise2D: %f", noise2D(-45.1231, 10.9453));    printf("noise3D: %f", noise3D(-45.1231, 10.9453, 32.3621));    printf("noise4D: %f", noise4D(-45.1231, 10.9453, 32.3621, 100.6343));        printf("ridgedNoise1D: %f", ridgedNoise1D(-45.1231));    printf("ridgedNoise2D: %f", ridgedNoise2D(-45.1231, 10.9453));    printf("ridgedNoise3D: %f", ridgedNoise3D(-45.1231, 10.9453, 32.3621));    printf("ridgedNoise4D: %f", ridgedNoise4D(-45.1231, 10.9453, 32.3621, 100.6343));        new Float:rx, Float:ry, Float:rz, Float:rw;    dnoise1D(100.5, rx, ry);    printf("dnoise1D: %f, %f", rx, ry);    dnoise2D(110.53, -20.5, rx, ry, rz);    printf("dnoise2D: %f, %f, %f", rx, ry, rz);    dnoise3D(110.53, -20.85, 9.12, rx, ry, rz, rw);    printf("dnoise3D: %f, %f, %f, %f", rx, ry, rz, rw);        printf("worleyNoise2D: %f", worleyNoise2D(13.0, -34.1));    printf("worleyNoise3D: %f", worleyNoise3D(13.52321, -34.1, -34.4));    printf("worleyNoise2D_F: %f", worleyNoise2D_F(13.0, -34.1, 10.0));    printf("worleyNoise3D_F: %f", worleyNoise3D_F(13.52321, -34.1, -34.4, 10.0));}`
Output:
Quote:
 noise1D: 0.117055 noise2D: -0.613689 noise3D: 0.060025 noise4D: -0.237536 ridgedNoise1D: 0.882944 ridgedNoise2D: 0.386310 ridgedNoise3D: 0.939974 ridgedNoise4D: 0.762463 dnoise1D: -0.875976, 9.531250 dnoise2D: 0.325981, -2.015559, -1.042779 dnoise3D: -0.662052, 1.085515, 0.660695, 1.227718 worleyNoise2D: 0.640313 worleyNoise3D: 0.412964 worleyNoise2D_F: 0.238459 worleyNoise3D_F: 0.173266
__________________________________________________ __________________________________________________

Credits:

simongeilfus for the original library in C++ : https://github.com/simongeilfus/SimplexNoise
__________________________________________________ __________________________________________________

Interesting but how are you going to avoid trees going through buildings if you are going to map the whole of SA?
I don't understand... what's the use of this?
Quote:
 Originally Posted by Wizzard2H I don't understand... what's the use of this?
Noise unwanted crap in some useful stuff. Like noise in your phone call, or noise in your TV signal. It doesn't allow the information to be shown clearly.

This include basically adds noise to stuff and using the pattern you plant trees all over the map. Since the noise generated is random, you will be placing trees at random locations with random densities and more randomly random stuff.
Quote:
 Originally Posted by Yashas Interesting but how are you going to avoid trees going through buildings if you are going to map the whole of SA?
Magic Function:
pawn Код:
`RemoveBuildingForPlayer(playerid, -1, 0.0, 0.0, 0.0, 5000.0);`
Quote:
 Originally Posted by Yashas This include basically adds noise to stuff and using the pattern you plant trees all over the map. Since the noise generated is random, you will be placing trees at random locations with random densities and more randomly random stuff.
Precisely, but it's not only for trees! I've also used it in a voxel world generator, which worked perfectly, but looked like shit due to SA-MP's object stream limit.
Looks interested that would be a nice feature for RP servers
I know an guy like alot things like this... ******. U know it's true xD

Its an very interesting job you did here.

Good Work Crayder
Quote:
 Originally Posted by PT I know an guy like alot things like this... ******. U know it's true xD
xD horrible translation or english !
Quote:
 Originally Posted by Gammix xD horrible translation or english !
Yeah my English never was good but at least he can understand.
I would like to see an image of the forest/other landmasses generated by this include. By the way, c++ to pawn sounds like a downgrade to me.

Forum Jump:

Users browsing this thread: 1 Guest(s)