本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.setGravity方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.setGravity方法的具体用法?Python BulletRigidBodyNode.setGravity怎么用?Python BulletRigidBodyNode.setGravity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.setGravity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Flame
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setGravity [as 别名]
class Flame(Entity):
"""
The thing that comes out the end of the thing you hold
"""
animspeed = 0.1
depth = 20
playerWidth = 3
speed = 20
def __init__(self, world, pos, hpr):
super(Flame, self).__init__()
self.shape = BulletBoxShape(Vec3(0.1,0.05,0.05))
self.bnode = BulletRigidBodyNode()
self.bnode.setMass(1.0)
self.bnode.addShape(self.shape)
self.np = utilities.app.render.attachNewNode(self.bnode)
self.world =world
self.anim = list()
self.anim.append(utilities.loadObject("flame1", depth=0))
self.anim.append(utilities.loadObject("flame2", depth=0))
self.anim.append(utilities.loadObject("flame3", depth=0))
world.bw.attachRigidBody(self.bnode)
self.curspr = 0
self.obj = self.anim[self.curspr]
self.obj.show()
self.livetime = 0
self.delta = 0
self.pos = pos
self.pos.y = Flame.depth
#self.pos.z -= 0.2
self.hpr = hpr
self.vel = Point2()
self.vel.x = cos(world.player.angle)*Flame.speed
self.vel.y = sin(world.player.angle)*Flame.speed
tv = Vec3(self.vel.x, 0, self.vel.y)
# this makes the shot miss the target if the player has any velocity
tv += world.player.bnode.getLinearVelocity()
self.bnode.setLinearVelocity(tv)
tv.normalize()
# initial position of RB and draw plane
self.np.setHpr(hpr)
self.np.setPos(pos+tv/2)
self.bnode.setAngularFactor(Vec3(0,0,0))
self.bnode.setLinearFactor(Vec3(1,0,1))
self.bnode.setGravity(Vec3(0,0,0))
self.bnode.setCcdMotionThreshold(1e-7)
self.bnode.setCcdSweptSphereRadius(0.10)
self.bnode.notifyCollisions(True)
self.bnode.setIntoCollideMask(BitMask32.bit(1))
self.bnode.setPythonTag("Entity", self)
self.noCollideFrames = 4
for a in self.anim:
a.hide()
a.reparentTo(self.np)
a.setScale(0.25, 1, 0.25)
a.setPos(0, -0.1,0)
def update(self, timer):
#animation
self.delta += timer
self.livetime += timer
if self.noCollideFrames == 0:
self.bnode.setIntoCollideMask(BitMask32.allOn())
if self.noCollideFrames > -1:
self.noCollideFrames -= 1
if self.delta > Flame.animspeed:
self.delta = 0
self.obj.hide()
self.curspr += 1
if self.curspr > len(self.anim)-1:
self.curspr = 0
self.obj = self.anim[self.curspr]
self.obj.show()