static void _perlin_terrain(Evas_Real *out_x, Evas_Real *out_y, Evas_Real *out_z, Evas_Real x, Evas_Real y) { Evas_Real persistence = 0.5f; Evas_Real frequency = 5; Evas_Real amplitude = 1; int i = 0; int octaves = 5; *out_x = x; x += 0.5; *out_y = y; y += 0.5; *out_z = 0; for(i = 0; i < octaves; i++) { *out_z += _noise(x * frequency, y * frequency) * amplitude; amplitude *= persistence; frequency *= 2; } }
//----------------------------------------------------------------------- double Noise3D::noise(double x, double y, double z) { double n = 0; double freq = mFrequency; double ampl = mAmplitude; for (Ogre::ushort u = 0; u < mOctaves; ++u) { n += _noise(x * freq, y * freq, z * freq) * ampl; freq *= 2; ampl *= mPersistence; } return n; }