Garibalde
27-12-2009 05:22:30
Hi
I am new to bullet. Have a bunch of objects in the simulation (using Ogre) that needs to collide with each other.
I will take control of one of these objects and drive it via Mouse and keyboard and make them collide with other
objects in the simulation. I can then change the selected object to another one in the scene at runtime by pressing
a keyboard key ("space").
I ahve all the objects loaded in the simulation the start in the air and fall to the ground. I see the effect of collision between the floor and the objects. Also between two objects on the fall (There is no user control activated here yet). Below is the code i use to setup the rigid body objects.
The at runtime when the object is switched i dot he following. I get the object RigidBodyState and apply the following:
When i move the keyboard and Mouse i collect the information and set the following Where cpos and Ori are the current position and orientation of the object controlled by the user.
Therefore here is the QUESTION:
It seems that the controlled pobject does not collide with the other objects in the scene and cause any physic effects. They just passthrough them!!! What am i doing wrong to enable a CONTROLLED object that can create physics effects at runtime with other righidbodies in the Simulation.
Any help you can provide woult be greatful. am lost i just need a hint of sorts to proceed. A example code would be great.
Garibalde
I am new to bullet. Have a bunch of objects in the simulation (using Ogre) that needs to collide with each other.
I will take control of one of these objects and drive it via Mouse and keyboard and make them collide with other
objects in the simulation. I can then change the selected object to another one in the scene at runtime by pressing
a keyboard key ("space").
I ahve all the objects loaded in the simulation the start in the air and fall to the ground. I see the effect of collision between the floor and the objects. Also between two objects on the fall (There is no user control activated here yet). Below is the code i use to setup the rigid body objects.
_cprintf("-> Creating Physics model %s.\n",(*p)->ObjectName.c_str());
BtOgre::StaticMeshToShapeConverter converter(MyEntity);
(*p)->mObjShape = converter.createBox();
(*p)->mObjShape->setLocalScaling(btVector3((*p)->AxisScaling[0],(*p)->AxisScaling[1],(*p)->AxisScaling[2]));
//Calculate inertia.
btScalar mass = 2;
btVector3 inertia;
(*p)->mObjShape->calculateLocalInertia(mass, inertia);
//Create BtOgre MotionState (connects Ogre and Bullet).
(*p)->mObjState = new BtOgre::RigidBodyState((*p)->mObjNode);
The at runtime when the object is switched i dot he following. I get the object RigidBodyState and apply the following:
ActiveToolName = ObjArray.GetObjectFromList(ActiveToolToggle);
ObjectPtr ObjData = ObjArray.GetObjectPtrGivenIndx(ActiveToolToggle);
ObjData->mObjBody->setCollisionFlags(ObjData->mObjBody->getCollisionFlags() | CollisionObject::CF_KINEMATIC_OBJECT);
When i move the keyboard and Mouse i collect the information and set the following Where cpos and Ori are the current position and orientation of the object controlled by the user.
ObjData->mObjBody->setWorldTransform(btTransform(btQuaternion(Ori.x,Ori.y,Ori.z,Ori.w),btVector3(cPos.x,cPos.y,cPos.z)));
Therefore here is the QUESTION:
It seems that the controlled pobject does not collide with the other objects in the scene and cause any physic effects. They just passthrough them!!! What am i doing wrong to enable a CONTROLLED object that can create physics effects at runtime with other righidbodies in the Simulation.
Any help you can provide woult be greatful. am lost i just need a hint of sorts to proceed. A example code would be great.
Garibalde