Пример #1
0
class Explosion:
    def __init__(self, base):
        self.base = base
        self.p = Particles()
        self.p.setFactory("PointParticleFactory")
        self.p.setRenderer("LineParticleRenderer")
        self.p.setEmitter("SphereSurfaceEmitter")
        self.p.setPoolSize(256)
        self.p.setBirthRate(0.01)
        self.p.setLitterSize(256)
        self.p.setSystemLifespan(2)
        self.p.factory.setLifespanBase(5.0000)
        self.p.renderer.setTailColor(Vec4(1.0, 1.0, 0.0, 1.0))
        self.p.renderer.setHeadColor(Vec4(1.0, 0.0, 0.0, 1.0))
        self.p.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
        self.p.renderer.setUserAlpha(1.00)
        self.p.renderer.setLineScaleFactor(32.00)
        self.p.emitter.setRadius(2.0000)
        self.p.setRenderParent(base.render)
        self.p.enable()
        self.pn = base.render.attachNewNode("particleExpNode")
        # self.pn.setDepthWrite(False)
        # self.pn.setBin("fixed", 0)
        self.pe = ParticleEffect("exp-effect", self.p)
        self.pe.reparentTo(self.pn)
        self.pe.enable()
Пример #2
0
    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 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)
Пример #4
0
    def buildMainMenu(self):

        self.toggleCursor(False)

        start_game_button = DirectButton(text="Start", scale=.1, command=None)
        select_level_button = DirectButton(text="Select Level",
                                           scale=.1,
                                           command=None)
        game_options_button = DirectButton(text="Settings",
                                           scale=.1,
                                           command=None)
        exit_button = DirectButton(text="Exit", scale=.1, command=exit)

        BUTTON_SPACING = .2
        BUTTON_HEIGHT = start_game_button.getSy()

        button_positions = self.evenButtonPositions(BUTTON_SPACING,
                                                    BUTTON_HEIGHT, 4)

        start_game_button.setPos(Vec3(0, 0, button_positions[0]))
        select_level_button.setPos(Vec3(0, 0, button_positions[1]))
        game_options_button.setPos(Vec3(0, 0, button_positions[2]))
        exit_button.setPos(Vec3(0, 0, button_positions[3]))

        self.guiElements.append(start_game_button)
        self.guiElements.append(select_level_button)
        self.guiElements.append(game_options_button)
        self.guiElements.append(exit_button)

        particles = Particles()
        particles.setPoolSize(1000)
        particles.setBirthRate(.1)
        particles.setLitterSize(10)
        particles.setLitterSpread(3)
        particles.setFactory("PointParticleFactory")
        particles.setRenderer("PointParticleRenderer")
        particles.setEmitter("SphereVolumeEmitter")
        particles.enable()

        self.effect = ParticleEffect("peffect", particles)
        self.effect.reparentTo(render)
        #self.effect.setPos(self.avatar.objectNP.getX(), self.avatar.objectNP.getY(), self.avatar.objectNP.getZ() + 5)
        self.effect.setPos(-1, 0, 0)
        self.effect.enable()
Пример #5
0
    def __init__(self):
        ShowBase.__init__(self)

        self.enableParticles()

        particles = Particles()
        particles.setPoolSize(1000)
        particles.setBirthRate(0.1)
        particles.setLitterSize(10)
        particles.setLitterSpread(3)
        particles.setFactory("PointParticleFactory")
        particles.setRenderer("GeomParticleRenderer")
        particles.setEmitter("SphereVolumeEmitter")

        smiley = loader.loadModel("smiley")
        smiley.setScale(0.1)
        particles.getRenderer().setGeomNode(smiley.node())
        particles.enable()

        self.effect = ParticleEffect("peffect", particles)
        self.effect.reparentTo(render)
        self.effect.enable()

        self.cam.setPos(0, -10, 0)