def __init__(self): ''' ''' ShowBase.__init__(self) loadPrcFileData("", "notify-level-x11display fatal") # This variable gets set to true when a collision-event gets fired and to false every ode-frame self.ode_collisiontest = False base.setFrameRateMeter(True) # Show the Framerate self.world = OdeWorld() self.deltaTimeAccumulator = 0.0 # this variable is necessary to track the time for the physics self.stepSize = 1.0 / 300.0 # This stepSize makes the simulation run at 300 frames per second # Initialize Collisions (ODE) self.space = OdeSimpleSpace() # Initialize the surface-table, it defines how objects interact with each other self.world.initSurfaceTable(1) self.world.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002) self.space.setAutoCollideWorld(self.world) self.contactgroup = OdeJointGroup() self.space.setAutoCollideJointGroup(self.contactgroup) self.startGame()
def __init__(self, canRender=0): self.canRender = canRender self.world = OdeWorld() self.space = OdeSimpleSpace() self.contactgroup = OdeJointGroup() self.bodyList = [] self.geomList = [] self.massList = [] self.rayList = [] self.showContacts = 0 self.jointMarkers = [] self.jointMarkerCount = 64 self.meshDataList = [] self.geomDataList = [] self.commonObjectInfoDict = {} self.maxColCount = 0 if self.canRender: self.odePandaRelationList = self.bodyList self.root = render.attachNewNode('physics root node') else: self.root = NodePath('physics root node') self.placerNode = self.root.attachNewNode('Placer') self.subPlacerNode = self.placerNode.attachNewNode('Placer Sub Node') self.commonObjectDict = {} self.commonId = 0 self.worldAttach = self.root.attachNewNode('physics geom attach point') self.timingCycleLength = 10.0 self.timingCycleOffset = 0.0 self.timingSimTime = 0.0 self.FPS = 60.0 self.DTAStep = 1.0 / self.FPS self.DTA = 0 self.useQuickStep = False self.deterministic = True self.numStepsInSimulateTask = 0
def __init__(self, base, mapNo): self.isListening = False # Holds rigid bodies, joints, controls global params self.world = OdeWorld() self.world.setGravity(0, 0, -9.8) st = SurfaceType() st.load(self.world) del st self.contactgroup = OdeJointGroup() self.space = OdeHashSpace() self.space.setAutoCollideWorld(self.world) self.space.setAutoCollideJointGroup(self.contactgroup) self.space.setCollisionEvent(EventType.ODE_COLLISION) base.accept(EventType.ODE_COLLISION, self.onCollision) self.ball = Ball(self.world, self.space, "Johanneksen pallo") self.level = Level(self, mapNo) self.player = Player("Johannes") self.camera = Camera(base, self.ball)
def createWorldAndStuff(): global world global space global contactgroup world = OdeWorld() world.setGravity(0, 0, -9.81) # The surface table is needed for autoCollide world.initSurfaceTable(1) world.setSurfaceEntry(0, 0, 15000, 0.001, 0.9, 0.9, 0.00001, 0.1, 0.002) # Create a space and add a contactgroup to it to add the contact joints space = OdeSimpleSpace() space.setAutoCollideWorld(world) contactgroup = OdeJointGroup() space.setAutoCollideJointGroup(contactgroup)
def __init__(self): ShowBase.__init__(self) base.setFrameRateMeter(True) # base.disableMouse() # initialise the lights alight = AmbientLight('alight') alight.setColor(VBase4(0.2, 0.2, 0.2, 1)) alnp = render.attachNewNode(alight) render.setLight(alnp) # Initialise the Ode world self.world = OdeWorld() self.world.setGravity(0, 0, -9.81) # load the models # environment self.environ = self.loader.loadModel("data/models/Plane") # Reparent the model to render. self.environ.reparentTo(self.render) # Apply scale and position transforms on the model. self.environ.setScale(10, 10, 10) self.environ.setPos(0, 0, 0) # racer self.glider = self.loader.loadModel("data/models/vehicle01") # Reparent the model to render. self.glider.reparentTo(self.render) # Apply scale and position transforms on the model. self.glider.setScale(1, 1, 1) self.glider.setPos(0, 0, 50) self.myBody = OdeBody(self.world) self.myBody.setPosition(self.glider.getPos(render)) self.myBody.setQuaternion(self.glider.getQuat(render)) self.myMass = OdeMass() self.myMass.setBox(11340, 1, 1, 1) self.myBody.setMass(self.myMass) # set up the camera base.camera.reparentTo(self.glider) base.camera.setPos(0, -30, 10) base.camera.lookAt(self.glider) # add physics to taskmgr taskMgr.add(self.physicsTask, 'physics')
def __init__(self, game): self.game = game self.world = OdeWorld() self.world.setGravity(0, 0, -9.81 * 3) self.group = OdeJointGroup() self.space = OdeHashSpace() self.space.setAutoCollideWorld(self.world) self.space.setAutoCollideJointGroup(self.group) self.setSurfaceTables() self.objects = [] self.objectsToRemove = [] self.postStepTasks = [] self.engineRunning = True self.dtAccumulator = 0.0 self.physicsFps = 90 self.physicsMinFps = 10 base.taskMgr.doMethodLater(0.1, self.processPhysics, "Physics") base.accept("escape", self.togglePhysics) self.space.setCollisionEvent("odeCollision") base.accept("odeCollision", self.onCollision)
def __init__(self): # Disable Panda's base camera mover base.disableMouse() base.setBackgroundColor(0, 0, 0, 0) self.state = Game.STATE_INITIALIZING # contains a list of the ships in game self.ships = None self.players = None self.bullets = None self.stars = None self.planet = None self.time = 0.0 self.isListening = False getModelPath().prependDirectory(Filename('./media/')) self.physWorld = OdeWorld() self.physWorld.setGravity(0, 0, 0) self.physWorld.initSurfaceTable(1) self.physWorld.setSurfaceEntry( 0, 0, 1.0, # u .35, # elasticity .01, # minimum threshold for physical movement .01, # .00000001, # softening .01, # .01) # dampening self.physSpace = OdeHashSpace() self.winnerText = None self.gameFrames = 0 self.lastWarp = 0 self.cameraMode = Game.CAMERA_MODE_GAME self.lastCameraPos = None self.pause = False
class Physical(object): world = OdeWorld() world.setGravity(0, 0, 0) def __init__(self): self.world = Physical.world
from pandac.PandaModules import loadPrcFileData from direct.directbase import DirectStart from pandac.PandaModules import OdeWorld, OdeSimpleSpace, OdeJointGroup from pandac.PandaModules import OdeBody, OdeMass, OdeSphereGeom, OdePlaneGeom from pandac.PandaModules import BitMask32, CardMaker, Vec4, Quat from pandac.PandaModules import PNMImage, PNMPainter, PNMBrush, Texture from random import randint, random # Setup our physics world world = OdeWorld() world.setGravity(0, 0, -9.81) # The surface table is needed for autoCollide world.initSurfaceTable(1) world.setSurfaceEntry(0, 0, 100, 1.0, 9.1, 0.9, 0.00001, 0.0, 0.002) # Create a space and add a contactgroup to it to add the contact joints space = OdeSimpleSpace() space.setAutoCollideWorld(world) contactgroup = OdeJointGroup() space.setAutoCollideJointGroup(contactgroup) # Load the ball ball = loader.loadModel("cilindroB") ball.flattenLight() # Apply transform ball.setTextureOff() # Add a random amount of balls balls = [] # This 'balls' list contains tuples of nodepaths with their ode geoms for i in range(15):