コード例 #1
0
ファイル: physics.py プロジェクト: simeks/D0016E-VIS
    def createCylinder(self, sceneNode, width, height, depth, mass):
        pos = sceneNode.getPosition();
        rot = sceneNode.getOrientation();
        
        # Skapa motion state
        motionState = NodeMotionState(sceneNode);

        shape = bullet.btCylinderShape(bullet.btVector3(width/2.0, height/2.0, depth/2.0));
        inertia = bullet.btVector3(0,0,0);
        shape.calculateLocalInertia(mass, inertia);
        
        constructInfo = bullet.btRigidBody.btRigidBodyConstructionInfo(
            mass, motionState, shape, inertia);
        rigidBody = bullet.btRigidBody(constructInfo);

        self.bodies.append(PhysicsWorld.Body(shape, motionState, constructInfo, rigidBody));
        self.world.addRigidBody(rigidBody);
コード例 #2
0
 def createCylinderShape(entity, axis):
     """Bullet Cylinder Shape"""
     ## mesh extents
     e = MeshInfo.getBoundingBox(entity)
     size = bullet.btVector3(e.getHalfSize().x,
                             e.getHalfSize().y,
                             e.getHalfSize().z)
     shape = None
     if axis == BulletShapes.CYLINDERX:
         height = size.x()
         radius = max(size.z(), size.y())
         shape = bullet.btCylinderShapeX(bullet.btVector3(height, radius, radius))
     if axis == BulletShapes.CYLINDERY:
         height = size.y()
         radius = max(size.z(), size.x())
         shape = bullet.btCylinderShape(bullet.btVector3(radius, height, radius))
     if axis == BulletShapes.CYLINDERZ:
         height = size.z()
         radius = max(size.x(), size.y())
         shape = bullet.btCylinderShapeZ(bullet.btVector3(radius, radius, height))
     return shape
コード例 #3
0
 def createCylinderShape(entity, axis):
     """Bullet Cylinder Shape"""
     ## mesh extents
     e = MeshInfo.getBoundingBox(entity)
     size = bullet.btVector3(e.getHalfSize().x,
                             e.getHalfSize().y,
                             e.getHalfSize().z)
     shape = None
     if axis == BulletShapes.CYLINDERX:
         height = size.x()
         radius = max(size.z(), size.y())
         shape = bullet.btCylinderShapeX(
             bullet.btVector3(height, radius, radius))
     if axis == BulletShapes.CYLINDERY:
         height = size.y()
         radius = max(size.z(), size.x())
         shape = bullet.btCylinderShape(
             bullet.btVector3(radius, height, radius))
     if axis == BulletShapes.CYLINDERZ:
         height = size.z()
         radius = max(size.x(), size.y())
         shape = bullet.btCylinderShapeZ(
             bullet.btVector3(radius, radius, height))
     return shape