Collisions

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
)-(eLioS

Collisions

Post by )-(eLioS »

I have created a 3d map but into it there are also some objects.
My problem is that when i want to collide a char with all this objects.

Now.. It's my problem, but i have not understood how to make it!
Help me thanks!
codemonkey

Post by codemonkey »

You might have been best posting this in the Beginners Help section of these forums, as the collision detection tutorial explains most of what I think you're trying to do. Have a look at that, but use a meta triangle selector instead.

Make a triangle selector for each object in the scene you want to collide with and add each one to your meta triangle selector. Then create a colision response animator using your meta triangle selector. Add this animator to the character you want to collide with things. The pseudo code below shows something like what i think you need, but it might have bugs in it as i haven't checked it

Code: Select all

ITriangleSelector* selector = 0;
IMetaTriangleSelector* meta = 0; 
	
// Make a meta triangle selector
meta = smgr->createMetaTriangleSelector();

// Create a triangle selector for each scene object
// and add it to the meta triangle selector
for (/* The number of objects in the scene*/)
{
  selector = smgr->createTreeTriangleSelector(aMesh, aNode);
  aNode->setTriangleSelector(selector);
  meta->addtriangleSelector(selector);
  selector->drop();
}

// Then create a collision response animator, and attach
// it to yourNode, being whatever node you want things to
// collide with
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(meta, yourNode);
yourNode->addAnimator(anim);
anim->drop();

// Then drop the meta selector if you don't need it
meta->drop();
If you're want to collide with an object with a large number of polygons (e.g. the level), use an octTreeTriangleSelector.

Hope that helps :wink:
irkab1rka
Posts: 9
Joined: Sat Jul 09, 2005 8:06 pm

Post by irkab1rka »

What a useful think :shock: Why I haven't discovered it earlier?
The question is:

can I add new selectors on demand? WIll they be used in the animator?
Post Reply