Collision flags, etc.

theyesfish
Posts: 10
Joined: Sat Apr 11, 2009 7:12 pm

Collision flags, etc.

Post by theyesfish »

Hi, I'm creating a game with bullet and ogre (not ogrebullet though). I've been around the long way with barely working pipelines, buggy octree triangle mesh intersections and all so this is like a dream come true having discovered these engines!

But I'm having difficulty with lack of documentation, I want to make some objects static to use for the background, some I want to just turn off the gravity so they'll float there but still react to applyforce (like the camera), and of course character capsules for the player and NPCs.

I'm implementing bodies based on the hello-world tutorial

Code: Select all

btMotionState* fallMotionState =
		new OgreBulletMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)), (Ogre::SceneNode*)OgreNode);
	btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,fallMotionState,Shape,fallInertia);
Body = new btRigidBody(fallRigidBodyCI);
Body->setUserPointer(this);
Body->setCollisionFlags(btCollisionObject::CF_STATIC_OBJECT);
dynamicsWorld->addRigidBody(Body);
With default collision the bodies act normally when the simulation starts. CF_NO_CONTACT_RESPONSE works as expected. But if I set them to CF_STATIC_OBJECT then they look like they're static, but their origin is set to 0 - every static body in the scene is just stuck together at 0,0,0! CF_CHARACTER_OBJECT has no effect, the capsule just rolls around like a regular body.

What am I doing wrong? Is the code bad or have I failed to grasp some basic concepts?

Edit:

I've found the problem with the static objects. I have to force the graphic nodes to synchronize with the static body because they're never called otherwise.
Body->getMotionState()->setWorldTransform(Body->getWorldTransform());

EditEdit: Found the manual - it answered the rest of the above. They really should make it more visible than a small link to a PDF file!