本文整理汇总了Python中direct.particles.ParticleEffect.ParticleEffect.addParticles方法的典型用法代码示例。如果您正苦于以下问题:Python ParticleEffect.addParticles方法的具体用法?Python ParticleEffect.addParticles怎么用?Python ParticleEffect.addParticles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.particles.ParticleEffect.ParticleEffect
的用法示例。
在下文中一共展示了ParticleEffect.addParticles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _start_pfx
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addParticles [as 别名]
def _start_pfx (self, enode, rnode, pos, radius, scale1, scale2,
lifespan, poolsize, amplitude,
texpath, color, alphamode, starttime):
pfx = ParticleEffect()
pfx.setPos(pos)
p0 = make_particles()
p0.setPoolSize(16)
p0.setPoolSize(poolsize)
p0.setBirthRate(starttime or 1e-5)
p0.setLitterSize(poolsize)
p0.setLitterSpread(0)
#p0.setSystemLifespan(1.0)
#p0.setLocalVelocityFlag(1)
#p0.setSystemGrowsOlderFlag(0)
p0.setFactory("PointParticleFactory")
p0.factory.setLifespanBase(lifespan)
p0.factory.setLifespanSpread(0.0)
#p0.factory.setMassBase(1.00)
#p0.factory.setMassSpread(0.00)
#p0.factory.setTerminalVelocityBase(400.0000)
#p0.factory.setTerminalVelocitySpread(0.0000)
p0.setRenderer("SpriteParticleRenderer")
p0.renderer.setAlphaMode(alphamode)
texture = base.load_texture("data", texpath)
p0.renderer.setTexture(texture)
# p0.renderer.setUserAlpha(alpha)
p0.renderer.setColor(color)
p0.renderer.setXScaleFlag(1)
p0.renderer.setYScaleFlag(1)
p0.renderer.setInitialXScale(scale1)
p0.renderer.setFinalXScale(scale2)
p0.renderer.setInitialYScale(scale1)
p0.renderer.setFinalYScale(scale2)
p0.setEmitter("SphereVolumeEmitter")
p0.emitter.setRadius(radius)
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(amplitude)
#p0.emitter.setAmplitudeSpread(0.0)
#p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
#p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
#p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
#f0 = ForceGroup("vertex")
#force0 = LinearVectorForce(Vec3(0.0, 0.0, -amplitude * 2))
#force0.setActive(1)
#f0.addForce(force0)
p0.setRenderParent(rnode)
#pfx.addForceGroup(f0)
pfx.addParticles(p0)
pfx.start(enode)
self._pfxes.append((pfx, lifespan, starttime))
示例2: _make_pfx
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addParticles [as 别名]
def _make_pfx (self, enode, rnode, pos, radius, scale1, scale2,
birthrate, lifespan, zspinini, zspinfin, zspinvel,
poolsize, littersize, amplitude, ampspread, risefact,
texpath, color, alphamode, softstop):
pfx = ParticleEffect()
pfx.setPos(pos)
p0 = make_particles()
p0.setPoolSize(poolsize)
p0.setBirthRate(birthrate)
p0.setLitterSize(littersize)
p0.setLitterSpread(0)
#p0.setSystemLifespan(1.0)
#p0.setLocalVelocityFlag(1)
#p0.setSystemGrowsOlderFlag(0)
# p0.setFactory("PointParticleFactory")
# p0.factory.setLifespanBase(lifespan)
# p0.factory.setLifespanSpread(0.0)
# #p0.factory.setMassBase(1.00)
# #p0.factory.setMassSpread(0.00)
# #p0.factory.setTerminalVelocityBase(400.0000)
# #p0.factory.setTerminalVelocitySpread(0.0000)
p0.setFactory("ZSpinParticleFactory")
p0.factory.setLifespanBase(lifespan)
p0.factory.setLifespanSpread(0.0)
#p0.factory.setMassBase(1.00)
#p0.factory.setMassSpread(0.00)
#p0.factory.setTerminalVelocityBase(400.0000)
#p0.factory.setTerminalVelocitySpread(0.0000)
p0.factory.setAngularVelocity(zspinvel)
p0.factory.setFinalAngle(zspinfin)
p0.factory.setInitialAngle(zspinini)
p0.setRenderer("SpriteParticleRenderer")
p0.renderer.setAlphaMode(alphamode)
texpaths = texpath
if not isinstance(texpath, (tuple, list)):
texpaths = [texpaths]
for texpath in texpaths:
texture = base.load_texture("data", texpath)
p0.renderer.addTexture(texture)
# p0.renderer.setUserAlpha(alpha)
p0.renderer.setColor(color)
p0.renderer.setXScaleFlag(1)
p0.renderer.setYScaleFlag(1)
p0.renderer.setAnimAngleFlag(1)
p0.renderer.setInitialXScale(scale1)
p0.renderer.setFinalXScale(scale2)
p0.renderer.setInitialYScale(scale1)
p0.renderer.setFinalYScale(scale2)
p0.setEmitter("SphereVolumeEmitter")
p0.emitter.setRadius(radius)
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(amplitude)
p0.emitter.setAmplitudeSpread(ampspread)
#p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
#p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
#p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
f0 = ForceGroup("vertex")
force0 = LinearVectorForce(risefact * amplitude)
force0.setActive(1)
f0.addForce(force0)
p0.setRenderParent(rnode)
pfx.addForceGroup(f0)
pfx.addParticles(p0)
pfx.start(enode)
if softstop:
pfx.softStop()
return pfx
示例3: Lvl03
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addParticles [as 别名]
#.........这里部分代码省略.........
# Factory parameters
p0.factory.setLifespanBase(2.0000)
p0.factory.setLifespanSpread(0.0000)
p0.factory.setMassBase(1.0000)
p0.factory.setMassSpread(0.0000)
p0.factory.setTerminalVelocityBase(400.0000)
p0.factory.setTerminalVelocitySpread(0.0000)
# Point factory parameters
# Renderer parameters
p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
p0.renderer.setUserAlpha(0.22)
# Sprite parameters
p0.renderer.addTextureFromFile('models/gamedev/sparkle.png')
p0.renderer.setColor(Vec4(1.00, 1.00, 1.00, 1.00))
p0.renderer.setXScaleFlag(1)
p0.renderer.setYScaleFlag(1)
p0.renderer.setAnimAngleFlag(0)
p0.renderer.setInitialXScale(0.5000)
p0.renderer.setFinalXScale(2.0000)
p0.renderer.setInitialYScale(1.0000)
p0.renderer.setFinalYScale(2.0000)
p0.renderer.setNonanimatedTheta(0.0000)
p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPNOBLEND)
p0.renderer.setAlphaDisable(0)
# Emitter parameters
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(1.0000)
p0.emitter.setAmplitudeSpread(0.0000)
p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 3.0000))
p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
# Disc parameters
p0.emitter.setRadius(0.5000)
self.fire.addParticles(p0)
self.fire.setPos(self.playerModel2.getPos())
t = Sequence(Func(self.fire.start, render, render),Wait(20),Func(self.cleanFire))
t.start()
def cleanFire(self):
self.fire.cleanup()
def explode(self,cEntry):
self.explosion = ParticleEffect()
self.explosion.reset()
self.explosion.setPos(cEntry.getIntoNodePath().getParent().getPos())
self.explosion.setHpr(0.000, 0.000, 0.000)
self.explosion.setScale(10.000, 10.000, 10.000)
p0 = Particles('particles-1')
# Particles parameters
p0.setFactory("PointParticleFactory")
p0.setRenderer("LineParticleRenderer")
p0.setEmitter("SphereVolumeEmitter")
p0.setPoolSize(10000)
p0.setBirthRate(0.0500)
p0.setLitterSize(10000)
p0.setLitterSpread(0)
p0.setSystemLifespan(2.0000)
p0.setLocalVelocityFlag(1)
p0.setSystemGrowsOlderFlag(1)
# Factory parameters
p0.factory.setLifespanBase(2.0000)
p0.factory.setLifespanSpread(0.0000)
示例4: Enemy
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addParticles [as 别名]
#.........这里部分代码省略.........
diff = angle - hpr.x
if diff > 180.0:
diff = diff - 360
if diff < -180.0:
diff = diff + 360
if diff > 5.0:
diff = 5.0
if diff < -5.0:
diff = -5.0
new = Vec3(diff, 0, 0) + hpr
#self.np.setHpr(new)
# move forward
r = radians(new.x)
curr = self.np.getPos()
diff = Vec3(self.movespeed * cos(r), self.movespeed * sin(r), 0)
self.np.setPos(curr + diff)"""
if self.hp < 0.0 and self.dead == 0.0:
self.dead = time
self.app.scene.remove(self)
# Create particle effect before we go
self.dnp.setPos(self.np.getPos())
self.particles.start(parent = self.dnp, renderParent = self.app.render)
self.np.detachNode()
# Drop some loot
self.app.item_manager.add_item(self.np.getPos(), "soul", self.level)
# Give the player some points
self.app.player.score = self.app.player.score + 100
def apply_effect(self, target, timer):
if self.last_activated - timer + self.activate_delay < 0.0:
self.last_activated = timer
target.hp = target.hp - self.damage
if target.np.getName()[0] == 't':
target.pursuers.append(self)
#self.ai_b = self.ai_char.getAiBehaviors()
#self.ai_b.pursue(self.np.getPos())
self.ai_b.pauseAi("pursue")
def load_particle_config(self):
self.particles = ParticleEffect()
self.particles.reset()
self.particles.setPos(0.000, 0.000, 0.000)
self.particles.setHpr(0.000, 0.000, 0.000)
self.particles.setScale(1.000, 1.000, 1.000)
p0 = Particles('particles-1')
# Particles parameters
p0.setFactory("PointParticleFactory")
p0.setRenderer("SpriteParticleRenderer")
p0.setEmitter("SphereVolumeEmitter")
p0.setPoolSize(20)
p0.setBirthRate(0.0100)
p0.setLitterSize(20)
p0.setLitterSpread(0)
p0.setSystemLifespan(1.0100)
p0.setLocalVelocityFlag(1)
p0.setSystemGrowsOlderFlag(1)
# Factory parameters
p0.factory.setLifespanBase(1.0000)
p0.factory.setLifespanSpread(0.0000)
p0.factory.setMassBase(1.0000)
p0.factory.setMassSpread(0.0100)
p0.factory.setTerminalVelocityBase(1200.0000)
p0.factory.setTerminalVelocitySpread(0.0000)
# Point factory parameters
# Renderer parameters
p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
p0.renderer.setUserAlpha(0.05)
# Sprite parameters
p0.renderer.setTexture(self.app.loader.loadTexture('effects/dust.png'))
p0.renderer.setColor(Vec4(1.00, 0.10, 0.10, 0.50))
p0.renderer.setXScaleFlag(2)
p0.renderer.setYScaleFlag(2)
p0.renderer.setAnimAngleFlag(0)
p0.renderer.setInitialXScale(0.100 * self.level)
p0.renderer.setFinalXScale(0.200 * self.level)
p0.renderer.setInitialYScale(0.100 * self.level)
p0.renderer.setFinalYScale(0.200 * self.level)
p0.renderer.setNonanimatedTheta(0.0000)
p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPBLENDLINEAR)
p0.renderer.setAlphaDisable(0)
# Emitter parameters
p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
p0.emitter.setAmplitude(1.0000)
p0.emitter.setAmplitudeSpread(0.0000)
p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
# Sphere Volume parameters
p0.emitter.setRadius(0.1000)
self.particles.addParticles(p0)
f0 = ForceGroup('gravity')
# Force parameters
self.particles.addForceGroup(f0)
示例5: ParticleSystemWrapper
# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addParticles [as 别名]
class ParticleSystemWrapper(VirtualNodeWrapper):
className = 'ParticleSystem'
def onCreateInstance(self, parent, filepath):
# create instance of this class
objectInstance = super(VirtualNodeWrapper, self).onCreateInstance(parent, "ParticleSystem")
objectInstance.setParticleConfig(filepath)
#objectInstance.setTransparency(True)
return objectInstance
onCreateInstance = classmethod(onCreateInstance)
def __init__( self, parent=None, name=None ):
global PARTICLES_ENABLED
if not PARTICLES_ENABLED:
base.enableParticles()
PARTICLES_ENABLED = True
# define the name of this object
VirtualNodeWrapper.__init__(self, parent, name, PARTICLE_WRAPPER_DUMMYOBJECT)
self.particleSystem = ParticleEffect()
def setParticleConfig(self, filepath):
if filepath is not None:
# check if model file is in pandaModelPath
filepath = str(Filename.fromOsSpecific(filepath))
# add the model path to the panda-path
pandaPath = None
from pandac.PandaModules import getModelPath
for searchPath in str(getModelPath()).split():
if searchPath == filepath:
pandaPath = searchPath
if pandaPath is None:
pandaPath = '/'.join(filepath.split('/')[:-1])
from pandac.PandaModules import getModelPath
getModelPath().appendPath( pandaPath )
self.particleFilename = filepath
try:
#Start of the code from steam.ptf
self.particleSystem.loadConfig(Filename(filepath))
self.setFilepath(filepath)
except:
print "W: particleSystemWrapper.setParticleConfig: Error loading file"
print " -", filepath
traceback.print_exc()
print " - Creating dummy particle Effect"
# create new one if loading failed (particlepanel requires at least one particle)
particles = Particles()
particles.setBirthRate(0.02)
particles.setLitterSize(10)
particles.setLitterSpread(0)
particles.setFactory("PointParticleFactory")
particles.setRenderer("PointParticleRenderer")
particles.setEmitter("SphereVolumeEmitter")
particles.enable()
self.particleSystem.addParticles(particles)
self.clearFilepath()
#Sets particles to birth relative to the teapot, but to render at toplevel
self.particleSystem.start(self.getNodepath())
# a bugfix, somewhere must be some color assigned to most nodes, i dont know why
# this looks very bad on particle systems
self.getNodepath().setColorOff(0)
def destroy( self ):
# destroy this object
VirtualNodeWrapper.destroy( self )
def getSaveData(self, relativeTo):
objectInstance = VirtualNodeWrapper.getSaveData(self, relativeTo)
self.setExternalReference(self.particleFilename, relativeTo, objectInstance)
return objectInstance
def loadFromData(self, eggGroup, filepath):
extRefFilename = self.getExternalReference(eggGroup, filepath)
self.setParticleConfig(extRefFilename)
VirtualNodeWrapper.loadFromData(self, eggGroup, filepath)
def duplicate(self, original):
objectInstance = super(ParticleSystemWrapper, self).duplicate(original)
objectInstance.setParticleConfig(original.particleFilename)
return objectInstance
duplicate = classmethod(duplicate)