34 #include "LinearMath/btVector3.h"
35 #include "BulletCollision/CollisionShapes/btBoxShape.h"
75 tgRigidInfo::initRigidBody(world);
92 std::cout <<
"creating box with tags " << getTags() << std::endl;
104 const double width = m_config.
width;
105 const double height = m_config.
height;
109 new btBoxShape(btVector3(width, length / 2.0, height));
122 const double width = m_config.
width;
123 const double height = m_config.
height;
124 const double density = m_config.
density;
125 const double volume = length * width * height;
126 return volume * density;
131 const btVector3& destinationPoint)
const
138 const btVector3& destinationPoint,
139 const double rotation)
const
141 if (referencePoint == destinationPoint)
144 std::invalid_argument(
"Destination point is the reference point.");
147 const btVector3 cylinderAxis = (
getTo() -
getFrom()).normalize();
148 const btVector3 cylinderAxis2 = (
getTo() -
getFrom()).normalize();
150 const btVector3 refToDest =
151 (referencePoint - destinationPoint).normalize();
154 btVector3 rotationAxis = cylinderAxis.cross(refToDest);
157 if (rotationAxis.length() == 0.0)
159 btScalar a = cylinderAxis[0];
160 btScalar b = cylinderAxis[1];
161 btScalar c = cylinderAxis[2];
163 rotationAxis = btVector3(b - c, -a, a).normalize();
166 const btVector3 directional =
167 cylinderAxis.rotate(rotationAxis, -M_PI / 2.0).normalize();
175 const btVector3 surfaceVector = directional.rotate(cylinderAxis2, rotation).normalize()
180 return referencePoint + surfaceVector;
185 std::set<tgRigidInfo*> leaves;
191 std::set<btVector3> contained;
193 contained.insert(
getTo());
virtual btVector3 getConnectionPoint(const btVector3 &referencePoint, const btVector3 &destinationPoint) const
const double rollFriction
virtual double getMass() const
tgRigidInfo * createRigidInfo(const tgPair &pair)
virtual std::set< tgRigidInfo * > getLeafRigids()
Contains the definition of class tgWorldBulletPhysicsImpl.
virtual void initRigidBody(tgWorld &world)
virtual btCollisionShape * getCollisionShape(tgWorld &world) const
const btVector3 & getFrom() const
Class that interfaces with Bullet to build the boxes.
virtual std::set< btVector3 > getContainedNodes() const
const btVector3 & getTo() const
virtual btRigidBody * getRigidBody()
btCollisionObject * m_collisionObject
tgWorldImpl & implementation() const
tgBoxInfo(const tgBox::Config &config)
void addCollisionShape(btCollisionShape *pShape)
btCollisionShape * m_collisionShape