Load a terrain bigger than 515 x 515

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
GameFilesOpen
Posts: 4
Joined: Thu Feb 24, 2011 3:23 pm

Load a terrain bigger than 515 x 515

Post by GameFilesOpen »

Hi community,
can you help me to load a map bigger than 515 x 515? my map is 515 x 643.

Thanks to all.
GameFilesOpen
Posts: 4
Joined: Thu Feb 24, 2011 3:23 pm

Post by GameFilesOpen »

anyone can help me?
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

When you create your terrain, are you using addTerrainMesh, or addTerrainSceneNode?
I believe the TerrainMesh can accept high res height maps (look at iscenemanager.h in the source).
THe TerrainSceneNode needs its height map pixel resolutions to be values of 2^N+1 (129x129, or 257x257, or 513x513, etc).

If changing the terrain type is a lot of trouble, try changing the pixel resloution of your height map.

--Carl
GameFilesOpen
Posts: 4
Joined: Thu Feb 24, 2011 3:23 pm

Post by GameFilesOpen »

Can you show me a simple example of addTerrainMesh?
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post by CarlS »

Have you tried compiling and running Example 12?
It already has a Terrain Scene Node. I modified the example to be switchable between the two terrain types:

Code: Select all

	if (iTerrainType == 1){ //Terrain Mesh

		video::IImage* colorMapImage = driver->createImageFromFile("C:/Program Files/irrlicht-1.7.1/media/terrain-texture.jpg");
		video::IImage* heightMapImage = driver->createImageFromFile("C:/Program Files/irrlicht-1.7.1/media/terrain-heightmap.bmp");

		scene::IAnimatedMesh* terrain =   smgr->addTerrainMesh ("TerrainMeshName", colorMapImage, heightMapImage,
			core::dimension2d< f32 >(fTerrainScale, fTerrainScale), // size of a pixel
			8.f*fTerrainScale); // maximum height

		scene::ISceneNode* room = 0;
		ISceneNode* node = smgr->addAnimatedMeshSceneNode(terrain);
		node->setMaterialFlag(video::EMF_LIGHTING, false);
		node->setPosition(core::vector3df(-5000,0,-5000));

}	else if (iTerrainType == 2){ // height map needs to be 2n+1 resolution
// add terrain scene node
		scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
			"C:/Program Files/irrlicht-1.7.1/media/terrain-heightmap.bmp"
			,0,-1
			,core::vector3df(0.0f,0.0f,0.0f) // position
			,core::vector3df(0.0f,0.0f,0.0f) // rotation
			,core::vector3df(1.0f,1.0f,1.0f) // scale
			,video::SColor(255,255,255,255)
			,3 // Level of detail
			,ETPS_17 // terrain patch size
			,0 //smooth factor
			);

	terrain->setScale(core::vector3df(fTerrainScale, 1.0f, fTerrainScale));
	terrain->setPosition(core::vector3df(-5000,0,-5000));
	terrain->setMaterialFlag(video::EMF_LIGHTING, false);
	terrain->setMaterialTexture(0, driver->getTexture("C:/Program Files/irrlicht-1.7.1/media/terrain-texture.jpg"));
	terrain->setMaterialTexture(1, driver->getTexture("C:/Program Files/irrlicht-1.7.1/media/detailmap3.jpg"));
	terrain->setMaterialType(video::EMT_DETAIL_MAP);
	terrain->scaleTexture(1.0f, 20.0f);
}
The code above shows the differences in the ways the two terrain types are used.
If you search the forum for addTerrainMesh, you'll probably find some other more complete examples.

--Carl
GameFilesOpen
Posts: 4
Joined: Thu Feb 24, 2011 3:23 pm

Post by GameFilesOpen »

Thanks very much, you're a monster! :D

P.s. sorry for the long time passed before the thanks ^^
Post Reply