Heightmap Terrain and Newton

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
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Heightmap Terrain and Newton

Post by Innopeor »

Hello,
anyone has any example about a integration between "ITerrainSceneNode" and Newton collision manager?

This is the code im using for my static objects, but i didn't found any example in order to do the same with a heightmap terrain.

Code: Select all

void CreateNewtonMesh(NewtonWorld *world, IAnimatedMeshSceneNode *node)
{
	NewtonCollision *treeCollision;
	treeCollision = NewtonCreateTreeCollision(world, NULL);
	NewtonTreeCollisionBeginBuild(treeCollision);

	IMesh *mesh = node->getMesh();

	for (unsigned int i = 0; i < mesh->getMeshBufferCount(); i++)
	{
		IMeshBuffer *mb = mesh->getMeshBuffer(i);

		switch(mb->getVertexType())
		{
			case EVT_STANDARD:
				addMeshToTreeCollisionStandard(mb, treeCollision, node->getScale());
			break;

			case EVT_2TCOORDS:
				addMeshToTreeCollision2TCoords(mb, treeCollision, node->getScale());
			break;

			case EVT_TANGENTS:
				addMeshToTreeCollisionTangents(mb, treeCollision, node->getScale());
			break;

			default:
				printf("Newton error: Unknown vertex type in static mesh: %d\n",
				mb->getVertexType());
			break;
		}
	}

	NewtonTreeCollisionEndBuild(treeCollision, 1);

	NewtonBody* treeBody;
	treeBody = NewtonCreateBody(world, treeCollision);

	NewtonReleaseCollision(world, treeCollision);

	NewtonBodySetUserData(treeBody, node);
}
Regards
freetimecoder
Posts: 226
Joined: Fri Aug 22, 2008 8:50 pm
Contact:

Post by freetimecoder »

Hi,
you could use IrrNewt: http://irrlicht.sourceforge.net/phpBB2/ ... sc&start=0
Or, if you prefer to write it yourself, you can take a look at the source code.

greetings
Innopeor
Posts: 27
Joined: Wed Aug 20, 2008 5:28 pm

Post by Innopeor »

freetimecoder wrote:Hi,
you could use IrrNewt: http://irrlicht.sourceforge.net/phpBB2/ ... sc&start=0
Or, if you prefer to write it yourself, you can take a look at the source code.

greetings
Thanks for the answer,
well i'd like to avoid to using wrappers overall if no longer developed, in order to understand better how Newton works.

I still looking for a example without results tho..
Brainsaw
Posts: 1183
Joined: Wed Jan 07, 2004 12:57 pm
Location: Bavaria

Post by Brainsaw »

Just try the wrapper and use it as a starting point - you can never be sure that development of something will be continued.
Dustbin::Games on the web: https://www.dustbin-online.de/

Dustbin::Games on facebook: https://www.facebook.com/dustbingames/
Dustbin::Games on twitter: https://twitter.com/dustbingames
Post Reply