def createGhostObjectEntity(self, sceneNode, radius): pos = sceneNode.getPosition() transform = bullet.btTransform() transform.setIdentity() transform.setOrigin(bullet.btVector3(pos.x, pos.y, pos.z)) ghostObject = bullet.btPairCachingGhostObject() ghostObject.setWorldTransform(transform) sphereShape = bullet.btSphereShape(1.0) ghostObject.setCollisionShape(sphereShape) #ghostObject.setCollisionFlags(bullet.btCollisionObject.CO_GHOST_OBJECT) actionEntity = ActionEntity(self.world, ghostObject, sceneNode) self.world.addCollisionObject(ghostObject, bullet.btBroadphaseProxy.SensorTrigger, bullet.btBroadphaseProxy.AllFilter) #self.world.getBroadphase().getOverlappingPairCache().setInternalGhostPairCallback(bullet.btGhostPairCallback()) #self.world.addAction(actionEntity) self.shapes.append(sphereShape) return actionEntity
def createBoxes( self ): print 2 ent = self.sceneManager.createEntity( "box", "cube.mesh" ) print 2 node = self.sceneManager.getRootSceneNode().createChildSceneNode() print 2 node.attachObject( ent ) print 2 ent.setMaterialName( "Examples/RustySteel") print 2 mass = 10 fallInertia = bullet.btVector3(0, 0, 0) print 2 shape=bullet.btSphereShape(1) print 2 shape.calculateLocalInertia(mass, fallInertia) print "Creating motionState" motionState=OgreMotionState(bullet.btTransform(bullet.btQuaternion(0, 0, 0, 1), bullet.btVector3(0, 50, 0))) print "creating construct" construct = bullet.btRigidBody.btRigidBodyConstructionInfo(mass, motionState, shape, fallInertia) print "creating object" Object=bullet.btRigidBody(construct) # ...this should work in my eyes print "adding rigidBody" self.world.addRigidBody(Object) print "completed" self.world.stepSimulation(1)
def createSphere(self, sceneNode, radius, mass): pos = sceneNode.getPosition(); rot = sceneNode.getOrientation(); # Skapa motion state motionState = NodeMotionState(sceneNode); sphereShape = bullet.btSphereShape(radius); inertia = bullet.btVector3(0,0,0); sphereShape.calculateLocalInertia(mass, inertia); constructInfo = bullet.btRigidBody.btRigidBodyConstructionInfo( mass, motionState, sphereShape, inertia); rigidBody = bullet.btRigidBody(constructInfo); self.bodies.append(PhysicsWorld.Body(sphereShape, motionState, constructInfo, rigidBody)); self.world.addRigidBody(rigidBody);
def createSphere(self, pos, radius, node): mass = 1.0 res = 0.1 bodyFriction = 0.8 fallInertia = bullet.btVector3(0, 0, 0) sphereId = len(self.bodies) sphereShape = bullet.btSphereShape(radius) sphereShape.calculateLocalInertia(mass, fallInertia) sphereMotionState = OgreMotionState(bullet.btTransform(bullet.btQuaternion(0, 0, 0, 1), bullet.btVector3(pos.x, pos.y, pos.z)), node) sphereBodyCI = bullet.btRigidBody.btRigidBodyConstructionInfo(mass, sphereMotionState, sphereShape, fallInertia) sphereBody = bullet.btRigidBody(sphereBodyCI) sphereBody.setActivationState(4) sphereBody.setCollisionFlags(bullet.btCollisionObject.CF_KINEMATIC_OBJECT) self.world.addRigidBody(sphereBody) self.motionStates.append(sphereMotionState) self.bodies.append(sphereBody) self.shapes.append(sphereShape) return None
def createSphereShape(entity): """Bullet Sphere Shape""" ## mesh extents radius = MeshInfo.getExtentsRadius(entity) return bullet.btSphereShape(radius)
def setWorldTransform(self, WorldTrans): # print "setWorldTrans", WorldTrans self.Position = ogre.Vector3(WorldTrans.getOrigin().x(), WorldTrans.getOrigin().y(), WorldTrans.getOrigin().z()) self.Quaternion = ogre.Quaternion( WorldTrans.getRotation().w(), WorldTrans.getRotation().x(), WorldTrans.getRotation().y(), WorldTrans.getRotation().z(), ) # print "setWorldTrans", WorldTrans mass = 10 fallInertia = bullet.btVector3(0, 0, 0) shape = bullet.btSphereShape(1) shape.calculateLocalInertia(mass, fallInertia) print "Creating motionState" motionState = OgreMotionState(bullet.btTransform(bullet.btQuaternion(0, 0, 0, 1), bullet.btVector3(0, 50, 0))) print "1" construct = bullet.btRigidBody.btRigidBodyConstructionInfo(mass, motionState, shape, fallInertia) print "1" Object = bullet.btRigidBody(construct) # ...this should work in my eyes print dir(Object) print "1" world.addRigidBody(Object) print "1" for x in range(90): world.stepSimulation(x * 1 / 30)