I’m not a big fan of the Panda particle engine, and using animated textures as per manual (using a SequenceNode) turned out to be a performance killer. So I’ve decided to use the oldest technique in the book - pre-rendered particles merged into one big texture atlas. Turned out not that bad so I’m sharing.
The class P2Pvfx is to make Point-to-Point effects like lightnings, rays etc. going from one NodePath to another.
The vfx class is for stationary effects.
The code could probably be improved - it’s just a working sample how it could be done.
If you have some frames on an animation saved as individual images you can merge them like this ( the code is for 64 frames 128x128 packed into one 1024x1024 texture):
from panda3d.core import *
import os, sys
dirname=sys.argv[1]
maps=[]
dirList=os.listdir(dirname)
for fname in dirList:
if fname[-3:]=="png":
maps.append(fname)
final_img=PNMImage(1024, 1024, 4)
x=-128
y=0
for index in xrange(len(maps)):
x=x+128
if x>1024:
x=0
y=y+128
new= PNMImage()
print maps[index]
new.read(dirname+'/'+maps[index])
final_img.copySubImage(new, x, y, 0, 0, 128, 128)
final_img.write(dirname+'.png')
I’ve added one more class ‘MovingVfx’ it’s like the classical vfx but the effect is moved with a ProjectileInterval from one Node to another (for fireballs and suchlike).
Here’s the new code and effect texture: sendspace.com/file/sv7i3b
And if someone want’s to use the code posted in the last post about making a atlas from individual images, then there’s a typo there it should be ‘if x>=1024:’ at line 16 else one in eight images is skipped.
If I may suggest, it might be a good idea to allow an optional rotation (or random rotation) to cover the fact that it’s the same effect every time, and you might be able to create more complex effects yet if you allow the system to mix two or more sets of textures via Texture Stages – perhaps create a “mixedVXF” that takes in a variable number of texture-operator pairs to feed to the Texture Stages.
sendspace.com/file/njg588
also updated in the first post. These things disappear after some time if there are no downloads, p3dp.com seems dead and I don’t have a host of my own.