[SOLVED] Texturing of GeoMipTerrain

Hello!

Here is code:

void init_terrain(NodePath root) {
	std::string terrainHeightmapFilenpath = "landscape.png";
	terrain.set_heightfield(terrainHeightmapFilenpath);
	terrain.set_bruteforce(true);
	terrain.set_block_size(32);
	terrain.set_near(40.0);
	terrain.set_far(100.0);
	terrain.set_focal_point(camera);
	
	NodePath terrainRoot = terrain.get_root();
	terrainRoot.reparent_to(root);
	terrainRoot.set_sz(10.0);
	
	PT(Texture) groundTexture = new Texture("ground.jpg");
	PT(TextureStage) groundTextureStage = new TextureStage("ts");
	terrainRoot.set_tex_scale(groundTextureStage->get_default(), 10.0, 10.0);
	terrainRoot.set_texture(groundTexture, 1);
	
	terrain.generate();
}

As a result I’m receiving compleetly white terrain without any texturing. Where may be a problem? Just out of ideas… And thank for any help.

Also, the code above suppose using of only a single texture. I’ve found a topic about tiling a terrain. But there was no answer. So, are there any ways to use different texture per block node path of terrain?

solution:
To load texture the TexturePool::load_texture method could be used. For instance:

	PT(Texture) groundTexture = TexturePool::load_texture("models/ground.jpg");

While tiling could be obtained using texure offset, layers and other TextureStage options.

PT(Texture) groundTexture = new Texture("ground.jpg");

That creates an empty texture with the name “ground.jpg”. You have to load your texture via the TexturePool if you want any texture to be shown.

Thank you. I’ve found it by my self just a minute ago.
Personally, it’s not obvious to a newbie how to load textures in C++.

Also note that groundTextureStage->get_default() returns the global default TextureStage, which has nothing to do with groundTextureStage. (TextureStage::get_default() is a static method.)

David