How to modify the parameters of a collision animator?

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
benjani13
Posts: 25
Joined: Sat Aug 07, 2010 8:12 pm

How to modify the parameters of a collision animator?

Post by benjani13 »

Hello, I have a model who is moving in the BSP map given with Irrlicht. I attached to the model an "ISceneNodeAnimatorCollisionResponse" and collisions work perfectly.
I'd like to modify one of the parameters of this collision animator during the execution of the program. But when I modify a parameter in the render loop( directly in the render loop or in a function called in the render loop) the collision animator doesn't work anymore, there's no more collision or gravity applied to the model.

So, I'd like to know how to modify a parameter of my collision animator during the execution. Thank you.

----------------------------------------------------------------------------------------

Here is my code if you notice a mistake from me.
The creation of the collision animator:

Code: Select all

//Creation of a collision animator for the model
    scene::ISceneNodeAnimatorCollisionResponse* anim;
    if (selector)
    {
        anim = smgr->createCollisionResponseAnimator(selector, playerNode,
                                                    core::vector3df(19, 40.0f, 9.25f),
                                                    core::vector3df(0, -10, 0),
                                                    core::vector3df(0, 18, -1));
        playerNode->addAnimator(anim);
    }
The render loop, for example I modify the gravity of the animator with "anim->setGravity". After that the collision animator doesn't work anymore.

Code: Select all

//Render loop
    while(device->run())
    {
        if(device->isWindowActive())
        {
            driver->beginScene(true, true, 0);
            smgr->drawAll();
            gui->drawAll();

            anim->setGravity(core::vector3df(0, -10, 0)); // Modification of the gravity

            time = (f32)device->getTimer()->getTime();
           
            eventReceiver.updateNodePositons(time - lastTime);
            eventReceiver.replaceCamera();
           
            if(time - lastTime < MIN_FRAME_TIME)
            {
                device->sleep((u32)(MIN_FRAME_TIME - (time - lastTime)));
            }
            else
            {
                lastTime = time;
            }

            driver->endScene();           
        }
        else
        {
            device->sleep(500);
        }
    }
I tried to put the modification before the beginScene, after the beginScene, and after the EndScene, but it changes nothing.
But if I make the modification before the render loop, the gravity is changed and the collision animator works.
benjani13
Posts: 25
Joined: Sat Aug 07, 2010 8:12 pm

Post by benjani13 »

Up, please if you have an idea of how to modify a parameter of a collision animator. :(
Iyad
Posts: 140
Joined: Sat Mar 07, 2009 1:18 am
Location: Montreal, Canada

Post by Iyad »

Why are cross-posting? You already posted your problem in the begginers help section.
#include <Iyad.h>
Post Reply