Help me with particle effects

Koiu Lpoi

18-06-2006 00:38:14

Ok, So I have particle effects working in PyOgre. They're pretty and all, I can move them around OK, etc., and I really like the system overall.

However, the only way I know of stopping the particles is to call ParticleSystemManager.destroySystem on them. This causes all the particles to instantly disappear, which is not what I'm looking for. I want the particles to fade out and disappear, not instantly disappear. Basically, I want the system to just stop emitting particles, not to delete it completely.


18-06-2006 01:41:27

for i in range(particleSystem.numEmitters):
emitter = particleSystem.getEmitter(i)
emitter.enabled = False

Koiu Lpoi

18-06-2006 02:00:58

Well, I tried it out, and i get
TypeError: range() integer end argument expected, got property.


18-06-2006 02:39:19

That's strange, it works for me.
Is your code short enough to post here? If so, post it. Otherwise post the smallest code stub that still raises the exception.

Koiu Lpoi

18-06-2006 05:41:38

from pyogre import ogre
import SampleFramework
import ode
import random

class myFrameListener(SampleFramework.FrameListener):
def __init__(self,renderWindow, camera,sceneManager):
self.sceneManager = sceneManager
self.bullets = []
self.bulletnode = []
self.zup = True
self.xup = True
self.bulletspeed = 700

def frameStarted(self,evt): #here's the main loop
inputDevice = self.inputDevice
self.mover = ogre.Vector3(0,0,0) #thing to hold the movement
self.move = 100 #constant of movement
if inputDevice.isKeyDown(ogre.KC_UP):
self.mover.y += self.move
if inputDevice.isKeyDown(ogre.KC_DOWN):
self.mover.y -= self.move
if inputDevice.isKeyDown(ogre.KC_LEFT):
self.mover.x -= self.move
if inputDevice.isKeyDown(ogre.KC_RIGHT):
self.mover.x += self.move
nodePlayer = self.sceneManager.getSceneNode("PlayerNode")
nodePlayer.translate(self.mover * evt.timeSinceLastFrame)

if inputDevice.isKeyDown(ogre.KC_Z) & self.zup == True:
psm = ogre.ParticleSystemManager.getSingleton()
self.bullets.append(psm.createSystem('fountain'+str(len(self.bullets)), 'Examples/JetEngine2'))
self.zup = False
if not inputDevice.isKeyDown(ogre.KC_Z):
self.zup = True

for x in range(len(self.bullets)):

if inputDevice.isKeyDown(ogre.KC_X)& self.xup == True:
for x in range(len(self.bullets)):
#if len(self.bullets)>0:
psm = ogre.ParticleSystemManager.getSingleton()
for i in range(ogre.ParticleSystem.numEmitters):
emitter = ogreparticleSystem.getEmitter(i)
emitter.enabled = False
self.xup = False
if not inputDevice.isKeyDown(ogre.KC_X):
self.xup = True

return not inputDevice.isKeyDown(ogre.KC_ESCAPE)

class InitApp(SampleFramework.Application):
def _createScene(self):
sceneManager = self.sceneManager
sceneManager.ambientLight = (0.5,0.5,0.5)

entPlayer = sceneManager.createEntity("Player","razor.mesh");
nodePlayer = sceneManager.rootSceneNode.createChildSceneNode("PlayerNode")

sceneManager.setSkyBox(True, "Examples/SpaceSkyBox")

cameraNode = sceneManager.rootSceneNode.createChildSceneNode()

def _createCamera(self): = self.sceneManager.createCamera("PlayerCam") = 0.1

def _createFrameListener(self):
self.frameListener = myFrameListener(self.renderWindow,,self.sceneManager)

def _isPsycoEnabled(self):
return False

if __name__ == "__main__":
app = InitApp()

There's the entire code.

Note 1: I'm still a bit of a noob at this, so this requires the "" from the tutorials directory, along with some of those media files.

Note 2: Hit Z to shoot a particle, hit X to stop them. The particles will shoot downward, iirc. They're supposed to go to the right, but you'd have to edit the particles file to see it that way.


18-06-2006 09:35:08

Looks like you are trying to retrieve the Emitter / Affector attributes from
ogre.ParticleSystem which is returning a type. You should be doing this from your ParticleSystem.

Since it looks like you are using pyOgre v1.0.6:

ps = psm.getSystem("Your Particle System Name")

Your code should look something like:

psm = ogre.ParticleSystemManager.getSingleton()

ps = psm.getSystem('fountain'+str(len(self.bullets)-1))
for i in range(ps.numEmitters):
emitter = ps.getEmitter(i)


Koiu Lpoi

18-06-2006 20:41:18

Excellent! That worked great, thanks so much!

Now, to clean up my code... it's gotten uuuuglllly...