Hi, another day another puzzle. I’m trying to use ParticleInterval’s but I don’t see the particles when I start the interval. doing a isPlaying() tells me that the interval is playing but nothing appears on the screen. Here is the code I have so far:
I tried doing the same thing with the teapot particle demo but nothing happens there either. Am I missing some args or an essential step to using ParticleIntervals? Thanks.
I really can’t figure out how to make this work, I don’t have any examples to see so irunno. Here’s the full code for the module:
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from direct.task.Task import Task
from direct.actor.Actor import Actor
from pandac.PandaModules import NodePath
from pandac.PandaModules import OrthographicLens
from direct.interval.ParticleInterval import ParticleInterval
from direct.interval.IntervalGlobal import *
from pandac.PandaModules import CardMaker
from MudParticles import *
class MudSimulator(DirectObject):
def __init__(self):
"""Draws an offscreen buffer for texturing the mudflow"""
mainWindow=base.win
base.enableParticles()
# Offscreen buffer stuff
self.altBuffer=mainWindow.makeTextureBuffer("hello", 512, 512)
self.altRender=NodePath("new render")
self.altCam=base.makeCamera(self.altBuffer)
self.altCam.reparentTo(self.altRender)
self.altCam.setPos(0,-20,0)
# Camera stuff
lens = OrthographicLens()
lens.setFilmSize(20, 15)
self.altCam.node().setLens(lens)
# Makes the full screen card
cm = CardMaker('background')
cm.setFrame(-10,10,-7.5,7.5)
# Try to pull the texture from the model to save memory
if __name__ is not "__main__":
cardTexture = loader.loadTexture("models/mayon_map.PNG")
else:
cardTexture = render.find_texture("mayon_map.PNG")
self.card = self.altRender.attachNewNode(cm.generate())
self.card.setTexture(cardTexture)
# Particles and intervals should correspond to each others index
self.mudParticleList = []
self.mudIntervalList = []
def loadParticle(self, mudType):
if mudType == "top":
m = MudTop()
self.mudParticleList.append(m)
#print "OLO", type(m)
particle = self.mudParticleList[-1].pEffect
# These lines are giving me a problem
pI = ParticleInterval(particle, self.card, name="Particlwhat", worldRelative="0", renderParent=self.altRender)
self.mudIntervalList.append(pI)
pI.start() # Not really working
print "Is particle playing?", pI.isPlaying()
# The lines below work, showing the particles
#particle.reparentTo(self.altRender)
#particle.start()
#particle.setPos(-0.2,0,3)
class World(DirectObject):
def __init__(self):
mudSim = MudSimulator()
base.bufferViewer.setPosition("llcorner")
base.bufferViewer.setCardSize(1.4, 0.0)
base.bufferViewer.toggleEnable()
mudSim.loadParticle("top")
if __name__ == "__main__":
w = World()
run()
Note that worldRelative=“0” is really the same thing as worldRelative=1, since the string “0” evaluates True by Python. If you wanted to turn off the worldRelative feature, you should remove the quotation marks: worldRelative=0.
I spotted the quotation marks as not being necessary but it still wouldn’t run for me. I’ve given up on ParticleIntervals for now, I got the thing done using LerpFunc’s instead. Not quite the effect I was going for but time was short on my project.
I’ll try it out again later on the steam example though.