本文整理汇总了Python中panda3d.core.CollisionSphere类的典型用法代码示例。如果您正苦于以下问题:Python CollisionSphere类的具体用法?Python CollisionSphere怎么用?Python CollisionSphere使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CollisionSphere类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: announceGenerate
def announceGenerate(self):
DistributedNode.announceGenerate(self)
self.kart = loader.loadModel('phase_6/models/karting/Kart3_Final.bam')
self.kart.find('**/decals').removeNode()
self.kart.reparentTo(self)
self.pod = loader.loadModel('phase_4/models/minigames/pods_truck.egg')
self.pod.reparentTo(self)
self.pod.setScale(0.2)
self.pod.setY(8.5)
self.pod.setH(180)
self.rope = Rope()
self.rope.ropeNode.setUseVertexColor(1)
self.rope.setup(3, ({'node': self.kart,
'point': (0, 1.5, 0.7),
'color': (0, 0, 0, 1),
'thickness': 1000}, {'node': self.kart,
'point': (0, 1.5, 0.7),
'color': (0, 0, 0, 1),
'thickness': 1000}, {'node': self.pod,
'point': (0, 31, 5),
'color': (0, 0, 0, 1),
'thickness': 1000}), [])
self.rope.setH(180)
self.rope.reparentTo(self)
sphere = CollisionSphere(0, 0, 0, 2)
sphere.setTangible(0)
node = CollisionNode(self.uniqueName('truck_trigger'))
node.addSolid(sphere)
node.setCollideMask(CIGlobals.WallBitmask)
self.triggerNP = self.attachNewNode(node)
self.triggerNP.setPos(0, 8.0, 2.0)
self.setScale(2.0)
self.accept('enter' + self.triggerNP.node().getName(), self.__handleTruckTrigger)
示例2: doAttack
def doAttack(self, particlePaths, track_name, particleCollId, animation_name, delayUntilRelease, animationSpeed = 1, handObjPath = None, handObjParent = None, startRightAway = True, ts = 0):
for path in particlePaths:
particle = ParticleLoader.loadParticleEffect(path)
self.particles.append(particle)
sphere = CollisionSphere(0, 0, 0, 1)
sphere.setTangible(0)
node = CollisionNode(particleCollId)
node.addSolid(sphere)
node.setCollideMask(CIGlobals.WallBitmask)
self.targetX = self.attacksClass.target.getX(render)
self.targetY = self.attacksClass.target.getY(render)
self.targetZ = self.attacksClass.target.getZ(render)
if len(self.particles) == 1:
self.shootOutCollNP = self.particles[0].attachNewNode(node)
else:
self.shootOutCollNP = self.suit.attachNewNode(node)
if handObjPath and handObjParent:
self.handObj = loader.loadModel(handObjPath)
self.handObj.reparentTo(handObjParent)
self.suit.setPlayRate(animationSpeed, animation_name)
self.suit.play(animation_name)
if hasattr(self.suit, 'uniqueName'):
track_name = self.suit.uniqueName(track_name)
particleCollId = self.suit.uniqueName(particleCollId)
self.suitTrack = Sequence(name=track_name)
self.suitTrack.append(Wait(delayUntilRelease))
self.suitTrack.append(Func(self.releaseAttack))
self.suitTrack.append(Wait(self.particleIvalDur))
self.suitTrack.setDoneEvent(self.suitTrack.getName())
self.acceptOnce(self.suitTrack.getDoneEvent(), self.finishedAttack)
if startRightAway:
self.suitTrack.start(ts)
示例3: setupCollisions
def setupCollisions(self):
sphere = CollisionSphere(0, 0, 0, 2)
sphere.setTangible(0)
node = CollisionNode(self.collisionName)
node.addSolid(sphere)
node.setCollideMask(CIGlobals.WallBitmask)
self.collisionNode = self.attachNewNode(node)
示例4: loadAttack
def loadAttack(self):
self.phone = loader.loadModel('phase_3.5/models/props/phone.bam')
self.phone.setHpr(0, 0, 180)
if self.suit.type == 'B':
self.phone.setPos(0.7, 0.15, 0)
elif self.suit.type == 'C':
self.phone.setPos(0.25, 0, 0)
self.receiver = loader.loadModel('phase_3.5/models/props/receiver.bam')
self.receiver.reparentTo(self.phone)
self.cord = Rope()
self.cord.ropeNode.setUseVertexColor(1)
self.cord.ropeNode.setUseVertexThickness(1)
self.cord.setup(3, ({'node': self.phone,
'point': (0.8, 0, 0.2),
'color': (0, 0, 0, 1),
'thickness': 1000}, {'node': self.phone,
'point': (2, 0, 0),
'color': (0, 0, 0, 1),
'thickness': 1000}, {'node': self.receiver,
'point': (1.1, 0.25, 0.5),
'color': (0, 0, 0, 1),
'thickness': 1000}), [])
self.cord.setH(180)
self.phoneSfx = base.audio3d.loadSfx('phase_3.5/audio/sfx/SA_hangup.mp3')
base.audio3d.attachSoundToObject(self.phoneSfx, self.phone)
self.hangupSfx = base.audio3d.loadSfx('phase_3.5/audio/sfx/SA_hangup_place_down.mp3')
base.audio3d.attachSoundToObject(self.hangupSfx, self.phone)
collSphere = CollisionSphere(0, 0, 0, 2)
collSphere.setTangible(0)
collNode = CollisionNode('phone_shootout')
collNode.addSolid(collSphere)
collNode.setCollideMask(CIGlobals.WallBitmask)
self.collNP = self.phone.attachNewNode(collNode)
示例5: initChests
def initChests(self):
objects = self.level.findAllMatches('**/Box_long_looseLid')
boxAnimNode = loader.loadModel("Box_long_looseLid-open.egg")
boxAnim = boxAnimNode.find("+AnimBundleNode").node().getBundle()
self.boxControls = {}
i = 0
for object in objects:
bundle = object.node().getBundle(0)
control = bundle.bindAnim(boxAnim, ~0)
boxsphere = CollisionSphere(0, 0, 0, 1.0)
boxsphere.setTangible(False)
boxColNP = object.getParent().attachNewNode(CollisionNode('boxActivation%d'%i))
boxColNP.node().addSolid(boxsphere)
#boxColNP.show()
self.boxControls.setdefault(object.getParent(), [control, boxColNP])
boxName = object.getParent().getParent().getName()
self.accept("playerCollision-in-boxActivation%d"%i,
self.__setActivateElement,
extraArgs=[True, boxName, "box"])
self.accept("playerCollision-out-boxActivation%d"%i,
self.__setActivateElement,
extraArgs=[False, boxName, "box"])
i+=1
示例6: initSwitches
def initSwitches(self):
# Find switch armatures
objects = self.level.findAllMatches('**/Switch')
# Load switch anim
switchAnimNode = loader.loadModel("Switch-Activate.egg")
switchAnim = switchAnimNode.find("+AnimBundleNode").node().getBundle()
self.switchControls = {}
i = 0
for object in objects:
bundle = object.node().getBundle(0)
control = bundle.bindAnim(switchAnim, ~0)
switchsphere = CollisionSphere(0, 0, 0, 0.5)
switchsphere.setTangible(False)
switchColNP = object.getParent().attachNewNode(CollisionNode('switchActivation%d'%i))
switchColNP.node().addSolid(switchsphere)
self.switchControls.setdefault(object.getParent(), [control, switchColNP])
switchName = object.getParent().getParent().getName()
self.accept("playerCollision-in-switchActivation%d"%i,
self.__setActivateElement,
extraArgs=[True, switchName, "switch"])
self.accept("playerCollision-out-switchActivation%d"%i,
self.__setActivateElement,
extraArgs=[False, switchName, "switch"])
i+=1
for key, value in self.switchControls.iteritems():
value[0].pose(0)
示例7: load
def load(self):
spawn = random.choice(DGG.SpawnPoints)
base.localAvatar.setPos(spawn)
base.localAvatar.setHpr(0, 0, 0)
self.soundPickUpBarrel = base.loadSfx("phase_6/audio/sfx/SZ_MM_gliss.mp3")
self.soundDropOff = base.loadSfx("phase_4/audio/sfx/MG_sfx_travel_game_bell_for_trolley.mp3")
self.setMinigameMusic("phase_4/audio/bgm/MG_Delivery.mp3")
self.setDescription(
"A new supply of Gags were just shipped to Toontown! "
+ "Run over to a truck with Gag barrels to take a barrel out. Then, carry it over to the Gag Shop. "
+ "Try to unload and deliver as many barrels as you can to the Gag Shop. "
+ "Watch out for the Cogs - they might try to snatch a barrel!"
)
self.setWinnerPrize(100)
self.setLoserPrize(0)
self.gagShop = loader.loadModel("phase_4/models/modules/gagShop_TT.bam")
self.gagShop.reparentTo(base.render)
self.gagShop.setY(-70)
sphere = CollisionSphere(0, 0, 0, 3)
sphere.setTangible(0)
node = CollisionNode("MGDeliveryGagShop")
node.addSolid(sphere)
self.gagShopCollNP = self.gagShop.attachNewNode(node)
self.world = loader.loadModel("phase_4/models/minigames/delivery_area.egg")
self.world.setY(-5)
self.world.reparentTo(base.render)
self.sky = loader.loadModel("phase_3.5/models/props/TT_sky.bam")
self.sky.reparentTo(base.camera)
ce = CompassEffect.make(NodePath(), CompassEffect.PRot | CompassEffect.PZ)
self.sky.node().setEffect(ce)
self.sky.setZ(-20)
self.skyUtil.startSky(self.sky)
base.camera.setPos(20, 50, 30)
base.camera.lookAt(20, 0, 7.5)
DistributedMinigame.load(self)
示例8: __setupCollisions
def __setupCollisions(self):
sphere = CollisionSphere(0, 0, 0, 4)
sphere.setTangible(0)
collisionNode = CollisionNode(self.uniqueName('NPCToonSphere'))
collisionNode.addSolid(sphere)
collisionNode.setCollideMask(CIGlobals.WallBitmask)
self.collisionNodePath = self.attachNewNode(collisionNode)
self.collisionNodePath.setY(1.5)
示例9: getSprayTrack
def getSprayTrack(self, origin, target, scaleUp, hold, scaleDown, horizScale = 1.0, vertScale = 1.0):
base.localAvatar.stop(self.toonAnim)
self.lastFrame = self.avatar.getCurrentFrame(self.toonAnim)
track = Sequence()
sprayProp = loader.loadModel(GagGlobals.SPRAY_MDL)
sprayProp.setTwoSided(1)
sprayScale = hidden.attachNewNode('spray-parent')
sprayRot = hidden.attachNewNode('spray-rotate')
sprayRot.setColor(GagGlobals.WATER_SPRAY_COLOR)
sprayRot.setTransparency(1)
collNode = CollisionNode('Collision')
spraySphere = CollisionSphere(0, 0, 0, 1)
spraySphere.setTangible(0)
collNode.addSolid(spraySphere)
collNode.setCollideMask(CIGlobals.WallBitmask)
sprayNP = sprayRot.attachNewNode(collNode)
sprayNP.setY(1)
self.sprayNP = sprayNP
event = CollisionHandlerEvent()
event.set_in_pattern('%fn-into')
event.set_out_pattern('%fn-out')
base.cTrav.add_collider(sprayNP, event)
self.avatar.acceptOnce(sprayNP.node().getName() + '-into', self.onCollision)
def showSpray(sprayScale, sprayProp, origin, target):
objects = [sprayRot, sprayScale, sprayProp]
for item in objects:
index = objects.index(item)
if index == 0:
item.reparentTo(self.sprayJoint)
item.setPos(self.sprayJoint.getPos(render))
item.setHpr(self.sprayJoint.getHpr(render))
item.setP(0)
else:
item.reparentTo(objects[index - 1])
item.clearMat()
track.append(Func(showSpray, sprayScale, sprayProp, origin, target))
self.spray = sprayRot
def calcTargetScale():
distance = Vec3(target - origin).length()
yScale = distance / GagGlobals.SPRAY_LEN
targetScale = Point3(yScale * horizScale, yScale, yScale * vertScale)
return targetScale
track.append(Parallel(LerpScaleInterval(sprayScale, scaleUp, calcTargetScale, startScale=GagGlobals.PNT3NEAR0), sprayNP.posInterval(0.25, self.spray.getPos(render) + Point3(0, 50, 0), startPos=self.spray.getPos(render) + Point3(0, 5, 0))))
track.append(Wait(hold))
track.append(Func(self.handleMiss))
track.append(LerpScaleInterval(sprayScale, 0.75, GagGlobals.PNT3NEAR0))
def hideSpray():
(lambda prop: prop.removeNode(), [sprayProp, sprayRot, sprayScale])
track.append(Func(hideSpray))
track.append(Func(self.completeSquirt))
return track
示例10: __initializeEventSphere
def __initializeEventSphere(self):
sphere = CollisionSphere(0, 0, 0, 2)
sphere.setTangible(0)
node = CollisionNode(self.uniqueName('DEagleSuit-eventSphere'))
node.addSolid(sphere)
node.setCollideMask(CIGlobals.WallBitmask)
np = self.attachNewNode(node)
np.setSz(2.5)
np.setZ(5.5)
self.eventSphereNodePath = np
示例11: __initCollisions
def __initCollisions(self, name):
self.notify.debug("Initializing collision sphere...")
ss = CollisionSphere(0, 0, 0, 5)
ss.setTangible(0)
snode = CollisionNode(name)
snode.add_solid(ss)
snode.set_collide_mask(CIGlobals.WallBitmask)
self.snp = self.attach_new_node(snode)
self.snp.setZ(3)
self.acceptOnce("enter" + self.snp.node().getName(), self.__handleEnterCollisionSphere)
示例12: __initShopCollisions
def __initShopCollisions(self, colName):
self.notify.debug('Setting up shop collisions')
shopSphere = CollisionSphere(0, 0, 0, 5)
shopSphere.setTangible(0)
shopNode = CollisionNode(colName)
shopNode.addSolid(shopSphere)
shopNode.setCollideMask(CIGlobals.WallBitmask)
self.shopNP = self.attachNewNode(shopNode)
self.shopNP.setZ(3)
self.acceptOnce('enter' + self.shopNP.node().getName(), self.__handleShopCollision)
示例13: setupHeadSphere
def setupHeadSphere(self, avatarNodePath):
collSphere = CollisionSphere(0, 0, 0, 1)
collSphere.setTangible(1)
collNode = CollisionNode('Flyer.cHeadCollSphere')
collNode.setFromCollideMask(ToontownGlobals.CeilingBitmask)
collNode.setIntoCollideMask(BitMask32.allOff())
collNode.addSolid(collSphere)
self.cHeadSphereNodePath = avatarNodePath.attachNewNode(collNode)
self.cHeadSphereNodePath.setZ(base.localAvatar.getHeight() + 1.0)
self.headCollisionEvent = CollisionHandlerEvent()
self.headCollisionEvent.addInPattern('%fn-enter-%in')
self.headCollisionEvent.addOutPattern('%fn-exit-%in')
base.cTrav.addCollider(self.cHeadSphereNodePath, self.headCollisionEvent)
示例14: setupEventSphere
def setupEventSphere(self, bitmask, avatarRadius):
self.avatarRadius = avatarRadius
cSphere = CollisionSphere(0.0, 0.0, self.avatarRadius + 0.75, self.avatarRadius * 1.04)
cSphere.setTangible(0)
cSphereNode = CollisionNode('Flyer.cEventSphereNode')
cSphereNode.addSolid(cSphere)
cSphereNodePath = self.avatarNodePath.attachNewNode(cSphereNode)
cSphereNode.setFromCollideMask(bitmask)
cSphereNode.setIntoCollideMask(BitMask32.allOff())
self.event = CollisionHandlerEvent()
self.event.addInPattern('enter%in')
self.event.addOutPattern('exit%in')
self.cEventSphereNodePath = cSphereNodePath
示例15: buildProjCollisions
def buildProjCollisions(self):
gagSph = CollisionSphere(0, 0, 0, 1)
gagSph.setTangible(0)
gagNode = CollisionNode('projSensor')
gagNode.addSolid(gagSph)
gagNP = self.gag.attach_new_node(gagNode)
gagNP.setScale(0.75, 0.8, 0.75)
gagNP.setPos(0.0, 0.1, 0.5)
gagNP.setCollideMask(BitMask32.bit(0))
gagNP.node().setFromCollideMask(CIGlobals.FloorBitmask)
event = CollisionHandlerEvent()
event.set_in_pattern('%fn-into')
event.set_out_pattern('%fn-out')
base.cTrav.addCollider(gagNP, event)