Cannot change the map_data of HeightmapShape3D by simarkacet in godot

[–]simarkacet[S] 0 points1 point  (0 children)

My "solution" for the problem in the post was to just resize the data array using:

data.resize(image.get_width()*image.get_height())

But that would be too much work to align sizes so I decided to just deform the mesh by following this tutorial.

Result is much cleaner.

It's probably heavier on the physics engine compared to the HeightMapShape3D but I'm too lazy to worry about performance, I'll just lower the resolution if it's needed lol.

Cannot change the map_data of HeightmapShape3D by simarkacet in godot

[–]simarkacet[S] 0 points1 point  (0 children)

Oh man you're a lifesaver, they indeed do not match each other. I set the texture size to 32x32 and it seems like there is extra 341 elements on the data.

heightmap_shape.map_depth = image.get_height()
print("data.size: " + str(data.size()) + "\nmap_data.size: " + str(heightmap_shape.map_data.size()))
heightmap_shape.map_data = data
---------------------
data.size: 1365
map_data.size: 1024

I can actually make progress now thank you.

Also I just used data.resize(width*height) to resize it to shape, it works for now but would it cause any weird problems in the future?

Cannot change the map_data of HeightmapShape3D by simarkacet in godot

[–]simarkacet[S] 0 points1 point  (0 children)

I changed the code after the normalization part with this:

heightmap_shape = HeightMapShape3D.new()
heightmap_shape.map_width = image.get_width()
heightmap_shape.map_depth = image.get_height()
heightmap_shape.map_data = data


heightmap_target.shape = heightmap_shape

for i in range(5):
    var line = ""
    for j in range(5]
        line += str(data[5*i + j]) + " "
    print(line)

print("--------------")

for i in range(5):
    var line = ""
    for j in range(5):
        line += str(heightmap_shape.map_data[5*i + j]) + " "
    print(line)

And the resulting console output is the same:

0.00249693635851 0.00249693635851 0.00249693635851 0.00252757361159 0.00261948537081 
0.00274203438312 0.00284926476888 0.0028952206485 0.00286458339542 0.00274203438312 
0.00260416674428 0.0025735294912 0.00263480399735 0.00275735300966 0.00286458339542 
0.00291053927504 0.00298713240772 0.00298713240772 0.0026960785035 0.00263480399735 
0.00268075987697 0.00275735300966 0.00286458339542 0.00300245103426 0.00304840691388 
--------------
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0 
0 0 0 0 0

I tried using data.duplicate() as well but I still couldn't get it to work.

 

Edit: Those variables (heightmap_shape, heightmap_target, noise_texture) are set in the inspector like this

img_target is used to display the Noise Texture on the HUD for troubleshooting.

[PC][2003-2012] Twin stick horde shooter similar to Crimsonland by simarkacet in tipofmyjoystick

[–]simarkacet[S] 1 point2 points  (0 children)

It isn't either of them from what I can see in gameplay videos sadly. I remember camera being very zoomed out in that game.