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.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Collision Detection

Post by monkeycracks »

How would you use collision detection so that something besides the camera is being collided with.

(such as a third-person camera wanting the sydney model its following to collide with terrain and not itself)

I've tried all I can think of and read and read and read...please post some help.
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Nevermind, I've solved the problem.
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

How did you do it? I can't figure it out.

Thanks.
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

It's nice if you would tell us how you solved it :)
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Code: Select all

         ISceneNodeAnimator* anim = sm>createCollisionResponseAnimator( 
            selector, pcam, vector3df(30,51,30), 
            vector3df(0,-8,0), 
            vector3df(0,0,0)); 
            pcam->addAnimator(anim);
            anim->drop();
pcam is my sydney model, and selector is my triangle selector of course.
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

Hmm i still havent got it to work. Is a triangle selector necessary?
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Post your code and I'll try to help you out some.
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

Code: Select all

scene::ISceneNodeAnimator* anim =
    app_scene_manager->createCollisionResponseAnimator(
		NULL, player, core::vector3df(30,50,30),
		core::vector3df(0,-3,0),
		core::vector3df(0,50,0));

	player->addAnimator(anim);

	anim->drop();
[/code]
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Code: Select all

	     ITriangleSelector* selector = sm->createTerrainTriangleSelector(terrain, 0);
         terrain->setTriangleSelector(selector);
Use that selector if your using terrain.

Code: Select all

ITriangleSelector* selector = smgr->createOctTreeTriangleSelector(
      yourlevelmesh->getMesh(0), q3node, 128);
		yourlevelnode->setTriangleSelector(selector);
		selector->drop();
	
And that if its not terrain.


EDIT : Be sure to add it above the code I posted above.
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

Ok i got it working. Only problem is , the clipping is all messed up with the level. When i ran the collision detection tutorial, with the camera, everything was fine. Here is what i mean :

http://img443.imageshack.us/img443/3484/ssvr7.jpg[/url]
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Post your code one more time with the selector you included please


EDIT

It should be similar to this

Code: Select all

ITriangleSelector* selector = smgr->createOctTreeTriangleSelector( 
      yourlevelmesh->getMesh(0), yourlevelnode, 128); 
      yourlevelnode->setTriangleSelector(selector); 
      selector->drop(); 

scene::ISceneNodeAnimator* anim = 
    app_scene_manager->createCollisionResponseAnimator( 
      selector, player, core::vector3df(30,50,30), 
      core::vector3df(0,-3,0), 
      core::vector3df(0,50,0)); 
   player->addAnimator(anim); 

   anim->drop();
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

Code: Select all

scene::ITriangleSelector* selector = 0;
   selector = app_scene_manager->createOctTreeTriangleSelector(
            q3levelmesh->getMesh(0), q3node, 128);
		q3node->setTriangleSelector(selector);
		selector->drop();
	//level->setMaterialFlag(EMF_LIGHTING, false);
	q3node->setPosition( vector3df(-1300,-144,-1249) );
	q3node->setScale( vector3df(2, 1, 2) );
	q3node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
	//level->setMaterialType(EMT_NORMAL_MAP_SOLID);
   

	scene::ISceneNodeAnimator* anim =
    app_scene_manager->createCollisionResponseAnimator(
		selector, player, core::vector3df(30,51,30),
		core::vector3df(0,-8,0),
		core::vector3df(0,20,0));

	player->addAnimator(anim);
	anim->drop();
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

Invictus1017 wrote:

Code: Select all

scene::ITriangleSelector* selector = 0;
   selector = app_scene_manager->createOctTreeTriangleSelector(
            q3levelmesh->getMesh(0), q3node, 128);
		q3node->setTriangleSelector(selector);
		selector->drop();
	//level->setMaterialFlag(EMF_LIGHTING, false);
	q3node->setPosition( vector3df(-1300,-144,-1249) );
	q3node->setScale( vector3df(2, 1, 2) );
	q3node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true);
	//level->setMaterialType(EMT_NORMAL_MAP_SOLID);
   

	scene::ISceneNodeAnimator* anim =
    app_scene_manager->createCollisionResponseAnimator(
		selector, player, core::vector3df(30,51,30),
		core::vector3df(0,-8,0),
		core::vector3df(0,20,0));

	player->addAnimator(anim);
	anim->drop();
whats app_scene_manager, thats the only thing I see that could possibly be out of place.
Invictus1017
Posts: 11
Joined: Sat Jul 15, 2006 5:42 am

Post by Invictus1017 »

my scene manager.
VinZ
Posts: 21
Joined: Sat Jul 29, 2006 11:16 am
Location: India

Getting collide with enemy

Post by VinZ »

hi sorry to use your thread...

I have the same problem but not yet solved?

I added the mapsector of envrionment and enemies to metasector..
and i createated CollisionResponseAnimator for that.. my player is not colliding with enemy.. But if i made enemy to move it is coliding with my player.. i am not able to add this mapsector to that and that mapsector to this.. can any one help me..
:?
Post Reply