注釈
Go to the end to download the full example code.
サンプル関数:3DでのPerlinノイズ#
ここでは, pyvista.core.utilities.features.sample_function()
を使用して領域上のPerlinノイズをサンプリングし,ランダムな地表を生成します.
Minecraftなどのビデオゲームでは,Perlinノイズを使用して地表を作成します.ここでは,Minecraftの "洞窟" に似たボクセル化メッシュを作成します.
from __future__ import annotations
import pyvista as pv
3D StructuredGrid上にPerlinノイズを生成する#
"freq" の値を自由に変更して, "洞窟" の形を変えることができます.たとえば,周波数を低くすると,洞穴が大きく拡張します.一方,任意の方向の周波数を高くすると,洞穴はより "静脈のように" 見え,開きにくくなります.
閾値を変更して,開いている地形または閉じている地形の割合を増減します
freq = (1, 1, 1)
noise = pv.perlin_noise(1, freq, (0, 0, 0))
grid = pv.sample_function(noise, [0, 3.0, -0, 1.0, 0, 1.0], dim=(120, 40, 40))
out = grid.threshold(0.02)
out
青以外の色の制限

Total running time of the script: (0 minutes 0.658 seconds)