本文整理汇总了Python中panda3d.bullet.BulletRigidBodyNode.setCcdSweptSphereRadius方法的典型用法代码示例。如果您正苦于以下问题:Python BulletRigidBodyNode.setCcdSweptSphereRadius方法的具体用法?Python BulletRigidBodyNode.setCcdSweptSphereRadius怎么用?Python BulletRigidBodyNode.setCcdSweptSphereRadius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.bullet.BulletRigidBodyNode
的用法示例。
在下文中一共展示了BulletRigidBodyNode.setCcdSweptSphereRadius方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DynamicNp
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class DynamicNp(DynamicObject):
def __init__(self, name, model, game, pos):
self.name = name
self.game = game
self.model = model
self.geomNode = self.model.node()
self.geom = self.geomNode.getGeom(0)
# with triangle mesh it crashes
#mesh = BulletTriangleMesh()
#mesh.addGeom(self.geom)
#self.shape = BulletTriangleMeshShape(mesh, dynamic=True)
# with convex hull
self.shape = BulletConvexHullShape()
self.shape.addGeom(self.geom)
self.node = BulletRigidBodyNode(self.name)
self.node.setMass(10.0)
self.node.addShape(self.shape)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
self.model.reparentTo(self.np)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
self.slice_able = True
示例2: DynamicPlatform
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class DynamicPlatform(DynamicObject):
def __init__(self, name, game, x, y, z, pos):
self.name = name
self.game = game
self.shape = BulletBoxShape(Vec3(x, y, z))
self.node = BulletRigidBodyNode(self.name)
self.node.addShape(self.shape)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
#self.model = self.game.loader.loadModel("models/crate.egg")
#self.model.reparentTo(self.np)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
#self.node.setFriction(5)
#self.debugOff()
self.speedVec = Vec3(0,0,0)
self.lastPos = Vec3(self.getPos())
self.slice_able = False
#self.node.setCcdMotionThreshold(1e-7)
#self.node.setCcdSweptSphereRadius(0.5)
def update(self, dt):
return
示例3: DynamicModel
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class DynamicModel(DynamicObject):
def __init__(self, name, modelPath, game, pos):
self.name = name
self.modelPath = modelPath
self.game = game
self.model = self.game.loader.loadModel(self.modelPath)
geomNodes = self.model.findAllMatches('**/+GeomNode')
self.geomNode = geomNodes.getPath(0).node()
self.geom = self.geomNode.getGeom(0)
self.shape = BulletConvexHullShape()
self.shape.addGeom(self.geom)
self.node = BulletRigidBodyNode(self.name)
self.node.setMass(10.0)
self.node.addShape(self.shape)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
self.model.reparentTo(self.np)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
self.slice_able = True
示例4: DynamicBox
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class DynamicBox(DynamicObject):
def __init__(self, name, game, pos):
self.name = name
self.game = game
self.shape = BulletBoxShape(Vec3(0.5, 0.5, 0.5))
self.node = BulletRigidBodyNode(name)
self.node.setMass(10.0)
self.node.addShape(self.shape)
self.setFriction(20)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
self.model = self.game.loader.loadModel("models/crate.egg")
self.model.reparentTo(self.np)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
self.debugOff()
self.slice_able = True
def update(self, dt):
#self.activate()
#if self.node.isActive():
# return
contact = self.checkFeet()
contacts = self.getContacts()
if contact in self.game.objects and contact in contacts:
obj = self.game.objects[contact]
if type(obj) is KinematicPlatform:
self.activate()
self.setAngularVelocity(self.getAngularVelocity()*0.9)
self.setFriction(0.1)
#print "%s is a box sliding on %s" % (self.name, obj.name)
#self.addSpeedVec(self.game.objects[contact].getSpeedVec())
#self.setForce(obj.getSpeedVec()*self.node.getMass() * 100)
platform_speed = obj.getSpeedVec()
force = platform_speed * self.node.getMass() * 50
#self.setSpeedXY(platform_speed[0], platform_speed[1])
self.setSpeedVec(platform_speed)
#self.setAngularVelocity(0)
#self.node.addLin(obj.getSpeedVec()*self.node.getMass() * 100)
#self.node.applyCentralForce(force)
#self.setForce(force)
#self.setFriction(20)
#self.setPos(self.getPos() + obj.getSpeedVec())
#self.node.setActive(False)
else:
self.setFriction(20)
示例5: KinematicPlatform
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class KinematicPlatform(BulletObject):
def __init__(self, name, game, x, y, z, pos):
self.name = name
self.game = game
self.shape = BulletBoxShape(Vec3(x, y, z))
self.node = BulletRigidBodyNode(self.name)
self.node.addShape(self.shape)
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(pos)
self.game.world.attachRigidBody(self.node)
self.model = self.game.loader.loadModel("models/platform.egg")
self.model.reparentTo(self.np)
self.model.setScale(x*2,y*2,z*2)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
#self.node.setFriction(5)
#self.debugOff()
self.speedVec = Vec3(0,0,0)
self.lastPos = Vec3(self.getPos())
self.slice_able = False
def getSpeedVec(self):
return self.speedVec
def update(self, dt):
currentPos = Vec3(self.getPos())
currentPos.setZ(0)
dVec = currentPos - self.lastPos
self.speedVec = dVec * (1.0 / dt)
#print "speedVec = %s, currentPos = %s, lastPos = %s, dVec = %s" % (self.speedVec, currentPos, self.lastPos, dVec)
self.lastPos = currentPos
self.lastPos.setZ(0)
示例6: Flame
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [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()
示例7: CharacterController
# 需要导入模块: from panda3d.bullet import BulletRigidBodyNode [as 别名]
# 或者: from panda3d.bullet.BulletRigidBodyNode import setCcdSweptSphereRadius [as 别名]
class CharacterController(DynamicObject, FSM):
def __init__(self, game):
self.game = game
FSM.__init__(self, "Player")
# key states
# dx direction left or right, dy direction forward or backward
self.kh = self.game.kh
self.dx = 0
self.dy = 0
self.jumping = 0
self.crouching = 0
# maximum speed when only walking
self.groundSpeed = 5.0
# acceleration used when walking to rise to self.groundSpeed
self.groundAccel = 100.0
# maximum speed in the air (air friction)
self.airSpeed = 30.0
# player movement control when in the air
self.airAccel = 10.0
# horizontal speed on jump start
self.jumpSpeed = 5.5
self.turnSpeed = 5
self.moveSpeedVec = Vec3(0,0,0)
self.platformSpeedVec = Vec3(0,0,0)
h = 1.75
w = 0.4
self.shape = BulletCapsuleShape(w, h - 2 * w, ZUp)
self.node = BulletRigidBodyNode('Player')
self.node.setMass(2)
self.node.addShape(self.shape)
self.node.setActive(True, True)
self.node.setDeactivationEnabled(False, True)
self.node.setFriction(200)
#self.node.setGravity(10)
#self.node.setFallSpeed(200)
self.node.setCcdMotionThreshold(1e-7)
self.node.setCcdSweptSphereRadius(0.5)
self.node.setAngularFactor(Vec3(0,0,1))
self.np = self.game.render.attachNewNode(self.node)
self.np.setPos(0, 0, 0)
self.np.setH(0)
#self.np.setCollideMask(BitMask32.allOn())
self.game.world.attachRigidBody(self.node)
self.playerModel = None
self.slice_able = False
def setActor(self, modelPath, animDic={}, flip = False, pos = (0,0,0), scale = 1.0):
self.playerModel = Actor(modelPath, animDic)
self.playerModel.reparentTo(self.np)
self.playerModel.setScale(scale) # 1ft = 0.3048m
if flip:
self.playerModel.setH(180)
self.playerModel.setPos(pos)
self.playerModel.setScale(scale)
#-------------------------------------------------------------------
# Speed
def getSpeedVec(self):
return self.node.getLinearVelocity()
def setSpeedVec(self, speedVec):
#print "setting speed to %s" % (speedVec)
self.node.setLinearVelocity(speedVec)
return speedVec
def setPlatformSpeed(self, speedVec):
self.platformSpeedVec = speedVec
def getSpeed(self):
return self.getSpeedVec().length()
def setSpeed(self, speed):
speedVec = self.getSpeedVec()
speedVec.normalize()
self.setSpeedVec(speedVec*speed)
def getLocalSpeedVec(self):
return self.np.getRelativeVector(self.getSpeed())
def getSpeedXY(self):
vec = self.getSpeedVec()
return Vec3(vec[0], vec[1], 0)
def setSpeedXY(self, speedX, speedY):
vec = self.getSpeedVec()
z = self.getSpeedZ()
self.setSpeedVec(Vec3(speedX, speedY, z))
def getSpeedH(self):
return self.getSpeedXY().length()
#.........这里部分代码省略.........