当前位置: 首页>>代码示例>>Python>>正文


Python BulletRigidBodyNode.setRestitution方法代码示例

本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.setRestitution方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.setRestitution方法的具体用法?Python BulletRigidBodyNode.setRestitution怎么用?Python BulletRigidBodyNode.setRestitution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.bullet.BulletRigidBodyNode的用法示例。


在下文中一共展示了BulletRigidBodyNode.setRestitution方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createPlane

# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setRestitution [as 别名]
    def createPlane(self, pos):
        rb = BulletRigidBodyNode("plane")
        rb.addShape(BulletPlaneShape(Vec3(0, 0, 1), 1))
        rb.setFriction(1.0)
        rb.setAnisotropicFriction(1.0)
        rb.setRestitution(1.0)

        np = self.render.attachNewNode(rb)
        np.setPos(pos)
        np.setCollideMask(BitMask32.bit(0))

        self.world.attachRigidBody(rb)

        return np
开发者ID:BarkingMouseStudio,项目名称:python-experiments,代码行数:16,代码来源:app.py

示例2: makeBall

# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setRestitution [as 别名]
 def makeBall(self, num, pos = (0, 0, 0)):
   shape = BulletSphereShape(0.5)
   node = BulletRigidBodyNode('ball_' + str(num))
   node.setMass(1.0)
   node.setRestitution(.9)
   node.setDeactivationEnabled(False)
   node.addShape(shape)
   physics = render.attachNewNode(node)
   physics.setPos(*pos)
   self.world.attachRigidBody(node)
   model = loader.loadModel('models/ball')
   color = self.makeColor()
   model.setColor(color)
   self.ballColors['ball_' + str(num)] = color
   model.reparentTo(physics)
开发者ID:r3t,项目名称:master-term1-gamedev,代码行数:17,代码来源:main.py

示例3: createBox

# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setRestitution [as 别名]
    def createBox(self, mass, pos, scale, color):
        rb = BulletRigidBodyNode('box')
        rb.addShape(BulletBoxShape(scale))
        rb.setMass(mass)
        rb.setLinearDamping(0.2)
        rb.setAngularDamping(0.9)
        rb.setFriction(1.0)
        rb.setAnisotropicFriction(1.0)
        rb.setRestitution(0.0)

        self.world.attachRigidBody(rb)

        np = self.render.attachNewNode(rb)
        np.setPos(pos)
        np.setCollideMask(BitMask32.bit(1))

        cube = self.loader.loadModel('cube')
        cube.setScale(scale)
        cube.setColor(color)
        cube.reparentTo(np)

        return np
开发者ID:BarkingMouseStudio,项目名称:python-experiments,代码行数:24,代码来源:app.py

示例4: setupObstacleThree

# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setRestitution [as 别名]
 def setupObstacleThree(self, pos, scale, turn):
   # Box A
   shape = BulletBoxShape(Vec3(0.1, 0.1, 0.1))
   
   bodyA = BulletRigidBodyNode('Box A')
   bodyA.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyA)
   bodyNP.node().addShape(shape)
   bodyNP.setCollideMask(BitMask32.allOn())
   bodyNP.setPos(pos)
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(0.1, 0.1, 0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyA)
   
   #Box B
   shape = BulletBoxShape(Vec3(0.1,0.1,0.1))
   
   bodyB = BulletRigidBodyNode('Box B')
   bodyB.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyB)
   bodyNP.node().addShape(shape)
   bodyNP.setCollideMask(BitMask32.allOn())
   bodyNP.setPos(pos)
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(0.1,0.1,0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyB)
   
   # Slider
   frameA = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   frameB = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   
   slider = BulletSliderConstraint(bodyA, bodyB, frameA, frameB, True)
   slider.setDebugDrawSize(2.0)
   slider.setLowerLinearLimit(0)
   slider.setUpperLinearLimit(12)
   slider.setLowerAngularLimit(-90)
   slider.setUpperAngularLimit(-85)
   self.world.attachConstraint(slider)
   
   # Box C
   shape = BulletBoxShape(Vec3(1, 3, 0.1))
   
   bodyC = BulletRigidBodyNode('Box C')
   bodyC.setRestitution(1.0)
   bodyNP = self.worldNP.attachNewNode(bodyC)
   bodyNP.node().addShape(shape)
   bodyNP.node().setMass(0.1)
   bodyNP.node().setDeactivationEnabled(False)
   bodyNP.setCollideMask(BitMask32.allOn())  
   bodyNP.setPos(Vec3(pos.getX() + 3, pos.getY() - 4, pos.getZ()))
   bodyNP.setHpr(turn)
   
   visNP = loader.loadModel('media/models/box.egg')
   visNP.setScale(Vec3(1, 3, 0.1)*2*scale)
   visNP.clearModelNodes()
   visNP.reparentTo(bodyNP)
   
   self.world.attachRigidBody(bodyC)
   
   bodyNP.node().setLinearVelocity(-100)
   
   # Slider
   frameA = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   frameB = TransformState.makePosHpr(Point3(0, 0, 0), Vec3(0, 0, 0))
   
   slider = BulletSliderConstraint(bodyA, bodyC, frameA, frameB, True)
   slider.setDebugDrawSize(2.0)
   slider.setLowerLinearLimit(2)
   slider.setUpperLinearLimit(6)
   slider.setLowerAngularLimit(-90)
   slider.setUpperAngularLimit(-85)
   self.world.attachConstraint(slider)
开发者ID:MarcusKhoo,项目名称:RonnieRacer,代码行数:84,代码来源:RonnieRacer.py


注:本文中的panda3d.bullet.BulletRigidBodyNode.setRestitution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。