Creating my heightmap!

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.
radiant
Posts: 112
Joined: Fri Feb 22, 2008 8:04 pm
Location: Mexico

Post by radiant »

well.. i made it work, (i cant be on msn since im on my work pc and its blocked), here's the code i used:

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;

#pragma comment(lib, "Irrlicht.lib")

int main()
{
	irr::IrrlichtDevice* device = irr::createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(1152, 864), 32, false, false, true);
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
	scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100, 5000, -1, 0, 0, false, 0);
	camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
	camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
	camera->setFarValue(120000.0f);
	//device->getCursorControl()->setVisible(false);

	scene::IAnimatedMesh* ter_mesh = smgr->addTerrainMesh("terrain", 
		driver->createImageFromFile("../media/terrain-texture.jpg"), 
		driver->createImageFromFile( "../media/heightmap512x512.bmp"), 
		core::dimension2d<f32>(20, 20), 1000, 
		core::dimension2d< s32 >(64, 64));

	scene::IAnimatedMeshSceneNode* terrain = smgr->addAnimatedMeshSceneNode(ter_mesh);
	terrain->setMaterialFlag(video::EMF_LIGHTING, false);
	terrain->setScale(core::vector3df(10,10,10));
	//terrain->setMaterialFlag(video::EMF_WIREFRAME, true);
	terrain->setMaterialTexture(1, driver->getTexture("../media/detailmap3.jpg"));
	terrain->setMaterialType(video::EMT_DETAIL_MAP);
	smgr->addSkyBoxSceneNode(
		driver->getTexture("../media/irrlicht2_up.jpg"),
		driver->getTexture("../media/irrlicht2_dn.jpg"),
		driver->getTexture("../media/irrlicht2_lf.jpg"),
		driver->getTexture("../media/irrlicht2_rt.jpg"),
		driver->getTexture("../media/irrlicht2_ft.jpg"),
		driver->getTexture("../media/irrlicht2_bk.jpg"));

	while(device->run())
	{
		if(device->isWindowActive())
		{driver->beginScene(true, true, 0 );
		smgr->drawAll();
		driver->endScene();}
	}
}
most files are from the media folder in the irrlicht files... and i used this heightmap: ... err... imageshack has been bloked too... damit... ill send it to u by email.

best regards
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Just use a heightmap with a size smaller than 257x257 along with addTerrainSceneNode, it'll boost fps dramatically.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply