Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btRigidBody* Okno::addBolw(float x,float y,float z,float mass)
- {
- btTransform t; //position and rotation
- t.setIdentity();
- t.setOrigin(btVector3(x,y,z)); //put it to x,y,z coordinates
- btCylinderShape * cylinder1 = new btCylinderShape(btVector3(1,1.7,1));
- btCylinderShape * cylinder2 = new btCylinderShape(btVector3(0.5, 1, 0.5));
- btCompoundShape * bolw = new btCompoundShape();
- bolw->addChildShape(t,cylinder1);
- t.setIdentity();
- t.setOrigin(btVector3(x,y+2.7,z));
- bolw->addChildShape(t, cylinder2);
- btVector3 inertia(0,0,0);
- btScalar masses[2] = { mass,mass/2};
- bolw->calculatePrincipalAxisTransform(masses,t,inertia);
- t.setIdentity();
- btMotionState* motion=new btDefaultMotionState(t); //set the position (and motion)
- btRigidBody::btRigidBodyConstructionInfo info(mass*2,motion,bolw,inertia); //create the constructioninfo, you can create multiple bodies with the same info
- btRigidBody* body=new btRigidBody(info); //let's create the body itself
- body->setFriction(1);
- body->setRestitution(0);
- world->addRigidBody(body); //and let the world know about it
- bodies.push_back(body); //to be easier to clean, I store them a vector
- return body;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement