pocketmine\level\generator\noise\Perlin::__construct PHP Method

__construct() public method

public __construct ( Random $random, $octaves, $persistence, $expansion = 1 )
$random pocketmine\utils\Random
    public function __construct(Random $random, $octaves, $persistence, $expansion = 1)
    {
        $this->octaves = $octaves;
        $this->persistence = $persistence;
        $this->expansion = $expansion;
        $this->offsetX = $random->nextFloat() * 256;
        $this->offsetY = $random->nextFloat() * 256;
        $this->offsetZ = $random->nextFloat() * 256;
        for ($i = 0; $i < 512; ++$i) {
            $this->perm[$i] = 0;
        }
        for ($i = 0; $i < 256; ++$i) {
            $this->perm[$i] = $random->nextBoundedInt(256);
        }
        for ($i = 0; $i < 256; ++$i) {
            $pos = $random->nextBoundedInt(256 - $i) + $i;
            $old = $this->perm[$i];
            $this->perm[$i] = $this->perm[$pos];
            $this->perm[$pos] = $old;
            $this->perm[$i + 256] = $this->perm[$i];
        }
    }

Usage Example

コード例 #1
0
ファイル: Simplex.php プロジェクト: ClearSkyTeam/ClearSky
 public function __construct(Random $random, $octaves, $persistence, $expansion = 1)
 {
     parent::__construct($random, $octaves, $persistence, $expansion);
     $this->offsetW = $random->nextFloat() * 256;
     self::$SQRT_3 = sqrt(3);
     self::$SQRT_5 = sqrt(5);
     self::$F2 = 0.5 * (self::$SQRT_3 - 1);
     self::$G2 = (3 - self::$SQRT_3) / 6;
     self::$G22 = self::$G2 * 2.0 - 1;
     self::$F3 = 1.0 / 3.0;
     self::$G3 = 1.0 / 6.0;
     self::$F4 = (self::$SQRT_5 - 1.0) / 4.0;
     self::$G4 = (5.0 - self::$SQRT_5) / 20.0;
     self::$G42 = self::$G4 * 2.0;
     self::$G43 = self::$G4 * 3.0;
     self::$G44 = self::$G4 * 4.0 - 1.0;
 }
All Usage Examples Of pocketmine\level\generator\noise\Perlin::__construct