i try to build a Terrain using GeoMipTerrain class and a heightmap - works as expected, except that the terrain is totally flat
This is my code to generate the Terrain and attach it to the Scene Graph:
// Create Terrain
GeoMipTerrain *terrain = new GeoMipTerrain( "TestTerrain" );
terrain->set_heightfield( string( "heightmap256.png" ));
terrain->set_near( 40 );
terrain->set_far( 100 );
terrain->set_focal_point( m_Window->get_camera(0) );
terrain->get_root().reparent_to( m_Window->get_render() );
Any ideas what i’ve did wrong?
You should post stuff like this in the “C++ coding using Panda3D”.
Lets see, your png’s name is “heightmap256”. Does that mean you used a 256x256 size? For heightmaps it should be power-of-two + 1. In this case 257x257.
And also try
terrain->set_sz( 100 );
Note that if the terrain is still quite flat, you will have to scale the terrain NodePath in the Z direction, because by default, the Z positions are between 0 and 1. To fix this, scale the terrain up in the Z direction (before generating it, otherwise it might require you to regenerate it)
panda3d.org/manual/index.php/G … MipMapping
You mean this:
terrain->get_root().set_sz( 100 );
thank you for your help - setting the z scale solved my problem. Sorry for having overseen this in the documentation which clearly solves the problem if you just follow the instructions