How to modify the parameters of a collision animator?
Posted: Fri Aug 27, 2010 9:55 am
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:
The render loop, for example I modify the gravity of the animator with "anim->setGravity". After that the collision animator doesn't work anymore.
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.
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);
}
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);
}
}
But if I make the modification before the render loop, the gravity is changed and the collision animator works.