def __init__(self, app): self.app = app self.body = {} app.world = self self.frameListener = WorldFrameListener(self) app.root.addFrameListener(self.frameListener) self.worldNode = app.sceneManager.getRootSceneNode().createChildSceneNode("World") self.physCollisionConfiguration = bullet.btDefaultCollisionConfiguration() self.physDispatcher = bullet.btCollisionDispatcher (self.physCollisionConfiguration) # self.physBroadphase = bullet.btAxisSweep3(bullet.btVector3(-1000, -1000, -1000), bullet.btVector3(1000, 1000, 1000)) self.physBroadphase = bullet.btDbvtBroadphase() self.physGhostCallback = bullet.btGhostPairCallback() self.physBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(self.physGhostCallback) self.physSolver = bullet.btSequentialImpulseConstraintSolver() self.physWorld = bullet.btDiscreteDynamicsWorld(self.physDispatcher, self.physBroadphase, self.physSolver, self.physCollisionConfiguration) self.physWorld.setGravity(bullet.btVector3(0, -10, 0)) # self.cells = {} self.entities = {} self.setupWorld()
def __init__(self, sceneManager): self.sceneManager = sceneManager """ bounds = ogre.AxisAlignedBox(-100.0, -100.0, -100.0, 100.0, 100.0, 100.0) self.world = dynamics.DynamicsWorld(self.sceneManager, bounds, ogre.Vector3(0.0, -9.91, 0.0)) """ self.collisionConfiguration = bullet.get_btDefaultCollisionConfiguration() self.dispatcher = bullet.get_btCollisionDispatcher1(self.collisionConfiguration) self.broadphase = bullet.btDbvtBroadphase() self.solver = bullet.btSequentialImpulseConstraintSolver() self.world = bullet.btDiscreteDynamicsWorld(self.dispatcher, self.broadphase, self.solver, self.collisionConfiguration) self.world.setGravity(bullet.btVector3(0, 0, 0)) self.bodies = [] self.shapes = [] self.cubes = [] self.motionStates = [] self.elapsedTime = 0.0 self.duration = 10.0 self.curCubeIdx = 0 self.tangentBundle = None return None
def load_level(self): """Setup the bullet world""" logging.info("Loading dynamic world...") self.collisionConfiguration = bullet.get_btDefaultCollisionConfiguration() self.dispatcher = bullet.get_btCollisionDispatcher1(self.collisionConfiguration) self.broadphase = bullet.btDbvtBroadphase() self.solver = bullet.btSequentialImpulseConstraintSolver() self.dynamics_world = bullet.btDiscreteDynamicsWorld(self.dispatcher, self.broadphase, self.solver, self.collisionConfiguration) logging.info("Dynamic world loaded!")
# s = bullet.btBoxShape(bullet.btVector3(10,10,10)) # body = bullet.btRigidBody(1, ms, s) # print body # collisionConfiguration = bullet.btDefaultCollisionConfiguration() collisionConfiguration = bullet.get_btDefaultCollisionConfiguration() dispatcher = bullet.get_btCollisionDispatcher1(collisionConfiguration) # worldAabbMin = bullet.btVector3(-1000,-1000,-1000) # worldAabbMax = bullet.btVector3(1000,1000,1000) # maxProxies = 32766 # broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies) # solver = bullet.btSequentialImpulseConstraintSolver() broadphase = bullet.btDbvtBroadphase() solver = bullet.btSequentialImpulseConstraintSolver() world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration) world.setGravity(bullet.btVector3(0, -10, 0)) world.getDispatchInfo().m_enableSPU = True print "WORLD:=", world print solver print broadphase print dispatcher print collisionConfiguration for x in range(30): world.stepSimulation(x * 1 / 30) print getDeltaTimeMicroseconds()