示例#1
0
 def createCubicObstacle(self, pos, obstacleIndex):
     self.notify.debug('create obstacleindex %s' % obstacleIndex)
     sideLength = IceGameGlobals.TireRadius * 2
     geom = OdeBoxGeom(self.space, sideLength, sideLength, sideLength)
     geom.setCollideBits(self.allTiresMask)
     geom.setCategoryBits(self.obstacleMask)
     self.space.setCollideId(geom, self.obstacleCollideId)
     tireModel = loader.loadModel('phase_4/models/minigames/ice_game_crate')
     tireModel.setPos(pos)
     tireModel.reparentTo(render)
     geom.setPosition(tireModel.getPos())
     tireModel.setZ(0)
     return tireModel
示例#2
0
for i in range(randint(5, 10)):
    # Setup the geometry
    boxNP = box.copyTo(render)
    # boxNP.setPos(randint(-10, 10), randint(-10, 10), 10 + random())
    boxNP.setPos(random() * 10, random() * 10, 10 + random())
    boxNP.setColor(random(), random(), random(), 1)
    boxNP.setHpr(randint(-45, 45), randint(-45, 45), randint(-45, 45))
    # Create the body and set the mass
    boxBody = OdeBody(world)
    M = OdeMass()
    M.setBox(5, 1, 1, 1)
    boxBody.setMass(M)
    boxBody.setPosition(boxNP.getPos(render))
    boxBody.setQuaternion(boxNP.getQuat(render))
    # Create a BoxGeom
    boxGeom = OdeBoxGeom(space, 1, 1, 1)
    # boxGeom = OdeTriMeshGeom(space, OdeTriMeshData(boxNP, True))
    boxGeom.setCollideBits(BitMask32(0x00000002))
    boxGeom.setCategoryBits(BitMask32(0x00000001))
    boxGeom.setBody(boxBody)
    boxes.append((boxNP, boxBody))

# Add a plane to collide with
cm = CardMaker("ground")
cm.setFrame(-20, 20, -20, 20)
ground = render.attachNewNode(cm.generate())
ground.setPos(0, 0, 0)
ground.lookAt(0, 0, -1)
groundGeom = OdePlaneGeom(space, Vec4(0, 0, 1, 0))
# groundGeom = OdeTriMeshGeom(space, OdeTriMeshData(ground, True))
groundGeom.setCollideBits(BitMask32(0x00000001))
示例#3
0
                  random() * 10 - 5, 1 + random()]))
    new_box.set_rgba([random(), random(), random(), 1])
    new_box.set_rotmat(
        rm.rotmat_from_euler(random() * math.pi / 4,
                             random() * math.pi / 4,
                             random() * math.pi / 4))
    new_box.attach_to(base)
    # Create the body and set the mass
    boxBody = OdeBody(world)
    M = OdeMass()
    M.setBox(3, .3, .3, .3)
    boxBody.setMass(M)
    boxBody.setPosition(da.npv3_to_pdv3(new_box.get_pos()))
    boxBody.setQuaternion(da.npmat3_to_pdquat(new_box.get_rotmat()))
    # Create a BoxGeom
    boxGeom = OdeBoxGeom(space, .3, .3, .3)
    # boxGeom = OdeTriMeshGeom(space, OdeTriMeshData(new_box.objpdnp, True))
    boxGeom.setCollideBits(BitMask32(0x00000002))
    boxGeom.setCategoryBits(BitMask32(0x00000001))
    boxGeom.setBody(boxBody)
    boxes.append((new_box, boxBody))

# Add a plane to collide with
ground = cm.gen_box(extent=[20, 20, 1], rgba=[.3, .3, .3, 1])
ground.set_pos(np.array([0, 0, -1.5]))
ground.attach_to(base)
# groundGeom = OdeTriMeshGeom(space, OdeTriMeshData(ground.objpdnp, True))
groundGeom = OdePlaneGeom(space, Vec4(0, 0, 1, -1))
groundGeom.setCollideBits(BitMask32(0x00000001))
groundGeom.setCategoryBits(BitMask32(0x00000002))
示例#4
0
 def add_static_box(self, x, y, z):
     self.box = OdeBoxGeom(self.space, Vec3(x, y, z))
     self.box.set_position(0, 0, 25)