class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS ObjectRefCountedResourceShape3D HeightMapShape3D
A 3D height map shape used for physics collision.
A 3D heightmap shape, intended for use in physics. Usually used to provide a shape for a CollisionShape3D. This type is most commonly used for terrain with vertices placed in a fixed width grid. Due to the nature of the heightmap, it cannot be used to model overhangs or caves, which would require multiple vertices at the same vertical location. Holes can be punched through the collision by assigning [constant @GDScript.NAN] to the height of the desired vertices (this is supported in both GodotPhysics3D and Jolt Physics). You could then insert meshes with their own separate collision to provide overhangs, caves, and so on.
Performance: HeightMapShape3D is faster to check collisions against than ConcavePolygonShape3D, but it is significantly slower than primitive shapes like BoxShape3D.
A heightmap collision shape can also be built by using an Image reference:
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)

set get PackedFloat32Array map_data<>():PackedFloat32Array set get
Height map data. The array's size must be equal to map_width multiplied by map_depth.

set get int map_depth<>():int set get
Number of vertices in the depth of the height map. Changing this will resize the map_data.

set get int map_width<>():int set get
Number of vertices in the width of the height map. Changing this will resize the map_data.

float get_max_height<>():float
Returns the largest height value found in map_data. Recalculates only when map_data changes.

float get_min_height<>():float
Returns the smallest height value found in map_data. Recalculates only when map_data changes.

void update_map_data_from_image<>( Image image=, image:Image=, float height_min=, height_min:float=, float height_max=, height_max:float=, ):void
Updates map_data with data read from an Image reference. Automatically resizes heightmap map_width and map_depth to fit the full image width and height.

The image needs to be in either [constant Image.FORMAT_RF] (32 bit), [constant Image.FORMAT_RH] (16 bit), or [constant Image.FORMAT_R8] (8 bit).
Each image pixel is read in as a float on the range from 0.0 (black pixel) to 1.0 (white pixel). This range value gets remapped to height_min and height_max to form the final height value.
Note: Using a heightmap with 16-bit or 32-bit data, stored in EXR or HDR format is recommended. Using 8-bit height data, or a format like PNG that Godot imports as 8-bit, will result in a terraced terrain.



All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...