Collision Detection

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
crosel
Posts: 11
Joined: Fri May 29, 2009 6:53 am

Collision Detection

Post by crosel »

Hi,

Ive had a look around, yet i cant find the answer i seek.

My issue is, that ive set up my collision code for nodes, by creating a selector and adding it to a specific node. I then add the collisionResponseAnimator. (Pretty much what is done in the collision tutorial).

However, my issue is having collision with multiple nodes. If i have a single FPS camera, a level node, and several "enemy" nodes, Is it necessary to set up several selectors and/or animators for each node?

what ive done so far, with a single level, a single node and a single camera is shown below. I just want this code, to be able to do collision detection and the response, as it does. By having it so, the camera is blocked from moving inside the node. I feel its unnecessary.

Code: Select all

selector = 0;
	if(levelNode)
	{
		levelNode->setPosition(vector3df(-1350,-130,-1400));

		selector = smgr->createOctTreeTriangleSelector(
			levelMesh->getMesh(0), levelNode, 128);
		levelNode->setTriangleSelector(selector);
	}
	if (selector)
	{
		anim = smgr->createCollisionResponseAnimator(
			selector, camera, vector3df(20,30,20),
			vector3df(0,-10,0),
			vector3df(0,50,0));
		camera->addAnimator(anim);
		anim->drop();
	}

	selectorTwo = 0;
	if(playerNode)
	{
		selectorTwo = smgr->createOctTreeTriangleSelector(
			playerMesh->getMesh(0), playerNode, 128);
		playerNode->setTriangleSelector(selectorTwo);
	}
	if (selectorTwo)
	{
		animTwo = smgr->createCollisionResponseAnimator(
			selectorTwo, camera, vector3df(15,25,15),
			vector3df(0,0,0),
			vector3df(0,50,0));
		camera->addAnimator(animTwo);
		animTwo->drop();
	}
Im also curious to know, is how to deal with specific collision events. Say i want to have a node explode when it is hit by another node. Is it acceptable to just obtain both the bounding boxes and perform an intersectswith check? or is there another method to doing this.

Code: Select all

aabbox3df node = node->getTransformedBoundingBox();
			aabbox3df playerN = playerNode->getTransformedBoundingBox();

			if(playerN.intersectsWithBox(node ))
			{
				//Explosion event
			}
			else
			{
				device->setWindowCaption(L"NO Collision");
			}
Thanks
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply