Compound objects problems.

Please don't post Bullet support questions here, use the above forums instead.
sr_dready
Posts: 4
Joined: Fri Jun 11, 2010 2:12 pm

Compound objects problems.

Post by sr_dready »

Hi, I'm trying to integrate bullet in my libraries, for my further applications.
So I've created a function like this that will create a new compound object:

Code: Select all

void oaCompoundObj::AddChild(oaObject * obj, Pose p){
  Trace("oaCompoundObj::AddChild(oaObject * obj, Pose p)");

  //  obj->onCompound=true;
  children.push_back(obj);


#ifdef WITH_BULLET
  btCompoundShape * shape = new btCompoundShape();;
  if (collisionShape) {
	Trace("oaCompoundObj::AddChild(oaObject * obj, Pose p)2");

	shape=(btCompoundShape *)collisionShape;
	btTransform objtrans;
	objtrans.setIdentity();
	objtrans.setOrigin(btVector3(p.tx,p.ty,p.tz));
	objtrans.setRotation(btQuaternion(p.angle/180.0*M_PI, 0, 0, 0));
	shape->addChildShape(objtrans , obj->collisionShape);

  }
   
#endif

}
next I have code for Glut generation, then the compound object appear, and falls down, but it don't collide with the other objects (simple rigid bodies).
I'm creating the collision shape for the compound like this:

Code: Select all

void oaObject::initPhysics(){
	Trace("oaObject::initPhysics");
	if (!collisionShape)
	  buildCollisionShape();
	if (!motionState)
	  motionState=
		new btDefaultMotionState(btTransform(btQuaternion(btVector3(pose.rx,pose.ry,pose.rz),pose.angle/180.0*M_PI), btVector3(pose.tx,pose.ty,pose.tz)));
	btVector3 bodyInertia(0,0,0);
	if (mass!=0)
	  collisionShape->calculateLocalInertia(mass,bodyInertia);
	
	btRigidBody::btRigidBodyConstructionInfo
	  rigidBodyCI(mass,motionState,collisionShape,bodyInertia);
	rigidBody = new btRigidBody(rigidBodyCI);
	
}


InitPhysics() do the same as localCreateRigidBody(mass,pose,object).
sr_dready
Posts: 4
Joined: Fri Jun 11, 2010 2:12 pm

Re: Compound objects problems.

Post by sr_dready »

Ok, I think I've already checked my error.
Thanks for the reading. This Post is closed.