Terrain rendering

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
mindwarp
Posts: 2
Joined: Mon Sep 13, 2004 7:29 pm

Terrain rendering

Post by mindwarp »

Ok before people dig into me: I did use the search function, but I think I may need a little more hand holding than what is currently posted.

I am looking just to render some terrain, and I can make it appear on screen using a greyscale bmp file for my data. I still am, even after reading the tutorials, a bit unclear on triangle selectors. I would also like to implement a octtree, and while I am aware there is a scene node for it I am having a little trouble grasping that also. Can anyone post some code showing a full working example from beginning to end?
Kaeles
Posts: 37
Joined: Thu Jun 03, 2004 12:43 am
Location: oklahoma
Contact:

Post by Kaeles »

Code: Select all

//====================================================
// init terrain  //
	IImage* heightmap= driver->createImageFromFile("hieghtmap.bmp");
	IImage* texture= driver->createImageFromFile("texture.jpg");
	ISceneNode* TerrainNode = 0;
	IAnimatedMesh* terrain = 0;
		smgr->addTerrainMesh("terrain",texture,heightmap,core::dimension2d<f32>
							(10.0f,10.0f),1000.0f,core::dimension2d<s32>(64,64));
	 terrain = smgr->getMesh("terrain");
	 TerrainNode = smgr->addAnimatedMeshSceneNode(terrain);
//create triangle selector//
	 ITriangleSelector* selector = 
		 smgr->createTriangleSelector(terrain->getMesh(0),TerrainNode);

//options loop//	 
	 if (TerrainNode)
 {
	 TerrainNode->setMaterialFlag(EMF_LIGHTING, false);
	 TerrainNode->setPosition(core::vector3df (-3000.0f,0.0f,-3000.0f));
	 TerrainNode->setTriangleSelector(selector);
	 selector->drop();
 }
//====================================================
// init camera //
	ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
	camera->setFOV(1.5);
	//camera->setFarValue(40000.0f);
	camera->setPosition(core::vector3df (200.0f,1200.0f,200.0f));
//camera animator//	
/*
	ISceneNodeAnimator* CameraAnim = 
		smgr->createCollisionResponseAnimator(selector,camera,core::vector3df(30,60,30),
												core::vector3df(0,-100,0), 100.0f,
												core::vector3df(0,50,0));
	camera->addAnimator(CameraAnim);
	CameraAnim->drop();
Last edited by Kaeles on Thu Sep 16, 2004 5:17 pm, edited 1 time in total.
Asheh
Posts: 14
Joined: Tue Sep 14, 2004 7:27 pm

Post by Asheh »

I actually just tried this out but it hangs:

ITriangleSelector *selector = smgr->createOctTreeTriangleSelector(terrain->getMesh(0),terrNode);

Why would this happen?
Kaeles
Posts: 37
Joined: Thu Jun 03, 2004 12:43 am
Location: oklahoma
Contact:

Post by Kaeles »

uh, are you using irr.6?
cause ive had problems with irr.7... i dunno for sure though, ill check later
my brain is fried.... too much class, too little time
Chakotay1308

Post by Chakotay1308 »

Hi guys,
I think I need some help... :(
I've just copied it to my source (just to test it). It works generally, but I can't find any terrain. Sometimes I can see in the upper left edge of the window a small piece of green (this is my "texture").

My "Terrain" is 64x64px sized mspaint-picture. ;) Black should be the deepest und white the highest point on the terrain. And my "texture" is a 64x64px sized piece of green (also made by paint).

So what was my fault with this?

Thanks a lot,
Chris

PS: I'm using irr.7 and have no problems!
Kaeles
Posts: 37
Joined: Thu Jun 03, 2004 12:43 am
Location: oklahoma
Contact:

Post by Kaeles »

I dont know why it hangs with octTreeTriangleSelector, but im guessing its because its not an octreescenenode?
if you change it to createTriangleSelector, it works fine :-D

well first, disable the animator on the camera, to make sure your not just falling through space... lol, ive done it many times.
Post Reply