Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
HeightMapShape3D
继承: Shape3D < Resource < RefCounted < Object
3D 高度图形状,用于物理碰撞。
描述
3D 高度图形状,旨在用于物理。常用于为 CollisionShape3D 提供形状。可用于地形,但是有无法存储悬垂部分(如洞窟)的限制。HeightMapShape3D 中创建洞的方法是为所需区域分配极低的值。
性能:对 HeightMapShape3D 的碰撞检测比 ConcavePolygonShape3D 快,但与 BoxShape3D 等图元形状相比显著要慢。
高度图碰撞形状也可以使用 Image 构建:
var heightmap_texture = ResourceLoader.load("res://heightmap_image.exr")
var heightmap_image = heightmap_texture.get_image()
heightmap_image.convert(Image.FORMAT_RF)
var height_min = 0.0
var height_max = 10.0
update_map_data_from_image(heightmap_image, height_min, height_max)
属性
|
||
|
||
|
方法
get_max_height() const |
|
get_min_height() const |
|
void |
update_map_data_from_image(image: Image, height_min: float, height_max: float) |
属性说明
PackedFloat32Array map_data = PackedFloat32Array(0, 0, 0, 0)
🔗
void set_map_data(value: PackedFloat32Array)
PackedFloat32Array get_map_data()
高度图数据。该数组的大小必须等于 map_width 乘以 map_depth。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat32Array for more details.
高度图深度中的顶点数。更改该项将调整 map_data 的大小。
高度图宽度中的顶点数。更改该项将调整 map_data 的大小。
方法说明
float get_max_height() const 🔗
返回在 map_data 中找到的最大高度值。仅当 map_data 更改时重新计算。
float get_min_height() const 🔗
返回在 map_data 中找到的最小高度值。仅当 map_data 更改时重新计算。
void update_map_data_from_image(image: Image, height_min: float, height_max: float) 🔗
使用从 Image 引用读取的数据更新 map_data。自动调整高度图 map_width 和 map_depth 的大小以适应整个图像的宽度和高度。
图像格式需要为 Image.FORMAT_RF(32 位)、Image.FORMAT_RH(16 位)或 Image.FORMAT_R8(8 位)。
每个图像像素都以浮点数形式读入,范围从 0.0
(黑色像素)到 1.0
(白色像素)。该范围值重新映射到 height_min
和 height_max
以形成最终高度值。