mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
*** empty log message ***
This commit is contained in:
parent
d7628d3319
commit
9f4ea73aac
@ -87,3 +87,40 @@ class ForceGroup(DirectObject):
|
||||
l.append(self.node.getForce(i))
|
||||
return l
|
||||
|
||||
def printParams(self, file = sys.stdout, targ = 'self'):
|
||||
"""printParams(file, targ)"""
|
||||
file.write('# Force parameters\n')
|
||||
for i in range(self.node.getNumForces()):
|
||||
f = self.node.getForce(i)
|
||||
fname = 'force%d' % i
|
||||
if isinstance(f, LinearForce):
|
||||
amplitude = f.getAmplitude()
|
||||
massDependent = f.getMassDependent()
|
||||
if isinstance(f, LinearCylinderVortexForce):
|
||||
file.write(fname + ' = LinearCylinderVortexForce(%.4f, %.4f, %.4f, %.4f, %d)\n' % (f.getRadius(), f.getLength(), f.getCoef(), amplitude, massDependent))
|
||||
elif isinstance(f, LinearDistanceForce):
|
||||
radius = f.getRadius()
|
||||
falloffType = f.getFalloffType()
|
||||
ftype = 'FTONEOVERR'
|
||||
if (falloffType == LinearDistanceForce.LinearDistanceForce.FTONEOVERR):
|
||||
ftype = 'FTONEOVERR'
|
||||
elif (falloffType == LinearDistanceForce.LinearDistanceForce.FTONEOVERRSQUARED):
|
||||
ftype = 'FTONEOVERRSQUARED'
|
||||
elif (falloffType == LinearDistanceForce.LinearDistanceForce.FTONEOVERRCUBED):
|
||||
ftype = 'FTONEOVERRCUBED'
|
||||
forceCenter = f.getForceCenter()
|
||||
if isinstance(f, LinearSinkForce):
|
||||
file.write(fname + ' = LinearSinkForce(Vec3(%.4f, %.4f, %.4f), %s, %.4f, %.4f, %d)\n' % (forceCenter[0], forceCenter[1], forceCenter[2], ftype, radius, amplitude, massDependent))
|
||||
elif isinstance(f, LinearSourceForce):
|
||||
file.write(fname + ' = LinearSourceForce(Vec3(%.4f, %.4f, %.4f), %s, %.4f, %.4f, %d)\n' % (forceCenter[0], forceCenter[1], forceCenter[2], ftype, radius, amplitude, massDependent))
|
||||
elif isinstance(f, LinearFrictionForce):
|
||||
file.write(fname + ' = LinearFrictionForce(%.4f, %.4f, %d)\n' % (f.getCoef(), amplitude, massDependent))
|
||||
elif isinstance(f, LinearJitterForce):
|
||||
file.write(fname + ' = LinearJitterForce(%.4f, %d)\n' % (amplitude, massDependent))
|
||||
elif isinstance(f, LinearNoiseForce):
|
||||
file.write(fname + ' = LinearNoiseForce(%.4f, %d)\n' % (amplitude, massDependent))
|
||||
elif isinstance(f, LinearVectorForce):
|
||||
vec = f.getVector()
|
||||
file.write(fname + ' = LinearVectorForce(Vec3(%.4f, %.4f, %.4f), %.4f, %d)\n' % (vec[0], vec[1], vec[2], amplitude, massDependent))
|
||||
file.write(fname + '.setActive(%d)\n' % f.getActive())
|
||||
file.write(targ + '.addForce(%s)\n' % fname)
|
||||
|
@ -86,16 +86,23 @@ class ParticleEffect(NodePath):
|
||||
f.write('\n')
|
||||
|
||||
# Save all the forces to file
|
||||
num = 0
|
||||
for fg in self.forceGroupDict.values():
|
||||
target = 'f%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = ForceGroup.ForceGroup(\'%s\')\n' % fg.getName())
|
||||
fg.printParams(f, target)
|
||||
f.write('self.addForceGroup(%s)\n' % target)
|
||||
|
||||
# Save all the particles to file
|
||||
f.write('self.particlesDict = {}\n')
|
||||
num = 1
|
||||
num = 0
|
||||
for p in self.particlesDict.values():
|
||||
target = 'particles%d' % num
|
||||
target = 'p%d' % num
|
||||
num = num + 1
|
||||
f.write(target + ' = Particles.Particles(\'%s\')\n' % p.name)
|
||||
f.write(target + ' = Particles.Particles(\'%s\')\n' % p.getName())
|
||||
p.printParams(f, target)
|
||||
f.write('self.addParticles(' + target + ')\n')
|
||||
f.write('self.addParticles(%s)\n' % target)
|
||||
|
||||
# Close the file
|
||||
f.close()
|
||||
|
@ -20,4 +20,4 @@ pe.addForceGroup(fg)
|
||||
pe.enable()
|
||||
|
||||
# Particle Panel
|
||||
ParticlePanel.ParticlePanel(pe)
|
||||
pp = ParticlePanel.ParticlePanel(pe)
|
||||
|
Loading…
x
Reference in New Issue
Block a user