Exemplo n.º 1
0
def warpFaceFn(self, dict):

    self.reset()
    self.setPos(0.000, 0.000, 0.000)
    self.setHpr(0.000, 0.000, 0.000)
    self.setScale(1.000, 1.000, 1.000)
    p0 = Particles.Particles('particles-1')
    # Particles parameters
    p0.setFactory("PointParticleFactory")
    p0.setRenderer("SpriteParticleRenderer")
    #p0.setEmitter("DiscEmitter")
    p0.setEmitter("SphereVolumeEmitter")
    p0.setPoolSize(20000)
    p0.setBirthRate(dict["birthRate"])
    p0.setLitterSize(100)
    p0.setLitterSpread(10)
    p0.setSystemLifespan(0.0000)
    p0.setLocalVelocityFlag(1)
    p0.setSystemGrowsOlderFlag(0)
    # Factory parameters
    p0.factory.setLifespanBase(dict["lifeSpan"])
    p0.factory.setLifespanSpread(dict["lifeSpanSpread"])
    p0.factory.setMassBase(dict["mass"])
    p0.factory.setMassSpread(dict["massSpread"])
    p0.factory.setTerminalVelocityBase(dict["terminalVelocity"])
    p0.factory.setTerminalVelocitySpread(dict["terminalVelocitySpread"])
    # Point factory parameters
    # Renderer parameters
    p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
    p0.renderer.setUserAlpha(0.22)
    # Sprite parameters
    #print __import__("g").texture
    p0.renderer.setTexture(findTexture(dict["texture"]))
    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.0050)
    p0.renderer.setFinalXScale(0.0200)
    p0.renderer.setInitialYScale(0.0100)
    p0.renderer.setFinalYScale(0.0200)
    p0.renderer.setNonanimatedTheta(0.0000)
    p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPNOBLEND)
    p0.renderer.setAlphaDisable(0)
    # Emitter parameters
    p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
    p0.emitter.setAmplitude(6.0000)
    p0.emitter.setAmplitudeSpread(5.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(50.0000)
    self.addParticles(p0)
Exemplo n.º 2
0
def warpFaceFn(self, dict):

    self.reset()
    self.setPos(0.000, 0.000, 0.000)
    self.setHpr(0.000, 0.000, 0.000)
    self.setScale(1.000, 1.000, 1.000)
    p0 = Particles.Particles('particles-1')
    # Particles parameters
    p0.setFactory("PointParticleFactory")
    p0.setRenderer("SpriteParticleRenderer")
    #p0.setEmitter("DiscEmitter")
    p0.setEmitter("SphereVolumeEmitter")
    p0.setPoolSize(20000)
    p0.setBirthRate(dict["birthRate"])
    p0.setLitterSize(100)
    p0.setLitterSpread(10)
    p0.setSystemLifespan(0.0000)
    p0.setLocalVelocityFlag(1)
    p0.setSystemGrowsOlderFlag(0)
    # Factory parameters
    p0.factory.setLifespanBase(dict["lifeSpan"])
    p0.factory.setLifespanSpread(dict["lifeSpanSpread"])
    p0.factory.setMassBase(dict["mass"])
    p0.factory.setMassSpread(dict["massSpread"])
    p0.factory.setTerminalVelocityBase(dict["terminalVelocity"])
    p0.factory.setTerminalVelocitySpread(dict["terminalVelocitySpread"])
    # Point factory parameters
    # Renderer parameters
    p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
    p0.renderer.setUserAlpha(0.22)
    # Sprite parameters
    #print __import__("g").texture
    p0.renderer.setTexture(findTexture(dict["texture"]))
    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.0050)
    p0.renderer.setFinalXScale(0.0200)
    p0.renderer.setInitialYScale(0.0100)
    p0.renderer.setFinalYScale(0.0200)
    p0.renderer.setNonanimatedTheta(0.0000)
    p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPNOBLEND)
    p0.renderer.setAlphaDisable(0)
    # Emitter parameters
    p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
    p0.emitter.setAmplitude(6.0000)
    p0.emitter.setAmplitudeSpread(5.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(50.0000)
    self.addParticles(p0)
Exemplo n.º 3
0
 def __init__(self, object, position=None, hpr=None, size = 1, color = None, texture = None, duration = 0):
     Handle.__init__(self, name="dynamicGeometry", duration = duration)
     self.d.model = object
     g.nextModelId = g.nextModelId + 1
     self.d.model.setTag('rpandaid', str(g.nextModelId))
     self.d.onScreen = False
     ctl = newSignalRefd(self, "control", controlType, scEmptyControl)
     self.__dict__["control"] = ctl
     self.__dict__['position'] = newSignalRefd(self, 'position', P3Type, P3(0,0,0), ctl)
     self.__dict__['hpr']   = newSignalRefd(self, 'hpr', HPRType, HPR(0,0,0), ctl)
     self.__dict__['size'] = newSignalRefd(self, 'size', numType, 1, ctl)
     self.__dict__['color'] = newSignalRefd(self, 'color', ColorType, noColor, ctl)
     if size is not None:
          self.size.setBehavior(size)
     if position is not None:
          self.position.setBehavior(position)
     if hpr is not None:
          self.hpr.setBehavior(hpr)
     if color is not None:
          self.color.setBehavior(color)
     if texture is not None:
       tex = loader.loadTexture(findTexture(texture))
       self.d.model.setTexture(tex)
Exemplo n.º 4
0
 def setTexture(self, texture):
     tex = loader.loadTexture(findTexture(texture))
     self.d.model.setTexture(tex)
Exemplo n.º 5
0
    def __init__(self,
                 name=None,
                 particleFile="LikeFountainWater.py",
                 defaultPath=True,
                 parent=render,
                 hpr=None,
                 position=None,
                 colorType=None,
                 color=gray,
                 endColor=None,
                 size=None,
                 birthRate=None,
                 poolSize=None,
                 litterSize=None,
                 lineScaleFactor=None,
                 lifeSpanBase=None,
                 terminalVelocityBase=None,
                 texture=None,
                 amplitude=None,
                 amplitudeSpread=None,
                 emissionType="ETRADIATE",
                 radius=None,
                 radiusSpread=None,
                 duration=0):
        """Initalizes the PEffect.

        PEffect __init__(self,
                        name = 'PEffect',
                        particleFile = "LikeFountainWater.py",
                        defaultPath = True,
                        parent = render,
                        hpr = None,
                        position = None,
                        color = gray,
                        startColor = None ,
                        endColor = None,
                        headColor = None,
                        tailColor = None,
                        birthRate = None,
                        poolSize = None,
                        litterSize = None,
                        lineScaleFactor = None,
                        lifeSpanBase = None,
                        terminalVelocityBase = None,
                        amplitude = None,
                        amplitudeSpread = None,
                        particlePic = None
                        ):
        """
        if texture is not None:
            g.texture = loader.loadTexture(findTexture(texture))
        if name is None:
            name = 'PEffect-%d' % PEffect.pid
            PEffect.pid += 1

        Handle.__init__(self, name=name)
        self.d.colorType = colorType

        #pathname = "/lib/panda/lib/lib-original/particles/"
        base.enableParticles()
        p = ParticleEffect()

        self.__dict__[name] = p
        self.particleName = name
        self.d.model = p  # ???

        if defaultPath:
            # print particleFile
            p.loadConfig(Filename(g.pandaPath + "/particles/" + particleFile))
        else:
            p.loadConfig(Filename(particleFile))

        pd = p.particlesDict["particles-1"]

        if emissionType is not None:
            if emissionType is "ETRADIATE":
                pd.emitter.setEmissionType(
                    BaseParticleEmitter.ETRADIATE
                )  #emitter type ETEXPICIT ETCUSTOM, ETRADIATE
            elif emissionType is "ETCUSTOM":
                pd.emitter.setEmissionType(BaseParticleEmitter.ETCUSTOM)
        if radius is not None:
            self.__dict__['radius'] = newSignalRef(self, 'radius', numType,
                                                   radius)
        checkKeyType('PEffect', name, stringType, 'name')

        self.__dict__['position'] = newSignalRef(self, 'position', P3Type)
        #        self.__dict__['color'] = newSignalRefd(self, 'color', ColorType,color)

        self.__dict__['hpr'] = newSignalRefd(self, 'hpr', HPRType,
                                             HPR(0, 0, 0))
        self.__dict__['size'] = newSignalRefd(self, 'size', numType, 1)
        if size is not None:
            self.size.setBehavior(size)
        self.__dict__['color'] = newSignalRefd(
            self, 'color', ColorType,
            color)  # color at which the effect will start
        if endColor is None:
            endColor = color
        self.__dict__['endColor'] = newSignalRefd(
            self, 'endColor', ColorType,
            endColor)  # color at which the effect will end at
        self.color.setBehavior(color)
        if lineScaleFactor is not None:
            self.__dict__['LineScaleFactor'] = newSignalRefd(
                self, 'LineScaleFactor', numType,
                lineScaleFactor)  #how long a particle is
        if poolSize is not None:
            self.__dict__['PoolSize'] = newSignalRefd(
                self, 'PoolSize', numType,
                poolSize)  #Number of particles avaiable for the entire effect
        if birthRate is not None:
            self.__dict__['BirthRate'] = newSignalRefd(
                self, 'BirthRate', numType,
                birthRate)  #The rate in which the particle effect occurs
        if litterSize is not None:
            self.__dict__['LitterSize'] = newSignalRefd(
                self, 'LitterSize', numType,
                litterSize)  #Number of particles per effect occcurance
        if lifeSpanBase is not None:
            self.__dict__['LifeSpanBase'] = newSignalRefd(
                self, 'LIfeSpanBase', numType,
                lifeSpanBase)  #How long the particle effect stays on screen
        if terminalVelocityBase is not None:
            self.__dict__['TerminalVelocityBase'] = newSignalRefd(
                self, 'TerminalVelocityBase', numType,
                terminalVelocityBase)  #how fast the particles move
        if amplitude is not None:
            self.__dict__['Amplitude'] = newSignalRefd(
                self, 'Amplitude', numType,
                amplitude)  #amplitude is the spreading out of particles
        if amplitudeSpread is not None:
            self.__dict__['AmplitudeSpread'] = newSignalRefd(
                self, 'AmplitudeSpread', numType, amplitudeSpread
            )  #amplitude multiplier spreadings of particles.

        if position is not None:
            self.position.setBehavior(position)
        if hpr is not None:
            self.hpr.setBehavior(hpr)
        if color is not None:
            self.color.setBehavior(color)
        if endColor is not None:
            self.endColor.setBehavior(endColor)
        if parent is not render:
            self.__dict__['parent'] = parent.d.model

        p.reparentTo(render)
        p.start()
        #Had to use this hack because the refresh function kept restarting the particle effects.
        self.__dict__["started"] = True
        if duration != 0:
            self.react1(localTimeIs(duration), lambda m, v: m.exit())
Exemplo n.º 6
0
    def __init__(self, name = None, particleFile = "LikeFountainWater.py",
                defaultPath = True, parent = render, hpr = None, position = None,
                colorType = None, color = gray, endColor = None,
                size = None, birthRate = None, poolSize = None, litterSize = None,
                lineScaleFactor = None, lifeSpanBase = None, terminalVelocityBase = None,
                texture = None, amplitude = None, amplitudeSpread = None,
                emissionType = "ETRADIATE", radius = None, radiusSpread = None ,
                duration = 0):

        """Initalizes the PEffect.

        PEffect __init__(self,
                        name = 'PEffect',
                        particleFile = "LikeFountainWater.py",
                        defaultPath = True,
                        parent = render,
                        hpr = None,
                        position = None,
                        color = gray,
                        startColor = None ,
                        endColor = None,
                        headColor = None,
                        tailColor = None,
                        birthRate = None,
                        poolSize = None,
                        litterSize = None,
                        lineScaleFactor = None,
                        lifeSpanBase = None,
                        terminalVelocityBase = None,
                        amplitude = None,
                        amplitudeSpread = None,
                        particlePic = None
                        ):
        """
        if texture is not None:
            g.texture = loader.loadTexture(findTexture(texture))
        if name is None:
            name = 'PEffect-%d' % PEffect.pid
            PEffect.pid += 1

        Handle.__init__(self, name = name)
        self.d.colorType = colorType

        #pathname = "/lib/panda/lib/lib-original/particles/"
        base.enableParticles()
        p = ParticleEffect()

        self.__dict__[name] = p
        self.particleName = name
        self.d.model = p  # ???
        
        if defaultPath:
            # print particleFile
            p.loadConfig(Filename(g.pandaPath+"/particles/"+ particleFile))
        else:
            p.loadConfig(Filename(particleFile))

        pd = p.particlesDict["particles-1"]

        if emissionType is not None:
            if emissionType is "ETRADIATE":
                pd.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)  #emitter type ETEXPICIT ETCUSTOM, ETRADIATE
            elif emissionType is "ETCUSTOM":
                pd.emitter.setEmissionType(BaseParticleEmitter.ETCUSTOM)
        if radius is not None:
                    self.__dict__['radius'] = newSignalRef(self, 'radius', numType, radius)
        checkKeyType('PEffect', name, stringType, 'name')

        self.__dict__['position'] = newSignalRef(self, 'position', P3Type)
#        self.__dict__['color'] = newSignalRefd(self, 'color', ColorType,color)
        
        self.__dict__['hpr'] = newSignalRefd(self, 'hpr', HPRType, HPR(0,0,0))
        self.__dict__['size'] = newSignalRefd(self, 'size', numType, 1)
        if size is not None:
             self.size.setBehavior(size)
        self.__dict__['color'] = newSignalRefd(self,'color',ColorType,color)# color at which the effect will start
        if endColor is None:
            endColor = color
        self.__dict__['endColor'] = newSignalRefd(self,'endColor',ColorType,endColor)# color at which the effect will end at
        self.color.setBehavior(color)
        if lineScaleFactor is not None:
            self.__dict__['LineScaleFactor'] = newSignalRefd(self,'LineScaleFactor',numType,lineScaleFactor) #how long a particle is
        if poolSize is not None:
            self.__dict__['PoolSize'] = newSignalRefd(self,'PoolSize',numType,poolSize) #Number of particles avaiable for the entire effect
        if birthRate is not None:
            self.__dict__['BirthRate'] = newSignalRefd(self,'BirthRate',numType,birthRate) #The rate in which the particle effect occurs
        if litterSize is not None:
            self.__dict__['LitterSize'] = newSignalRefd(self,'LitterSize',numType,litterSize) #Number of particles per effect occcurance
        if lifeSpanBase is not None:
            self.__dict__['LifeSpanBase']  = newSignalRefd(self,'LIfeSpanBase',numType,lifeSpanBase) #How long the particle effect stays on screen
        if terminalVelocityBase is not None:
            self.__dict__['TerminalVelocityBase'] = newSignalRefd(self,'TerminalVelocityBase',numType,terminalVelocityBase) #how fast the particles move
        if amplitude is not None:
            self.__dict__['Amplitude'] = newSignalRefd(self,'Amplitude', numType, amplitude)#amplitude is the spreading out of particles
        if amplitudeSpread is not None:
            self.__dict__['AmplitudeSpread'] = newSignalRefd(self,'AmplitudeSpread',numType,amplitudeSpread)#amplitude multiplier spreadings of particles.

        if position is not None:
            self.position.setBehavior(position)
        if hpr is not None:
            self.hpr.setBehavior(hpr)
        if color is not None:
            self.color.setBehavior(color)
        if endColor is not None:
            self.endColor.setBehavior(endColor)
        if parent is not render:
            self.__dict__['parent'] = parent.d.model

        p.reparentTo(render)
        p.start()
        #Had to use this hack because the refresh function kept restarting the particle effects.
        self.__dict__["started"] = True
        if duration != 0:
            self.react1(localTimeIs(duration), lambda m, v: m.exit())