When i start my particle effect the scene goes black and the models disappear


#1

I am a newbie to Panda3d. I was trying to add a particle effect to my scene to model rain. I used the samples code to write a separate script to adjust the parameters of the particles and everything worked correctly. This is the code

from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextNode
from panda3d.core import AmbientLight, DirectionalLight
from panda3d.core import LPoint3, LVector3
from panda3d.core import Filename
from panda3d.physics import BaseParticleEmitter, BaseParticleRenderer
from panda3d.physics import PointParticleFactory, SpriteParticleRenderer
from panda3d.physics import LinearNoiseForce, DiscEmitter
from direct.particles.Particles import Particles
from direct.particles.ParticleEffect import ParticleEffect
from direct.particles.ForceGroup import ForceGroup
from direct.gui.OnscreenText import OnscreenText
import sys

class ParticleDemo(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

   
        base.disableMouse()
        base.camera.setPos(0, -20, 2)
        base.camLens.setFov(25)
        base.setBackgroundColor(0, 0, 0)
        base.enableParticles()
    
        self.p = ParticleEffect()
        self.loadParticleConfig('rain.ptf')

    def loadParticleConfig(self, filename):
        # Start of the code from steam.ptf
        self.p.cleanup()
        self.p = ParticleEffect()
        self.p.loadConfig(Filename(filename))
        # Sets particles to birth relative to the teapot, but to render at
       # toplevel
        self.p.start(self.render)
        self.p.setPos(3.000, 100.000,20)

demo = ParticleDemo()
demo.run()

but when i added the particles effect to my scene it turned black and nothing from my models appeared. This the part of the code where i added my particle effect

import random

from panda3d.core import TextNode
from panda3d.core import AmbientLight, DirectionalLight
from panda3d.core import LPoint3, LVector3
from panda3d.core import Filename
from panda3d.physics import BaseParticleEmitter, BaseParticleRenderer
from panda3d.physics import PointParticleFactory, SpriteParticleRenderer
from panda3d.physics import LinearNoiseForce, DiscEmitter
from direct.particles.Particles import Particles
from direct.particles.ParticleEffect import ParticleEffect
from direct.particles.ForceGroup import ForceGroup
from direct.gui.OnscreenText import OnscreenText
import sys

def load_rainy_weather(scene):

    p = ParticleEffect()
    p.loadConfig('../models/world/environments/weather/rain.ptf')
    p.start(scene)
    p.setPos(3, -6, 0)

class WeatherFactory(object):
   
    def __init__(self,loader):
        self.loader = loader

    def create_weather(self,scene):
        load_rainy_weather(scene)

And in the main script

            weather_factory = WeatherFactory(self.loader)
            weather_factory.create_weather(self.render)

when i comment this line of code weather_factory.create_weather(self.render) my scene loads correctly and when i un-comment it the scene goes black
Any help would be appreciated
Thanks very much in advance


#2

Did you see any errors on the command-line? Perhaps it was unable to load the textures?