本文整理汇总了Python中direct.particles.ParticleEffect.ParticleEffect类的典型用法代码示例。如果您正苦于以下问题:Python ParticleEffect类的具体用法?Python ParticleEffect怎么用?Python ParticleEffect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParticleEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Smoke
def Smoke(self,model):
p1 = ParticleEffect()
p1.cleanup()
p1 = ParticleEffect()
p1.loadConfig(Filename(MYDIRPART+'smoke.ptf'))
p1.start(model)
p1.setPos(3.000, 0.000, 2.250)
示例2: createEffect
def createEffect(values):
p = ParticleEffect()
loadValues(values, p)
color_gradient=loader.loadTexture(values["color_gradient"])
size_gradient=loader.loadTexture(values["size_gradient"])
shape_gradient=loader.loadTexture(values["shape_gradient"])
blend_gradient=loader.loadTexture("data/blend.png", minfilter=Texture.FTNearest, magfilter=Texture.FTNearest)
color_gradient.setWrapU(Texture.WMClamp)
color_gradient.setWrapV(Texture.WMClamp)
size_gradient.setWrapU(Texture.WMClamp)
size_gradient.setWrapV(Texture.WMClamp)
shape_gradient.setWrapU(Texture.WMClamp)
shape_gradient.setWrapV(Texture.WMClamp)
blend_gradient.setWrapU(Texture.WMClamp)
blend_gradient.setWrapV(Texture.WMClamp)
for geom in p.findAllMatches('**/+GeomNode'):
geom.setDepthWrite(False)
geom.setBin("transparent", 31)
#need to hide it from the water and shadow camera now... I don't know hot to get the geom later :(
geom.hide(BitMask32.bit(1))
geom.hide(BitMask32.bit(2))
geom.setShader(Shader.load(Shader.SLGLSL, "shaders/vfx_v.glsl","shaders/vfx_f.glsl"), 1)
geom.setShaderInput('distortion',0.9)
#geom.setShaderInput("fog", Vec4(0.4, 0.4, 0.4, 0.002))
geom.setShaderInput("color_gradient", color_gradient)
geom.setShaderInput("size_gradient", size_gradient)
geom.setShaderInput("shape_gradient", shape_gradient)
geom.setShaderInput("blend_gradient", blend_gradient)
#p.start(parent=self.root, renderParent = render)
return p
示例3: Water
def Water(self,model):
p1 = ParticleEffect()
p1.cleanup()
p1 = ParticleEffect()
p1.loadConfig(Filename(MYDIRPART+'fountain.ptf'))
p1.start(model)
p1.setPos(3.000, 0.000, 2.250)
示例4: SmokeRing
def SmokeRing(self,model):
p1 = ParticleEffect()
p1.cleanup()
p1 = ParticleEffect()
p1.loadConfig(Filename(MYDIRPART+'smokering.ptf'))
p1.start(model)
p1.setPos(0, 0.000, 0)
示例5: Flame
def Flame(self,model):
p1 = ParticleEffect()
p1.cleanup()
p1 = ParticleEffect()
p1.loadConfig(Filename('ee.ptf'))#'fireish.ptf'))
p1.start(model)
p1.setPos(3.000, 0.000, 2.250)
setupLights(self,model)
示例6: init_player
def init_player(self, left_btn, right_btn, player_number ,pos=(0,0,0), heading=0):
color = (configs.COLORS_MAP[player_number][0])
nodePath = loadObject()
nodePath.setPos(pos)
nodePath.setScale(configs.SCALE*0.004)
nodePath.setColor(color)
p = ParticleEffect()
p.loadConfig('textures/flare.ptf')
p.start(parent = nodePath, renderParent = render)
p0 = p.getParticlesList()[0]
p0.emitter.setRadiateOrigin(Point3(0.05*cos(heading* pi/180), 0.0, 0.05*sin(heading* pi/180)))
p.setPos(0,-1,0)
# p.setBin("unsorted", 0)
# p.setDepthTest(False)
p.setTwoSided(True)
text= TextNode('text')
text.setText(str("%s" % player_number))
text.setTextColor(color)
text.setAlign(TextNode.ACenter)
# text.font = self.font
text3d = NodePath(text)
text3d.setTwoSided(True)
text3d.setPos(nodePath, -1,-3,-4)
text3d.reparentTo(render)
circle = loadObject(tex='circle.png')
circle.reparentTo(render)
circle.setPos(nodePath, 0,-2,0)
text3d.setScale(0.13)
circle.setScale(0.09)
text3d.setColorScale(color)
circle.setColorScale(color)
new_line, line_vertex, line_node = start_new_line(self, pos[0], pos[2], color)
line_id = configs.ENTITY_ID
configs.ENTITIES[configs.ENTITY_ID] = {'CATEGORY':'line', 'GEOM':new_line, 'VERTEX':line_vertex, "NODE": line_node}
configs.ENTITY_ID += 1
speed = configs.FORWARD_SPEED
right_angle = configs.FORCE_RIGHT_ANGLE_TURN
# print left_btn
# print right_btn
self.accept(("%s" % left_btn), player_controls, [configs.ENTITY_ID, 'TURN_LEFT', 1])
self.accept(("%s-up" % left_btn), player_controls, [configs.ENTITY_ID, 'TURN_LEFT', 0])
self.accept(("%s" % right_btn), player_controls, [configs.ENTITY_ID, 'TURN_RIGHT', 1])
self.accept(("%s-up" % right_btn), player_controls, [configs.ENTITY_ID, 'TURN_RIGHT', 0])
configs.ENTITIES[configs.ENTITY_ID] = {'CATEGORY':'player','ALIVE':True, 'NODE':nodePath,'PARTICLE_PARENT':p, 'PARTICLE':p0,
'HEADING':heading, 'CURRENT_LINE':line_id, 'TICKNESS':configs.SCALE, 'TURN_LEFT':0, 'TURN_RIGHT':0, 'COLOR':color,
'PLAYER_ID':text3d, 'CIRCLE_NODE':circle, 'LEFT_ARMED':True, 'RIGHT_ARMED':True, 'PLAYER_NUMBER': player_number, 'SPEED':speed,
'RIGHT_ANGLE_TURN':right_angle }
configs.ENTITY_ID += 1
示例7: ParticleDemo
class ParticleDemo(ShowBase):
def __init__(self):
ShowBase.__init__(self)
# Standard title and instruction text
self.title = OnscreenText(
text="Panda3D: Tutorial - Particles",
parent=base.a2dBottomCenter,
style=1, fg=(1, 1, 1, 1), pos=(0, 0.1), scale=.08)
self.escapeEvent = OnscreenText(
text=HELP_TEXT, parent=base.a2dTopLeft,
style=1, fg=(1, 1, 1, 1), pos=(0.06, -0.06),
align=TextNode.ALeft, scale=.05)
# More standard initialization
self.accept('escape', sys.exit)
self.accept('1', self.loadParticleConfig, ['steam.ptf'])
self.accept('2', self.loadParticleConfig, ['dust.ptf'])
self.accept('3', self.loadParticleConfig, ['fountain.ptf'])
self.accept('4', self.loadParticleConfig, ['smoke.ptf'])
self.accept('5', self.loadParticleConfig, ['smokering.ptf'])
self.accept('6', self.loadParticleConfig, ['fireish.ptf'])
self.accept('escape', sys.exit)
base.disableMouse()
base.camera.setPos(0, -20, 2)
base.camLens.setFov(25)
base.setBackgroundColor(0, 0, 0)
# This command is required for Panda to render particles
base.enableParticles()
self.t = loader.loadModel("teapot")
self.t.setPos(0, 10, 0)
self.t.reparentTo(render)
self.setupLights()
self.p = ParticleEffect()
self.loadParticleConfig('steam.ptf')
def loadParticleConfig(self, filename):
# Start of the code from steam.ptf
self.p.cleanup()
self.p = ParticleEffect()
self.p.loadConfig(Filename(filename))
# Sets particles to birth relative to the teapot, but to render at
# toplevel
self.p.start(self.t)
self.p.setPos(3.000, 0.000, 2.250)
# Setup lighting
def setupLights(self):
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor((.4, .4, .35, 1))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(LVector3(0, 8, -2.5))
directionalLight.setColor((0.9, 0.8, 0.9, 1))
# Set lighting on teapot so steam doesn't get affected
self.t.setLight(self.t.attachNewNode(directionalLight))
self.t.setLight(self.t.attachNewNode(ambientLight))
示例8: __init__
def __init__(self, pos, world):
self.id = next(Dorf.idgen)
self.world = world
self.node = loader.loadModel('media/models/dorfPH.egg')
self.text = core.TextNode('dorf')
self.text.setText('Dorf {}'.format(self.id))
self.text.setAlign(core.TextNode.ACenter)
self.text.setTextColor(1, 1, 0.5, 1)
self.text.setShadow(0.1, 0.1)
self.text.setShadowColor(0, 0, 0, 0.8)
self.textnode = self.node.attachNewNode(self.text)
self.textnode.setBillboardPointEye()
self.textnode.setPos(0, 0, 1.1)
self.textnode.setScale(0.4)
self.textnode.setDepthWrite(False)
self.textnode.setDepthTest(False)
self.textnode.setShaderOff()
self.x = int(pos.x)
self.y = int(pos.y)
self.z = 0
self.next = None
self.dir = (1, 0)
taskMgr.doMethodLater(0.5, self.move, 'Move dorf')
self.set_z(int(pos.z))
self.node.setPos(pos.x, pos.y, 0)
self.particles = ParticleEffect()
self.particles.loadConfig('media/sparks.ptf')
self.particles.reparentTo(self.node)
示例9: useThunder
def useThunder(self):
self.onThunder = True
self.pokeCandyCount -= 1
self.thunder = ParticleEffect()
self.thunder.loadConfig("thunder.ptf")
self.thunder.start(parent=render, renderParent=render)
self.use.play()
示例10: addParticle
def addParticle(self, pipe):
#Particle Effect: VERY SLOW
self.particle = ParticleEffect()
self.particle.loadConfig("../models/steam.ptf")
self.particle.start(pipe)
self.particle.setPos(100.00, 0.000, 0)
self.particle.setScale(100.00, 80.00, 80.00)
示例11: load_config
def load_config(self, file_name):
self.p.cleanup()
self.p = ParticleEffect()
self.p.loadConfig(file_name)
self.p.start(render)
self.p.setPos(self.x, self.y, self.z)
self.p.reparentTo(self.parent)
示例12: __init__
def __init__(self):
#Standard title and instruction text
self.title = OnscreenText(
text="Panda3D: Tutorial - Particles",
style=1, fg=(1,1,1,1), pos=(0.8,-0.95), scale = .07)
self.escapeEvent = OnscreenText(
text=HELPTEXT,
style=1, fg=(1,1,1,1), pos=(-1.3, 0.95),
align=TextNode.ALeft, scale = .05)
#More standard initialization
self.accept('escape', sys.exit)
self.accept('1', self.loadParticleConfig , ['steam.ptf'])
self.accept('2', self.loadParticleConfig , ['dust.ptf'])
self.accept('3', self.loadParticleConfig , ['fountain.ptf'])
self.accept('4', self.loadParticleConfig , ['smoke.ptf'])
self.accept('5', self.loadParticleConfig , ['smokering.ptf'])
self.accept('6', self.loadParticleConfig , ['fireish.ptf'])
self.accept('escape', sys.exit)
base.disableMouse()
camera.setPos(0,-20,2)
base.setBackgroundColor( 0, 0, 0 )
#This command is required for Panda to render particles
base.enableParticles()
self.t = loader.loadModel("models/teapot")
self.t.setPos(0,10,0)
self.t.reparentTo(render)
self.setupLights()
self.p = ParticleEffect()
self.loadParticleConfig('steam.ptf')
示例13: __init__
def __init__(self):
#sys.path.append('../game')
#Standard title and instruction text
self.title = OnscreenText(
text="PSG: Test - Explosion",
style=1, fg=(1,1,1,1), pos=(0.9,-0.95), scale = .07)
self.escapeEvent = OnscreenText(
text=HELPTEXT,
style=1, fg=(1,1,1,1), pos=(-1.3, 0.95),
align=TextNode.ALeft, scale = .05)
#More standard initialization
self.accept('escape', sys.exit)
self.accept('1', self.loadParticleConfig , ['explosion1.ptf'])
self.accept('2', self.loadParticleConfig , ['explosion2.ptf'])
self.accept('3', self.loadParticleConfig , ['explosion3.ptf'])
self.accept('4', self.loadParticleConfig , ['explosion4.ptf'])
self.accept('5', self.loadParticleConfig , ['explosion5.ptf'])
self.accept('6', self.loadParticleConfig , ['explosion6.ptf'])
self.accept('escape', sys.exit)
base.disableMouse()
camera.setPos(0,-20,2)
base.setBackgroundColor( 0, 0, 0 )
#This command is required for Panda to render particles
base.enableParticles()
self.t = loader.loadModel("../data/models/ship_03.egg")
self.t.setScale(0.5)
self.t.setHpr(180, 0, 0)
self.t.setPos(0,10,0)
self.t.reparentTo(render)
self.setupLights()
self.p = ParticleEffect()
self.loadParticleConfig('explosion1.ptf')
示例14: __init__
def __init__(self, main, username, pos = LVecBase3(-5, -5, 1), isCurrentPlayer = False, carId=3):
self.username = username
self.main = main
self.isCurrentPlayer = isCurrentPlayer
self.boostCount = 0
self.boostActive = False
self.boostStep = 2
self.boostDuration = 0
self.moveStartTime = self.startTime = self.boostStartTime = time.time()
self.pos = pos
self.boostFactor = 1.2
self.specs = {"mass": 800.0,
"maxWheelForce": 2000.0,
"brakeForce": 100.0,
"steeringLock": 45.0,
"maxSpeed": 33.0,
"maxReverseSpeed": 10.0}
self.vehicleControlState = {"throttle": 0, "reverse": False, "brake": 0.0, "steering": 0.0, "health": 1}
# Steering change per second, normalised to steering lock
# Eg. 45 degrees lock and 1.0 rate means 45 degrees per second
self.steeringRate = 0.8
self.centreingRate = 1.2
self.speed = 0
self.setupVehicle(main)
self.props = VehicleProps(carId)
self.currentPowerups = {"powerup1": None, "powerup2": None, "powerup3": None}
if isCurrentPlayer:
#This command is required for Panda to render particles
base.enableParticles()
self.p = ParticleEffect()
示例15: drain
def drain(self, task):
if self.draining and task.time - self.drainTime > DRAIN_DELAY:
carpos = self.staticCars[self.target].getPos()
playerpos = self.player.getPos()
dist = math.sqrt( (carpos[0] - playerpos[0])**2 + (carpos[1] - playerpos[1])**2 + (carpos[2] - playerpos[2])**2 )
if self.gasList[self.target] > 0 and dist < DRAIN_DIST:
if not self.gasPlaying:
self.gasP.reset()
self.gasP = ParticleEffect()
self.gasP.loadConfig(Filename('oil.ptf'))
self.gasP.start(self.player)
self.gasNode.lookAt(self.staticCars[self.target])
self.gasP.setPos(0,0,2)
self.gasP.setScale(1.5)
self.gasP.setLightOff()
self.gasPlaying = True
self.alan_var = False
self.gasNode.lookAt(self.staticCars[self.target])
self.gasP.setHpr(self.gasNode.getH() + 180, 90, 0)
self.player.totalGas = self.player.totalGas + 1
self.gasList[self.target] = self.gasList[self.target] - 1
else:
self.alan_var = True
# print "TotalGas: " + str(self.player.totalGas)
self.drainTime = task.time
elif not self.draining or self.alan_var:
self.gasP.softStop()
self.drainSound.stop()
self.gasPlaying = False
return Task.cont