Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. btRigidBody* Okno::addBolw(float x,float y,float z,float mass)
  2. {
  3.     btTransform t;  //position and rotation
  4.     t.setIdentity();
  5.     t.setOrigin(btVector3(x,y,z));  //put it to x,y,z coordinates
  6.     btCylinderShape * cylinder1 = new btCylinderShape(btVector3(1,1.7,1));
  7.  
  8.     btCylinderShape * cylinder2 = new btCylinderShape(btVector3(0.5, 1, 0.5));
  9.     btCompoundShape * bolw = new btCompoundShape();
  10.     bolw->addChildShape(t,cylinder1);
  11.     t.setIdentity();
  12.     t.setOrigin(btVector3(x,y+2.7,z));
  13.     bolw->addChildShape(t, cylinder2);
  14.     btVector3 inertia(0,0,0);
  15.     btScalar masses[2] = { mass,mass/2};
  16.     bolw->calculatePrincipalAxisTransform(masses,t,inertia);
  17.     t.setIdentity();
  18.    
  19.     btMotionState* motion=new btDefaultMotionState(t);  //set the position (and motion)
  20.     btRigidBody::btRigidBodyConstructionInfo info(mass*2,motion,bolw,inertia);  //create the constructioninfo, you can create multiple bodies with the same info
  21.     btRigidBody* body=new btRigidBody(info);    //let's create the body itself
  22.     body->setFriction(1);
  23.     body->setRestitution(0);
  24.     world->addRigidBody(body);  //and let the world know about it
  25.     bodies.push_back(body); //to be easier to clean, I store them a vector
  26.     return body;
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement