Ejemplo n.º 1
0
    def __init__(self, name, model, world, space, x, y, z):
        self.name = name
        self.obj = loader.loadModel('models/' + str(model))
        self.obj.reparentTo(render)
        self.obj.setPos(x, y, z)

        M = OdeMass()
        M.setBox(50, 1, 1, 1)

        self.boxBody = OdeBody(world)
        self.boxBody.setMass(M)
        self.boxBody.setPosition(self.obj.getPos(render))
        self.boxBody.setQuaternion(self.obj.getQuat(render))
        boxGeom = OdeBoxGeom(space, 1, 1, 1)
        boxGeom.setCollideBits(BitMask32(0x00000002))
        boxGeom.setCategoryBits(BitMask32(0x00000001))
        boxGeom.setBody(self.boxBody)

        frowneyCollider = self.obj.attachNewNode(CollisionNode(name))
        frowneyCollider.node().addSolid(CollisionSphere(0, 0, 0, 1))

        #kollision
        self.collider = self.obj.attachNewNode(CollisionNode(name))
        self.collider.node().addSolid(CollisionSphere(0, 0, 0, 1))

        print name + ' erschaffen. '
Ejemplo n.º 2
0
    def __init__(self, name, model, world, space,x, y, z):
        self.name = name
        self.obj = loader.loadModel('models/'+str(model))
        self.obj.reparentTo(render)
        self.obj.setPos(x,y,z)

        M = OdeMass()
        M.setBox(50, 1, 1, 1)

        self.boxBody = OdeBody(world)
        self.boxBody.setMass(M)
        self.boxBody.setPosition(self.obj.getPos(render))
        self.boxBody.setQuaternion(self.obj.getQuat(render))
        boxGeom = OdeBoxGeom(space, 1,1,1)
        boxGeom.setCollideBits(BitMask32(0x00000002))
        boxGeom.setCategoryBits(BitMask32(0x00000001))
        boxGeom.setBody(self.boxBody)

        frowneyCollider = self.obj.attachNewNode(CollisionNode(name))
        frowneyCollider.node().addSolid(CollisionSphere(0, 0, 0, 1))

        #kollision
        self.collider = self.obj.attachNewNode(CollisionNode(name))
        self.collider.node().addSolid(CollisionSphere(0, 0, 0, 1))

        print name+' erschaffen. '
Ejemplo n.º 3
0
    def __init__(self):

        # lade eine umgebung
        environment = loader.loadModel('models/world')
        environment.reparentTo(render)
        environment.setPos(0,0,0)

        # erstelle gravitation
        self.__odeWorld = OdeWorld()
        self.__odeWorld.setGravity(0, 0, -9.81)
        self.__odeWorld.initSurfaceTable(1)
        self.__odeWorld.setSurfaceEntry(0, 0, 150, 0.0, 9.1, 0.9, 0.00001, 0.0, 0.002)

        self.__space = OdeSimpleSpace()
        self.__space.setAutoCollideWorld(self.__odeWorld)
        self.__contacts = OdeJointGroup()
        self.__space.setAutoCollideJointGroup(self.__contacts)

        cm = CardMaker("ground")
        x = 1000
        cm.setFrame(-x, x, -x, x)
        ground = render.attachNewNode(cm.generate())
        ground.setPos(0, 0, -10)
        ground.lookAt(0, 0, -1)
        groundGeom = OdePlaneGeom(self.__space, Vec4(0, 0, 1, 0))
        groundGeom.setCollideBits(BitMask32(0x00000001))
        groundGeom.setCategoryBits(BitMask32(0x00000002))

        #kollision
        base.cTrav=CollisionTraverser()
        self.collisionHandler = CollisionHandlerQueue()

        print "Welt erschaffen. "

        #Alle Objekte:
        self.__allObjects = {}