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
Toshihiro Shimizu 890ddd
		\brief Declares the Noise1234 class for producing Perlin noise.
Toshihiro Shimizu 890ddd
		\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
Toshihiro Shimizu 890ddd
class Noise1234
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Noise1234() {}
Toshihiro Shimizu 890ddd
	~Noise1234() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/** 1D, 2D, 3D and 4D float Perlin noise, SL "noise()"
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
	static float noise(float x);
Toshihiro Shimizu 890ddd
	static float noise(float x, float y);
Toshihiro Shimizu 890ddd
	static float noise(float x, float y, float z);
Toshihiro Shimizu 890ddd
	static float noise(float x, float y, float z, float w);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/** 1D, 2D, 3D and 4D float Perlin periodic noise, SL "pnoise()"
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
	static float pnoise(float x, int px);
Toshihiro Shimizu 890ddd
	static float pnoise(float x, float y, int px, int py);
Toshihiro Shimizu 890ddd
	static float pnoise(float x, float y, float z, int px, int py, int pz);
Toshihiro Shimizu 890ddd
	static float pnoise(float x, float y, float z, float w,
Toshihiro Shimizu 890ddd
						int px, int py, int pz, int pw);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	static unsigned char perm[];
Toshihiro Shimizu 890ddd
	static float grad(int hash, float x);
Toshihiro Shimizu 890ddd
	static float grad(int hash, float x, float y);
Toshihiro Shimizu 890ddd
	static float grad(int hash, float x, float y, float z);
Toshihiro Shimizu 890ddd
	static float grad(int hash, float x, float y, float z, float t);
Toshihiro Shimizu 890ddd
};