python from direct.showbase.ShowBase import ShowBase from panda3d.core import Point3 from panda3d.bullet import BulletWorld, BulletSphereShape, BulletRigidBodyNode class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) self.world = BulletWorld() shape = BulletSphereShape(1) body = BulletRigidBodyNode("Sphere") body.add_shape(shape) node = self.render.attach_new_node(body) self.world.attach_rigid_body(node.node()) node.set_pos(0, 0, 10) body.set_mass(1) body.set_gravity(Point3(0, 0, -9.81)) self.accept("enter_collision", self.on_collision) def on_collision(self, entry): print("Collision occurred!") app = MyApp() app.run()


上一篇:
下一篇:
切换中文