Collision with terrain scene nodes w/ irrEdit

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Anteater
Posts: 266
Joined: Thu Jun 01, 2006 4:02 pm
Location: Earth
Contact:

Collision with terrain scene nodes w/ irrEdit

Post by Anteater »

Hi. I'm loading irrEdit scenes into my program using a method similar to the one on the Irrlicht wiki. My problem is getting terrains to load with collision. Has anyone done this correctly?

Here's what I'm doing so far:

Code: Select all

		if(nodeToAdd->getType() == ESNT_TERRAIN)
		{
			cout << "Node is Terrain.\n";
			nodeToAdd->setMaterialFlag(EMF_LIGHTING, true);
			//yeah, I know this won't work.
			ITriangleSelector* triSel = smgr->createTerrainTriangleSelector(nodeToAdd,32);
			nodeToAdd->setTriangleSelector(triSel);
			metaSel->addTriangleSelector(triSel);
			triSel->drop();
			
		}
		if(nodeToAdd->getType() == ESNT_OCT_TREE || nodeToAdd->getType() == ESNT_MESH)
		{
			cout << "Node is OctTree.\n";
			nodeToAdd->setMaterialFlag(EMF_LIGHTING, true);
			IAttributes* attributes = device->getFileSystem()->createEmptyAttributes();
			if(attributes)
			{
				nodeToAdd->serializeAttributes(attributes);
				stringc meshName = attributes->getAttributeAsString("Mesh");
				attributes->drop();
				IAnimatedMesh* octMesh = smgr->getMesh(meshName.c_str());
				
				
				
				if(octMesh)
				{
					ITriangleSelector* triSel = smgr->createOctTreeTriangleSelector(octMesh->getMesh(0),nodeToAdd,256);
					nodeToAdd->setTriangleSelector(triSel);
					metaSel->addTriangleSelector(triSel);
					triSel->drop();
				}
				
			}
		}
		
Any help would be greatly appreciated.
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

This should help you : http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=108896#108896

Search the forums, there are a couple topics covering collisions with .irr scenes.
Post Reply