ITerrainSceneNode troubles

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
Epsilon
Posts: 38
Joined: Fri Jan 09, 2004 1:46 pm
Location: Argentina

ITerrainSceneNode troubles

Post by Epsilon »

hi, i am exploring in the heightmap terrain implementation of irrlicht but i cant get it to work, it crashes the application when create the terrain with addTerrainSceneNode.

IDE = M$ VC
OS = Windows XP
IrrVer = 0.4.2

i only want to see the terrain in the screen. for now.

see the code:

video::IImage* texture = driver->createImageFromFile("MapTexture.jpg");
video::IImage* heightmap = driver->createImageFromFile("HeightMapTerrain.jpg");
video::ITexture* detailmap = driver->getTexture("detail.bmp");

// here crash
scene::ITerrainSceneNode* Map = smgr->addTerrainSceneNode(NULL ,NULL, texture, heightmap, detailmap, core::dimension2d<f32>(10.0f,10.0f), 200.0f, core::dimension2d<s32>(64,64));

any idea?

thanks.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

Code: Select all


#include <irrlicht.h> 

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui; 

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

void main() 
{ 
IrrlichtDevice *device = createDevice(video::EDT_DIRECTX9, core::dimension2d<s32>(640, 480), 16); 

	video::IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment(); 

 
scene::ISceneNode* node = 0; 

video::IImage* iHeightMap = driver->createImageFromFile("height.bmp");//this works 
video::IImage* iTerrain = driver->createImageFromFile("tex.bmp");//this works iTerrain

scene::IAnimatedMesh* iTerrainMesh = smgr->addTerrainMesh("iTerrainMesh", iTerrain, iHeightMap); //<---Error is here 
scene::ISceneNode* iTerrainNode = smgr->addOctTreeSceneNode(iTerrainMesh);
iTerrainNode->setMaterialFlag(EMF_LIGHTING, false);


smgr->addCameraSceneNodeFPS(0, 100.0f, 400.0f, -1, 0, 0);




IGUIEnvironment* env = device->getGUIEnvironment();
	IGUIStaticText* fpstext = env->addStaticText(L"", core::rect<s32>(10,26,120,41), true);

	IGUISkin* skin = env->getSkin();
	IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
	if (font)
		skin->setFont(font);
	
	device->getGUIEnvironment()->getSkin()->setColor(gui::EGDC_BUTTON_TEXT,
		video::SColor(255,200,200,200));

	//IGUIFont::draw(L"hallo",core::rect<s32>(10,26,120,41))
	
	device->getCursorControl()->setVisible(false);
	

	int lastFPS = -1;


while(device->run())
	{

		u32 time = device->getTimer()->getTime();

		driver->beginScene(true, true, video::SColor(0,100,100,100));
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();


		device->getGUIEnvironment()->getSkin()->setColor(gui::EGDC_BUTTON_TEXT,
		video::SColor( 255,2*time % 200,time % 200,3*time % 200));


		wchar_t tmp2[255];
			swprintf(tmp2, 255, L" FPS: %d", driver->getFPS());
			fpstext->setText(tmp2);
		
	}

	device->drop();

}
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

In my case this works when texture sizes are 64X64.
With large size 256x256 have no success.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

what did you mean with no success

you got a error message? loading an hieghtmap wit 256x256 take a lot of time! maybe your computer is to slow to calculate that. when i add an triangle selector for collision detecting... it took almost infinite time.
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

I thought the terrain renderer in Irrlicht is in a buggy stage anyway at the moment?
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Yes, my PC is slow /P3 800/, and I use triangle selector. Mabe my patience is not enough. :wink:
I know that terrain randerer is buggy for now, but want to test some cases related with my futures plans.
Post Reply