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
Example #2
0
    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()
Example #3
0
    def __init__(self):
        sf.Application.__init__(self)
        patchDecl = ogre.VertexDeclaration()
        self.patchCtlPoints = 0
        # Create the global log manager instance
        self.logMgr = ogre.LogManager()
        # create the instance of our log listener
        self.myLog = MyLog()
        # create a "log"
        self.currentLog = ogre.LogManager.getSingletonPtr().createLog(
            "dummy.log",
            True,  # it's the default log
            False,  # I don't want it sent to the debug window
            True,  # it's a virtual log, so you need a listener :)
        )
        # register our listener
        self.currentLog.addListener(self.myLog)

        self.collisionConfiguration = bullet.btDefaultCollisionConfiguration()
        self.dispatcher = bullet.btCollisionDispatcher(self.collisionConfiguration)

        worldAabbMin = bullet.btVector3(-1000, -1000, -1000)
        worldAabbMax = bullet.btVector3(1000, 1000, 1000)
        maxProxies = 32766

        self.broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies)

        self.solver = bullet.btSequentialImpulseConstraintSolver()
        self.world = bullet.btDiscreteDynamicsWorld(
            self.dispatcher, self.broadphase, self.solver, self.collisionConfiguration
        )
        self.world.stepSimulation(0.1)
        self.world.stepSimulation(1)
        print "INIT OK"
Example #4
0
def initializePhysics():
    """Start the Bullet Physics engine."""
    global bullet_world
    global bullet_debug_drawer
    global bullet_collision_configuration
    global bullet_dispatcher
    global bullet_broadphase
    global bullet_solver

    bullet_collision_configuration = bullet.get_btDefaultCollisionConfiguration()
    bullet_dispatcher = bullet.get_btCollisionDispatcher1(bullet_collision_configuration)
    #bullet_broadphase = bullet.btDbvtBroadphase()
    bullet_broadphase = bullet.btAxisSweep3(
                                    bullet.btVector3(-10000, -10000, -10000),
                                    bullet.btVector3(10000, 10000, 10000),
                                    1024)
    bullet_solver = bullet.btSequentialImpulseConstraintSolver()

    bullet_world = bullet.btDiscreteDynamicsWorld(
                                    bullet_dispatcher,
                                    bullet_broadphase,
                                    bullet_solver,
                                    bullet_collision_configuration)
    bullet_world.setGravity(bullet.btVector3(0, -10, 0))
    bullet_world.getDispatchInfo().m_enableSPU = True

    bullet_debug_drawer = OgreBulletUtils.DebugDrawer(ogre_scene_manager)
    bullet_world.setDebugDrawer(bullet_debug_drawer)
    bullet_world.getDebugDrawer().setDebugMode(
                                       bullet.btIDebugDraw.DBG_DrawWireframe |
                                       bullet.btIDebugDraw.DBG_DrawAabb
                                       #bullet.btIDebugDraw.DBG_DrawContactPoints
                                       #bullet.btIDebugDraw.DBG_NoDebug
                                               )
Example #5
0
 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!")
Example #6
0
 def setupBullet( self ):
     self.collisionConfiguration = bullet.btDefaultCollisionConfiguration() 
     self.dispatcher = bullet.btCollisionDispatcher (self.collisionConfiguration) 
     worldAabbMin = bullet.btVector3(-1000,-1000,-1000) 
     worldAabbMax = bullet.btVector3(1000,1000,1000) 
     maxProxies = 32# 766 
     self.broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies) 
     self.solver = bullet.btSequentialImpulseConstraintSolver() 
     self.world = bullet.btDiscreteDynamicsWorld(self.dispatcher, self.broadphase , self.solver, self.collisionConfiguration) 
     self.world.stepSimulation(0.1)
     self.world.stepSimulation(1)
     print "Leaving setup"
Example #7
0
    def init(self, gravity):
        self.collisionConfiguration = bullet.btDefaultCollisionConfiguration()
        self.dispatcher = bullet.btCollisionDispatcher (self.collisionConfiguration)

        
        worldAabbMin = bullet.btVector3(-20000,-1000,-20000)
        worldAabbMax = bullet.btVector3(20000,1000,20000)
        self.broadphase = bullet.btAxisSweep3(worldAabbMin, worldAabbMax);

        self.solver = bullet.btSequentialImpulseConstraintSolver();

        self.world = bullet.btDiscreteDynamicsWorld(self.dispatcher, self.broadphase, self.solver,
                                                    self.collisionConfiguration);
        self.world.getDispatchInfo().m_enableSPU = True
        self.world.setGravity(bullet.btVector3(0,gravity,0));

        self.world.stepSimulation(0);
Example #8
0
# 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()

world.stepSimulation(0)
world.stepSimulation(-0.333)