I need to collision detection with IAnimatedMeshSceneNode!

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
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

I need to collision detection with IAnimatedMeshSceneNode!

Post 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;

}
$L!M
Posts: 28
Joined: Thu May 04, 2006 1:21 pm
Location: Ukraine :)

Post 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);

mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

No, adding

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

Didn't solve the problem, still the camera fly though Sydeny!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Proceed as adviced by LM, and additionally change 'node' to 'camera' in the collisionResponse, otherwise the node can only coolide with itself.
$L!M
Posts: 28
Joined: Thu May 04, 2006 1:21 pm
Location: Ukraine :)

Post 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:
mmh771
Posts: 39
Joined: Thu Apr 27, 2006 7:02 am

Post by mmh771 »

Thanx very much .. for both LiM and Hybrid ...
the collision detection between the Camera and IAnimatedMeshSceneNode now works 100% ...
Post Reply