Пример #1
0
    def add_sphere_at(self, x, y, z, radius, color, room):
        s = Primitives.getSphere(radius)

        colorname = 'added_sphere_%d' % id(s)
        TextureManager.getInstance().addTexture(
            colorname, Texture(1, 1, color))
        s.setTexture(colorname)
        s.build()
        if not hasattr(self, 'extra_shapes'):
            self.extra_shapes = []
        self.extra_shapes.append((s, x, y, z))
        room.world.addObject(s)
Пример #2
0
    def __init__(self, r, mass=1, color=Color.red):
        colorname = 'sphere_%d' % id(self)
        self.shape = Primitives.getSphere(r)
        TextureManager.getInstance().addTexture(
            colorname, Texture(1, 1, color))
        self.shape.setTexture(colorname)
        self.shape.build()

        shape = BoxShape(Vector3f(r / 2.0, r / 2.0, r / 2.0))

        inertia = Vector3f(0, 0, 0)
        shape.calculateLocalInertia(mass, inertia)

        t = Transform()
        t.setIdentity()

        ms = DefaultMotionState(t)
        rb = RigidBodyConstructionInfo(mass, ms, shape, inertia)
        self.physics = RigidBody(rb)