예제 #1
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"
예제 #2
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
                                               )
예제 #3
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"
예제 #4
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);
예제 #5
0
import ogre.physics.bullet as bullet
t = bullet.btTransform()
ms = bullet.btDefaultMotionState (t)
s = bullet.btBoxShape(bullet.btVector3(10,10,10))
body = bullet.btRigidBody(1, ms, s)
print body


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

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

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

solver = bullet.btSequentialImpulseConstraintSolver()

world = bullet.btDiscreteDynamicsWorld(dispatcher, broadphase , solver, collisionConfiguration)
world.getDispatchInfo().m_enableSPU = True
world.setGravity(bullet.btVector3(0,-10,0))

print world
print dir(world)
print solver
print broadphase
print dispatcher
print collisionConfiguration 
for x in range (30):        
    world.stepSimulation( x * 1/30)