Problems with terrain


изображение
изображение
изображение
BulletHeightfieldShape doing great, but HeightfieldTesselator works kinda bad

What is your statement based on? Let’s say you configured the HeightfieldTesselator class incorrectly… Is this a Panda3D problem?..

i dont know how to configure it

focal point its something like max LOD point?
why my terrain has this bevel on one side?

Yes, it is detailing around the given coordinates.

from direct.showbase.ShowBase import ShowBase
from panda3d.core import HeightfieldTesselator, Filename, TextureStage, TexGenAttrib, SamplerState

class Test(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        heightfield_map = Filename('heightfield.png')
        grass = loader.load_texture('grass.png')
        grass.set_magfilter(SamplerState.FT_linear_mipmap_linear)
        grass.set_minfilter(SamplerState.FT_linear_mipmap_linear)

        self.terrain = HeightfieldTesselator('Terrain')
        self.terrain.set_heightfield(heightfield_map)
        self.terrain.set_horizontal_scale(1)
        self.terrain.set_vertical_scale(20)
        self.terrain.set_focal_point(int(512), int(512))

        ts = TextureStage.get_default()

        node_path = self.terrain.generate()
        node_path.set_texture(grass)
        node_path.set_tex_gen(ts, TexGenAttrib.M_world_position)
        node_path.set_tex_scale(ts, 0.1, 0.1)
        node_path.reparent_to(render)

        base.accept("f3", self.toggle_wireframe)

test = Test()
test.run()

I used the resources from the shader-terrain example.

btw, why does it rescale image “Rescaling heightfield image height_map.png from 256x256 to 257x257 pixels.” ?

This is to completely build the mesh.

so that is what this bevel was

By the way, you’d better use GeoMipTerrain. So with HeightfieldTesselator, you need to implement an algorithm for regeneration the geometry in each frame when changing the focal point.

ye already on geomipterrain