mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
particles: add snake-case aliases to Python particle classes
This commit is contained in:
parent
ccca3cca3a
commit
f47fd8875c
@ -6,13 +6,14 @@ from direct.showbase.PhysicsManagerGlobal import *
|
|||||||
from direct.directnotify import DirectNotifyGlobal
|
from direct.directnotify import DirectNotifyGlobal
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class ForceGroup(DirectObject):
|
class ForceGroup(DirectObject):
|
||||||
|
|
||||||
notify = DirectNotifyGlobal.directNotify.newCategory('ForceGroup')
|
notify = DirectNotifyGlobal.directNotify.newCategory('ForceGroup')
|
||||||
id = 1
|
id = 1
|
||||||
|
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
if (name == None):
|
if name is None:
|
||||||
self.name = 'ForceGroup-%d' % ForceGroup.id
|
self.name = 'ForceGroup-%d' % ForceGroup.id
|
||||||
ForceGroup.id += 1
|
ForceGroup.id += 1
|
||||||
else:
|
else:
|
||||||
@ -60,9 +61,12 @@ class ForceGroup(DirectObject):
|
|||||||
|
|
||||||
# Get/set
|
# Get/set
|
||||||
def getName(self):
|
def getName(self):
|
||||||
|
"""Deprecated: access .name directly instead."""
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def getNode(self):
|
def getNode(self):
|
||||||
return self.node
|
return self.node
|
||||||
|
|
||||||
def getNodePath(self):
|
def getNodePath(self):
|
||||||
return self.nodePath
|
return self.nodePath
|
||||||
|
|
||||||
@ -124,3 +128,9 @@ class ForceGroup(DirectObject):
|
|||||||
file.write(fname + ' = AngularVectorForce(Quat(%.4f, %.4f, %.4f))\n' % (vec[0], vec[1], vec[2], vec[3]))
|
file.write(fname + ' = AngularVectorForce(Quat(%.4f, %.4f, %.4f))\n' % (vec[0], vec[1], vec[2], vec[3]))
|
||||||
file.write(fname + '.setActive(%d)\n' % f.getActive())
|
file.write(fname + '.setActive(%d)\n' % f.getActive())
|
||||||
file.write(targ + '.addForce(%s)\n' % fname)
|
file.write(targ + '.addForce(%s)\n' % fname)
|
||||||
|
|
||||||
|
is_enabled = isEnabled
|
||||||
|
get_node = getNode
|
||||||
|
get_node_path = getNodePath
|
||||||
|
as_list = asList
|
||||||
|
print_params = printParams
|
||||||
|
@ -8,12 +8,13 @@ from . 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):
|
||||||
if name == None:
|
if name is 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)
|
||||||
@ -25,7 +26,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 is not None:
|
||||||
self.addParticles(particles)
|
self.addParticles(particles)
|
||||||
self.renderParent = None
|
self.renderParent = None
|
||||||
|
|
||||||
@ -55,7 +56,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 is not None:
|
||||||
self.reparentTo(parent)
|
self.reparentTo(parent)
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
@ -128,7 +129,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 is None:
|
||||||
self.notify.warning('removeParticles() - particles == None!')
|
self.notify.warning('removeParticles() - particles == None!')
|
||||||
return
|
return
|
||||||
particles.nodePath.detachNode()
|
particles.nodePath.detachNode()
|
||||||
@ -232,3 +233,25 @@ class ParticleEffect(NodePath):
|
|||||||
def __isValid(self):
|
def __isValid(self):
|
||||||
return hasattr(self, 'forceGroupDict') and \
|
return hasattr(self, 'forceGroupDict') and \
|
||||||
hasattr(self, 'particlesDict')
|
hasattr(self, 'particlesDict')
|
||||||
|
|
||||||
|
# Snake-case aliases.
|
||||||
|
is_enabled = isEnabled
|
||||||
|
add_force_group = addForceGroup
|
||||||
|
add_force = addForce
|
||||||
|
remove_force_group = removeForceGroup
|
||||||
|
remove_force = removeForce
|
||||||
|
remove_all_forces = removeAllForces
|
||||||
|
add_particles = addParticles
|
||||||
|
remove_particles = removeParticles
|
||||||
|
remove_all_particles = removeAllParticles
|
||||||
|
get_particles_list = getParticlesList
|
||||||
|
get_particles_named = getParticlesNamed
|
||||||
|
get_particles_dict = getParticlesDict
|
||||||
|
get_force_group_list = getForceGroupList
|
||||||
|
get_force_group_named = getForceGroupNamed
|
||||||
|
get_force_group_dict = getForceGroupDict
|
||||||
|
save_config = saveConfig
|
||||||
|
load_config = loadConfig
|
||||||
|
clear_to_initial = clearToInitial
|
||||||
|
soft_stop = softStop
|
||||||
|
soft_start = softStart
|
||||||
|
@ -600,3 +600,17 @@ class Particles(ParticleSystem):
|
|||||||
base.physicsMgr.doPhysics(remainder,self)
|
base.physicsMgr.doPhysics(remainder,self)
|
||||||
|
|
||||||
self.render()
|
self.render()
|
||||||
|
|
||||||
|
# Snake-case aliases.
|
||||||
|
is_enabled = isEnabled
|
||||||
|
set_factory = setFactory
|
||||||
|
set_renderer = setRenderer
|
||||||
|
set_emitter = setEmitter
|
||||||
|
add_force = addForce
|
||||||
|
remove_force = removeForce
|
||||||
|
set_render_node_path = setRenderNodePath
|
||||||
|
get_factory = getFactory
|
||||||
|
get_emitter = getEmitter
|
||||||
|
get_renderer = getRenderer
|
||||||
|
print_params = printParams
|
||||||
|
get_pool_size_ranges = getPoolSizeRanges
|
||||||
|
Loading…
x
Reference in New Issue
Block a user