Page 1 of 1

I need to collision detection with IAnimatedMeshSceneNode!

Posted: Fri May 05, 2006 9:47 am
by mmh771
I've really tried all the possible way to collisiosn detection with IAnimatedMeshSceneNode .... but with no result ..

Still the camera fly thrugh my SceneNode, and it doesn't colide with it!

Any help please!

here is the code

Code: Select all

int main()
{
....
....
....
IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
{
	node->setMaterialFlag(EMF_LIGHTING, false);
	node->setFrameLoop(0, 310);
	node->setMaterialTexture( 0,  driver->getTexture("../../media/sydney.bmp") );
}

ICameraSceneNode* camera;
camera = smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);
camera->setPosition(vector3df(-100, -100, 100));
	
ITriangleSelector* selector;
selector = smgr->createTriangleSelectorFromBoundingBox(node);
	
ISceneNodeAnimator* anim;
anim = smgr->createCollisionResponseAnimator
           (selector, node, vector3df(50, 50, 50), vector3df(0, 0, 0),     vector3df(0, 20, 0), 0.000500);

node->addAnimator(anim);

while(device->run())
{
	driver->beginScene(true, true, SColor(255,100,101,140));
	smgr->drawAll();
	guienv->drawAll();
	driver->endScene();
}
return 0;

}

Posted: Fri May 05, 2006 10:23 am
by $L!M
I'm not sure, but try this

Code: Select all

	
ITriangleSelector* selector;
selector = smgr->createTriangleSelectorFromBoundingBox(node);

[color=red]
node->setTriangleSelector(selector);
selector->drop();
[/color]

ISceneNodeAnimator* anim;
anim = smgr->createCollisionResponseAnimator
           (selector, node, vector3df(50, 50, 50), vector3df(0, 0, 0),     vector3df(0, 20, 0), 0.000500);


Posted: Fri May 05, 2006 10:31 am
by mmh771
No, adding

node->setTriangleSelector(selector);
selector->drop();

Didn't solve the problem, still the camera fly though Sydeny!

Posted: Fri May 05, 2006 11:15 am
by hybrid
Proceed as adviced by LM, and additionally change 'node' to 'camera' in the collisionResponse, otherwise the node can only coolide with itself.

Posted: Fri May 05, 2006 11:17 am
by $L!M
replace:
anim = smgr->createCollisionResponseAnimator
(selector, node, vector3df(50, 50, 50), vector3df(0, 0, 0), vector3df(0, 20, 0), 0.000500);

node->addAnimator(anim);

with:

anim = smgr->createCollisionResponseAnimator(selector, CAMERA, core::vector3df(5,5,5),core::vector3df(0,0,0), core::vector3df(0,0,0));
CAMERA->addAnimator(anim);
anim->drop();
:lol:

Posted: Fri May 05, 2006 12:25 pm
by mmh771
Thanx very much .. for both LiM and Hybrid ...
the collision detection between the Camera and IAnimatedMeshSceneNode now works 100% ...