mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
formatting
This commit is contained in:
parent
3ba4ac0cb1
commit
1a285d3c10
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
SpriteParticleRenderer-extensions module: contains methods to extend functionality
|
Contains methods to extend functionality
|
||||||
of the SpriteParticleRenderer class
|
of the SpriteParticleRenderer class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
|
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
import Particles
|
import Particles
|
||||||
import ForceGroup
|
import ForceGroup
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
|
|
||||||
class ParticleEffect(NodePath):
|
class ParticleEffect(NodePath):
|
||||||
|
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('ParticleEffect')
|
notify = DirectNotifyGlobal.directNotify.newCategory('ParticleEffect')
|
||||||
pid = 1
|
pid = 1
|
||||||
|
|
||||||
def __init__(self, name=None, particles=None):
|
def __init__(self, name=None, particles=None):
|
||||||
"""__init__()"""
|
if name == None:
|
||||||
if (name == None):
|
|
||||||
name = 'particle-effect-%d' % ParticleEffect.pid
|
name = 'particle-effect-%d' % ParticleEffect.pid
|
||||||
ParticleEffect.pid += 1
|
ParticleEffect.pid += 1
|
||||||
NodePath.__init__(self, name)
|
NodePath.__init__(self, name)
|
||||||
@ -22,7 +21,7 @@ class ParticleEffect(NodePath):
|
|||||||
self.particlesDict = {}
|
self.particlesDict = {}
|
||||||
self.forceGroupDict = {}
|
self.forceGroupDict = {}
|
||||||
# The effect's particle system
|
# The effect's particle system
|
||||||
if (particles != None):
|
if particles != None:
|
||||||
self.addParticles(particles)
|
self.addParticles(particles)
|
||||||
self.renderParent = None
|
self.renderParent = None
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ class ParticleEffect(NodePath):
|
|||||||
assert(self.notify.debug('start() - name: %s' % self.name))
|
assert(self.notify.debug('start() - name: %s' % self.name))
|
||||||
self.renderParent = renderParent
|
self.renderParent = renderParent
|
||||||
self.enable()
|
self.enable()
|
||||||
if (parent != None):
|
if parent != None:
|
||||||
self.reparentTo(parent)
|
self.reparentTo(parent)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
@ -46,8 +45,6 @@ class ParticleEffect(NodePath):
|
|||||||
del self.particlesDict
|
del self.particlesDict
|
||||||
del self.renderParent
|
del self.renderParent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.removeAllForces()
|
self.removeAllForces()
|
||||||
self.removeAllParticles()
|
self.removeAllParticles()
|
||||||
@ -55,7 +52,6 @@ class ParticleEffect(NodePath):
|
|||||||
self.particlesDict = {}
|
self.particlesDict = {}
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
"""enable()"""
|
|
||||||
# band-aid added for client crash - grw
|
# band-aid added for client crash - grw
|
||||||
if hasattr(self, 'forceGroupDict') and hasattr(self, 'particlesDict'):
|
if hasattr(self, 'forceGroupDict') and hasattr(self, 'particlesDict'):
|
||||||
if (self.renderParent != None):
|
if (self.renderParent != None):
|
||||||
@ -68,7 +64,6 @@ class ParticleEffect(NodePath):
|
|||||||
self.fEnabled = 1
|
self.fEnabled = 1
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
"""disable()"""
|
|
||||||
self.detachNode()
|
self.detachNode()
|
||||||
for p in self.particlesDict.values():
|
for p in self.particlesDict.values():
|
||||||
p.setRenderParent(p.node)
|
p.setRenderParent(p.node)
|
||||||
@ -80,13 +75,11 @@ class ParticleEffect(NodePath):
|
|||||||
|
|
||||||
def isEnabled(self):
|
def isEnabled(self):
|
||||||
"""
|
"""
|
||||||
isEnabled()
|
|
||||||
Note: this may be misleading if enable(),disable() not used
|
Note: this may be misleading if enable(),disable() not used
|
||||||
"""
|
"""
|
||||||
return self.fEnabled
|
return self.fEnabled
|
||||||
|
|
||||||
def addForceGroup(self, forceGroup):
|
def addForceGroup(self, forceGroup):
|
||||||
"""addForceGroup(forceGroup)"""
|
|
||||||
forceGroup.nodePath.reparentTo(self)
|
forceGroup.nodePath.reparentTo(self)
|
||||||
forceGroup.particleEffect = self
|
forceGroup.particleEffect = self
|
||||||
self.forceGroupDict[forceGroup.getName()] = forceGroup
|
self.forceGroupDict[forceGroup.getName()] = forceGroup
|
||||||
@ -96,12 +89,10 @@ class ParticleEffect(NodePath):
|
|||||||
self.addForce(forceGroup[i])
|
self.addForce(forceGroup[i])
|
||||||
|
|
||||||
def addForce(self, force):
|
def addForce(self, force):
|
||||||
"""addForce(force)"""
|
|
||||||
for p in self.particlesDict.values():
|
for p in self.particlesDict.values():
|
||||||
p.addForce(force)
|
p.addForce(force)
|
||||||
|
|
||||||
def removeForceGroup(self, forceGroup):
|
def removeForceGroup(self, forceGroup):
|
||||||
"""removeForceGroup(forceGroup)"""
|
|
||||||
# Remove forces from all particles
|
# Remove forces from all particles
|
||||||
for i in range(len(forceGroup)):
|
for i in range(len(forceGroup)):
|
||||||
self.removeForce(forceGroup[i])
|
self.removeForce(forceGroup[i])
|
||||||
@ -111,7 +102,6 @@ class ParticleEffect(NodePath):
|
|||||||
del self.forceGroupDict[forceGroup.getName()]
|
del self.forceGroupDict[forceGroup.getName()]
|
||||||
|
|
||||||
def removeForce(self, force):
|
def removeForce(self, force):
|
||||||
"""removeForce(force)"""
|
|
||||||
for p in self.particlesDict.values():
|
for p in self.particlesDict.values():
|
||||||
p.removeForce(force)
|
p.removeForce(force)
|
||||||
|
|
||||||
@ -120,7 +110,6 @@ class ParticleEffect(NodePath):
|
|||||||
self.removeForceGroup(fg)
|
self.removeForceGroup(fg)
|
||||||
|
|
||||||
def addParticles(self, particles):
|
def addParticles(self, particles):
|
||||||
"""addParticles(particles)"""
|
|
||||||
particles.nodePath.reparentTo(self)
|
particles.nodePath.reparentTo(self)
|
||||||
self.particlesDict[particles.getName()] = particles
|
self.particlesDict[particles.getName()] = particles
|
||||||
|
|
||||||
@ -130,7 +119,7 @@ class ParticleEffect(NodePath):
|
|||||||
particles.addForce(fg[i])
|
particles.addForce(fg[i])
|
||||||
|
|
||||||
def removeParticles(self, particles):
|
def removeParticles(self, particles):
|
||||||
if (particles == None):
|
if particles == None:
|
||||||
self.notify.warning('removeParticles() - particles == None!')
|
self.notify.warning('removeParticles() - particles == None!')
|
||||||
return
|
return
|
||||||
particles.nodePath.detachNode()
|
particles.nodePath.detachNode()
|
||||||
@ -164,7 +153,6 @@ class ParticleEffect(NodePath):
|
|||||||
return self.forceGroupDict
|
return self.forceGroupDict
|
||||||
|
|
||||||
def saveConfig(self, filename):
|
def saveConfig(self, filename):
|
||||||
"""saveFileData(filename)"""
|
|
||||||
f = open(filename.toOsSpecific(), 'wb')
|
f = open(filename.toOsSpecific(), 'wb')
|
||||||
# Add a blank line
|
# Add a blank line
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
@ -205,7 +193,6 @@ class ParticleEffect(NodePath):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def loadConfig(self, filename):
|
def loadConfig(self, filename):
|
||||||
"""loadConfig(filename)"""
|
|
||||||
try:
|
try:
|
||||||
if vfs:
|
if vfs:
|
||||||
exec vfs.readFile(filename)
|
exec vfs.readFile(filename)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
from pandac.PandaModules import *
|
from pandac.PandaModules import *
|
||||||
from direct.particles import ParticleEffect
|
from direct.particles import ParticleEffect
|
||||||
from direct.particles import Particles
|
from direct.particles import Particles
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
"""ParticleManagerGlobal module: contains the global particle system manager"""
|
"""
|
||||||
|
Contains the global particle system manager
|
||||||
|
"""
|
||||||
from pandac.PandaModules import ParticleSystemManager
|
from pandac.PandaModules import ParticleSystemManager
|
||||||
|
|
||||||
particleMgr = ParticleSystemManager()
|
particleMgr = ParticleSystemManager()
|
||||||
|
@ -28,12 +28,11 @@ import SpriteParticleRendererExt
|
|||||||
|
|
||||||
import string
|
import string
|
||||||
import os
|
import os
|
||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class Particles(ParticleSystem):
|
class Particles(ParticleSystem):
|
||||||
|
notify = directNotify.newCategory('Particles')
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('Particles')
|
|
||||||
id = 1
|
id = 1
|
||||||
|
|
||||||
def __init__(self, name=None, poolSize=1024):
|
def __init__(self, name=None, poolSize=1024):
|
||||||
@ -147,7 +146,6 @@ class Particles(ParticleSystem):
|
|||||||
ParticleSystem.setRenderer(self, self.renderer)
|
ParticleSystem.setRenderer(self, self.renderer)
|
||||||
|
|
||||||
def setEmitter(self, type):
|
def setEmitter(self, type):
|
||||||
"""setEmitter(type)"""
|
|
||||||
if (self.emitterType == type):
|
if (self.emitterType == type):
|
||||||
return None
|
return None
|
||||||
if (self.emitter):
|
if (self.emitter):
|
||||||
|
@ -3,7 +3,7 @@ from pandac.PandaModules import SpriteParticleRenderer
|
|||||||
|
|
||||||
class SpriteParticleRendererExt(SpriteParticleRenderer):
|
class SpriteParticleRendererExt(SpriteParticleRenderer):
|
||||||
"""
|
"""
|
||||||
SpriteParticleRenderer-extensions module: contains methods to extend functionality
|
Contains methods to extend functionality
|
||||||
of the SpriteParticleRenderer class
|
of the SpriteParticleRenderer class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -30,7 +30,6 @@ class SpriteParticleRendererExt(SpriteParticleRenderer):
|
|||||||
def setTextureFromFile(self, fileName = None):
|
def setTextureFromFile(self, fileName = None):
|
||||||
if fileName == None:
|
if fileName == None:
|
||||||
fileName = self.getSourceTextureName()
|
fileName = self.getSourceTextureName()
|
||||||
|
|
||||||
|
|
||||||
t = loader.loadTexture(fileName)
|
t = loader.loadTexture(fileName)
|
||||||
if (t != None):
|
if (t != None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user