Irrlicht 1.7.2 + bullet 2.77

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
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

hey there,
I've got a problem :)
I want to push object 2 with the help of object 1. When I press 5 key, object 1 move and push object 2. With this code I can do what I want, but I've got strange problem. If I press 5 key after I run the programm everything work fine and object 1 push object 2, but if I wait about 5-6 seconds after the programm start, object 1 move, but don't push object 2. It passes through the object 2.
Image

Code: Select all

 
CIrrBPManager *bulletPhysMgr = createBulletManager(device);
bulletPhysMgr->getWorld()->setGravity(vector3df(0,-9.8,0));
Tube *tube = new Tube(smgr->getRootSceneNode(), smgr, 1000);                                         //obj 2
CIrrBPRigidBody *tubeBody = bulletPhysMgr->addRigidBox(tube,1000000.0f);
detail cube(smgr, "../data/models/cube.X", vector3df(-95,98,120), vector3df(0,90,0));        //obj 1
CIrrBPRigidBody *cubeBody = bulletPhysMgr->addRigidBox(cube.node,0);
vector3df nodePosition = cubeBody->getPosition();
while(device->run())
{
        if (receiver.IsKeyDown(KEY_KEY_5) && isMove == false)
        {
           isMove = true;
        }
        if (isMove)
        {
            if(nodePosition.Z>10)
    {
        nodePosition.Z -= 1;
        cubeBody->setPosition(nodePosition);
    }
    else
    {
        isMove = false;
    }
}
        bulletPhysMgr->stepSimulation();
 
if I wait I've got this
Image
of not
Image
Maybe someone know what's the problem?
sorry for my bad english :)
aburt11
Posts: 66
Joined: Sun Jan 15, 2012 10:27 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by aburt11 »

looks like a problem with your collision on different nodes
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

aburt11 wrote:looks like a problem with your collision on different nodes
any ideas how I can fix that?
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: Irrlicht 1.7.2 + bullet 2.77

Post by zerochen »

i think the problem is that the object become disabled after a few seconds.
have you tried to set

Code: Select all

rigidbody->setActivenState(DISABLE_DEACTIVATION);?
(pseudocode! dont know the exact functionname und param. something similar like this. you have to look into the api)
?
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by randomMesh »

Don't disable the activation state, rather use body->activate(), before applying forces.
"Whoops..."
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

thanks. I use this and everything works!
tubeBody->setDeactivation(false);
I've got one more question.
addRigidBox use 2 parameters: node and mass. Why object with mass=1000 and object with mass = 1 works identically?
CIrrBPRigidBody *tubeBody = bulletPhysMgr->addRigidBox(tube,1000000.0f);
and
CIrrBPRigidBody *tubeBody = bulletPhysMgr->addRigidBox(tube,1.0f);
no difference
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Irrlicht 1.7.2 + bullet 2.77

Post by hendu »

You are wasting CPU by doing that - disabling its deactivation.

Please read the Bullet manual, it should clarify these points and it's only a couple dozen pages.

- never use "setPosition" unless the object is kinematic, use forces on dynamic objects, static objects never move
- you are setting the position directly, so of course mass doesn't have an effect
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

hendu wrote: - you are setting the position directly, so of course mass doesn't have an effect
I'm not using setPosition with tubeBody object
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

when I use applyForce and move object different mass gives different results, but when object falls down from the height mass again doesn't have an effect
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Irrlicht 1.7.2 + bullet 2.77

Post by hendu »

Um, mass does not affect falling speed, elementary physics ;)
Ossir
Posts: 9
Joined: Thu Feb 16, 2012 8:56 am

Re: Irrlicht 1.7.2 + bullet 2.77

Post by Ossir »

oh, right. Forgot this :)
Post Reply