|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Toshihiro Shimizu |
890ddd |
/*-------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
iwa_noise1234.h
|
|
Toshihiro Shimizu |
890ddd |
Identical to a public domain code "noise1234.h" by Stefan Gustavson.
|
|
Toshihiro Shimizu |
890ddd |
Just changed file name for handling of files.
|
|
Toshihiro Shimizu |
890ddd |
-------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
/*-- The original code starts here --*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Noise1234
|
|
Toshihiro Shimizu |
890ddd |
// Author: Stefan Gustavson (stegu@itn.liu.se)
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// This library is public domain software, released by the author
|
|
Toshihiro Shimizu |
890ddd |
// into the public domain in February 2011. You may do anything
|
|
Toshihiro Shimizu |
890ddd |
// you like with it. You may even remove all attributions,
|
|
Toshihiro Shimizu |
890ddd |
// but of course I'd appreciate it if you kept my name somewhere.
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// This library is distributed in the hope that it will be useful,
|
|
Toshihiro Shimizu |
890ddd |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Toshihiro Shimizu |
890ddd |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Toshihiro Shimizu |
890ddd |
// General Public License for more details.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/** \file
|
|
Shinya Kitaoka |
120a6e |
\brief Declares the Noise1234 class for producing Perlin noise.
|
|
Shinya Kitaoka |
120a6e |
\author Stefan Gustavson (stegu@itn.liu.se)
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
* This is a clean, fast, modern and free Perlin noise class in C++.
|
|
Toshihiro Shimizu |
890ddd |
* Being a stand-alone class with no external dependencies, it is
|
|
Toshihiro Shimizu |
890ddd |
* highly reusable without source code modifications.
|
|
Toshihiro Shimizu |
890ddd |
*
|
|
Toshihiro Shimizu |
890ddd |
* Note:
|
|
Toshihiro Shimizu |
890ddd |
* Replacing the "float" type with "double" can actually make this run faster
|
|
Toshihiro Shimizu |
890ddd |
* on some platforms. A templatized version of Noise1234 could be useful.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class Noise1234 {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
Noise1234() {}
|
|
Shinya Kitaoka |
120a6e |
~Noise1234() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/** 1D, 2D, 3D and 4D float Perlin noise, SL "noise()"
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
static float noise(float x);
|
|
Shinya Kitaoka |
120a6e |
static float noise(float x, float y);
|
|
Shinya Kitaoka |
120a6e |
static float noise(float x, float y, float z);
|
|
Shinya Kitaoka |
120a6e |
static float noise(float x, float y, float z, float w);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/** 1D, 2D, 3D and 4D float Perlin periodic noise, SL "pnoise()"
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
static float pnoise(float x, int px);
|
|
Shinya Kitaoka |
120a6e |
static float pnoise(float x, float y, int px, int py);
|
|
Shinya Kitaoka |
120a6e |
static float pnoise(float x, float y, float z, int px, int py, int pz);
|
|
Shinya Kitaoka |
120a6e |
static float pnoise(float x, float y, float z, float w, int px, int py,
|
|
Shinya Kitaoka |
120a6e |
int pz, int pw);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
static unsigned char perm[];
|
|
Shinya Kitaoka |
120a6e |
static float grad(int hash, float x);
|
|
Shinya Kitaoka |
120a6e |
static float grad(int hash, float x, float y);
|
|
Shinya Kitaoka |
120a6e |
static float grad(int hash, float x, float y, float z);
|
|
Shinya Kitaoka |
120a6e |
static float grad(int hash, float x, float y, float z, float t);
|
|
Toshihiro Shimizu |
890ddd |
};
|