Moving object (physical and graphical)

hynner

14-08-2011 12:18:59

Hi, I just want to ask how to move both Ogre entity and its Bullet body, I´am using btOgre. I´ve tried to translate both Ogre::SceneNode and btRigidBody, but the results were a bit strange, so I suppose it´s not the right way to do it. I´ve noticed that OgreBullet tutorial demo uses setLinearVelocity to get boxes moving, but I´m not sure if it is the right thing to do when trying to do something like Ogre translate. So if anybody has some experience about this, no matter whether using OgreBullet, it will be highly appreciated.
Edit: I also find another problem for me, how to use Bullet physics with animated mesh? I´ve tried to use btOgre´s AnimatedMeshToShapeConverter, but it seems it need to be somehow updated, so if anyone knows how to do it I will be very glad

JohnBoyManbullet

21-08-2011 03:50:26

once you add an ogre node to bullet and its dynamics world, bullet takes total control of it from ogre. You no longer can use translate(). Thats ok though. you can convert everything from ogre like quaternions to bullet. You use btconverter for this. You can also use applyForce() instead of set velocity. I use this one alot. you should wrap an ogre node in the bullet motion states then control the node with the motion state. As for animations its not different.

JohnBoyManbullet

21-08-2011 03:51:45

Heres a final hint this might save you days of time figuring out. this is to stop objct from falling over.





bodyofmotionstate->setAngularFactor( .0f );


hynner

22-08-2011 10:18:09

OK, thanks for the advice about movement, but I still don´t understand how I create bullet rigid body from ogre´s animated mesh, if I use btOgre´s animated mesh to shape converter and enable animation, the Ogre mesh is animated but rigid body doesn´t change at all. Here is my code
player = mSceneMgr->createEntity("robot", "robot.mesh");
playerSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("playerSceneNode", Ogre::Vector3(-50, 0, -60));
playerSceneNode->attachObject(player);

//Create shape.
BtOgre::AnimatedMeshToShapeConverter converter2(player);
mPlayerShape = converter2.createConvex(); //You can also just use btSphereShape(1.2) or something.
BtOgre::RigidBodyState *playerState = new BtOgre::RigidBodyState(playerSceneNode);
mAnimationState = player->getAnimationState("Idle");
mAnimationState->setEnabled(true);
mAnimationState->setLoop(true);

JohnBoyManbullet

22-08-2011 17:28:00

Well your code isnt able to move a node yet, so nothings going wrong, try applying a force to it.

JohnBoyManbullet

22-08-2011 17:30:00

what do you mean by ridgid body doesnt change.

hynner

23-08-2011 08:02:08

I mean when the mesh is animated, his shape is changing, but his bullet shape is not changing and that is what I am asking , how to do it so that bullet shape will be the same as ogre´s mesh even during the animation.

JohnBoyManbullet

24-08-2011 02:22:29

You'd have to remake a new motion state every frame, That shape needs to be updated every frame before being added to the motion state.

hynner

24-08-2011 12:01:06

Thanks that is what I thought.