Adding Collision Detection in Tutorial 7

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
so1odo1o
Posts: 32
Joined: Sat Apr 03, 2010 10:29 am

Adding Collision Detection in Tutorial 7

Post by so1odo1o »

I am playing around with Tutorial 7 and I want to add collision detection to the models using IMetaTriangleSelector.

Here is my code from Tutorial 7 so far (testing with ninja model first):

Code: Select all

.
.
.
        // Making main selector
        scene::IMetaTriangleSelector* mainSelector = 0;
        mainSelector = smgr->createMetaTriangleSelector();

        if (selector)
        {
                scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
                        selector, camera, core::vector3df(30,50,30),
                        core::vector3df(0,-10,0), core::vector3df(0,30,0));

                // Adding selector
                mainSelector->addTriangleSelector(selector);

                selector->drop(); // As soon as we're done with the selector, drop it.
                camera->addAnimator(anim);
                anim->drop();  // And likewise, drop the animator when we're done referring to it.
        }
.
.
.
        node->setScale(core::vector3df(10, 10, 10));
        node->setPosition(core::vector3df(-70,-66,-60));
        node->setRotation(core::vector3df(0,90,0));
        node->setAnimationSpeed(10.f);
        node->getMaterial(0).NormalizeNormals = true;
        // Just do the same as we did above.
        selector = smgr->createTriangleSelector(node);
        node->setTriangleSelector(selector);

        // Adding selector
        mainSelector->addTriangleSelector(selector);
As you can see I create an IMetaTriangleSelector and add the camera's selector and ninja's selector respectively. Can anyone point me to why this isn't working. Perhaps I am not understanding the concept of the IMetaTriangleSelector class? Thanks.
Post Reply