本文整理汇总了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
示例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)
示例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
示例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)