def __init__(self, name = 'unnamed handle', isWorld = False, duration = 0):
     d = HandleData()
     self.__dict__['d'] = d
     d.undefined = []    # Things that need to be initialized
     d.sustain = []      # Make sure everything gets evaluated
     d.switches = []     # switchers for this object
     d.newswitches = []  # newly generated switchers - don't look at these at time of switch
     d.isWorld = isWorld # Need to mark the world object
     d.statics = {}
     d.collections = []
     d.initialized = False
     d.zombie = False
     if isWorld:
          self.__dict__['name'] = 'world'
     else:
          self.__dict__['name'] = uniqueName(name)    # uniquify all names
     # Add this to the list of objects currently in the world
     g.newModels.append(self)
     if duration != 0:
         self.react1(localTimeIs(duration), lambda m, v: m.exit())
Beispiel #2
0
 def __init__(self, name='unnamed handle', isWorld=False, duration=0):
     d = HandleData()
     self.__dict__['d'] = d
     d.undefined = []  # Things that need to be initialized
     d.sustain = []  # Make sure everything gets evaluated
     d.switches = []  # switchers for this object
     d.newswitches = [
     ]  # newly generated switchers - don't look at these at time of switch
     d.isWorld = isWorld  # Need to mark the world object
     d.statics = {}
     d.collections = []
     d.initialized = False
     d.zombie = False
     if isWorld:
         self.__dict__['name'] = 'world'
     else:
         self.__dict__['name'] = uniqueName(name)  # uniquify all names
     # Add this to the list of objects currently in the world
     g.newModels.append(self)
     if duration != 0:
         self.react1(localTimeIs(duration), lambda m, v: m.exit())
Beispiel #3
0
def atLocalTime(n, r):
    react(localTimeIs(n), lambda m, v: r())
Beispiel #4
0
def atLocalTime(n, r):
    react(localTimeIs(n), lambda m, v: r())
Beispiel #5
0
def fireWork(**a):
    f = fireWorks(**a)
    f.react1(localTimeIs(2), stopIt)
    return f
Beispiel #6
0
def explosion(**a):
    e = explosions(**a)
    e.react1(localTimeIs(2), stopIt)
    return e
Beispiel #7
0
 def r(model, value):
     pos = model.position.now()
     e = effect(position=pos + offset, size=size)
     e.react1(localTimeIs(2), exitScene)
     model.exit()
Beispiel #8
0
def wait(n, r):
    react(localTimeIs(n), lambda m, v: r())
Beispiel #9
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())
def wait(n, r):
    react(localTimeIs(n), lambda m, v: r())
Beispiel #11
0
def fireWork(**a):
    f = fireWorks(**a)
    f.react1(localTimeIs(2), stopIt)
    return f
Beispiel #12
0
 def r(model, value):
     pos = model.position.now()
     e = effect(position = pos + offset, size = size)
     e.react1(localTimeIs(2), exitScene)
     model.exit()
Beispiel #13
0
def explosion(**a):
    e = explosions(**a)
    e.react1(localTimeIs(2), stopIt)
    return e
Beispiel #14
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())