July 15, 2009 at 8:00 pm #3087
I was wondering if you could provide a short example of how to create and run a particle effect. I tried to copy the code from Vaders, modify it and use that. However, my framework separates the logic loop and the draw loop from each other. So I think I’m having trouble integrating the tweening mechanism. My particles don’t appear anywheres.
I’m calling particles.Update() in my logic loop at the number of frame ticks from the tween which is also updated in the logic loop. I call the particles.Drawparticles() passing the tween value in the draw loop. The two loops run at different speeds. Logic is called a lot more often than the drawing is.
I’d show you my code but the framework code is commercial and I can’t show my code without showing the framework code too.
I’m going to try again but it could also be that I’m running it on a mac and that is the problem. Is there anything I have to do to make it compatible with Mac or OpenGL? Thanks.
JamesJuly 15, 2009 at 11:06 pm #3378
Off the top of my head before I go to bed, are you using SetUpdateFrequency to set whatever the update frequency is? I wouldn’t have thought that would stop anything from being drawn though. In the doc folder of timelinefx mod is an example called tlParticleManager.bmx (rigz.mod/timelinefx.mod/doc) which is a very simple example. Try running that and see if it works. It can also be found here: http://www.rigzsoft.co.uk/index.php?option=com_content&view=article&id=24:a-simple-program&catid=5:module-help&Itemid=18 on this site in the help section.
Also just try compiling vaders and see if that runs ok on the mac. It should run ok, I can’t think of any reason why it shouldn’t.July 16, 2009 at 12:34 am #3379
I didn’t call SetFrequency(). But I’m having a problem with the particles.update() for the particle manager now. It complains about a null object. I think I read somewhere in another thread about this. I’m going to take a look and see if I can update everything.
The Vaders wont run for the same reason. But the basic particle demo in the docs folder works fine. So I have to have something incorrect.
I also noticed in the tween module that the tween has a create method rather than a create function. I switched that around. I think I remember that being mentioned to do that too. May be I just have an old copy of the module and I need to update.July 16, 2009 at 1:40 am #3380
I updated the modules and the extra module and used CopyEffect() instead of the tlEffect directly and it seems to work fine.July 16, 2009 at 7:36 am #3381
Excellent 🙂 so it’s working OK on the Mac then? That’s good to know.July 16, 2009 at 10:22 am #3382
It seems to be working but I’m getting some odd behavior. Perhaps I’m working in an unsupported mode too. First, I’m in 3D mode using MiniB3D within a Window. When I move my mouse outside of the window and my mouse graphic is not displayed because the cursor has moved outside of the window, I start getting a dark blue hue around every sprite that is displayed with an alpha channel. This doesn’t happen when I’m not displaying particles. It’s only when the particles are active and possibly when an effect is just loaded. But I haven’t tested that.
Also, when this blue hue appears I notice a continuous bunch of sprites being drawn in the upper left corner which are not visible when the mouse is inside the window. It looks like my particle effect but I don’t know why it would be there. There is only one effect running and it is a copy of the template that I loaded. Could it be the template? When on pause it is more obvious that there is something going on in the upper corner. When the game goes on pause, it fades slightly. Whenever my games fades, I get this problem in the corner.
[attachment=0:o8f385sj]PausedProblem.jpg[/attachment:o8f385sj]July 16, 2009 at 12:11 pm #3383
The blue hue sounds like it might be that some open gl states are not being reset since the particles were drawn. When you draw your sprites do you setcolor and setalpha before drawing them? ie.,
I’m not sure about the grey square in the top left as it doesn’t look like the same shape as the particles being drawn. Is it perhaps something else being drawn that you haven’t noticed before because the particles weren’t changing the open gl states at all ie., setrotation setscale etc.
Nice looking candle effect 🙂July 16, 2009 at 2:09 pm #3384
The blue only shows up when the mouse is outside of the window and when I have the particles being displayed. I’ll try to set the colors and blend modes in each draw loop to see if that helps. It’s just strange why it does it only when the mouse is outside of the window.
To me, the gray squares look like the alpha channel of the particle being blended with the background. They rotate around a lot centred on that corner. They aren’t static. They seem to only do this when the screen is faded slightly. So I’m not sure what is causing it. I managed to code my way around the issue for fading the screen in and out but not for the slight dimming that the screen gets when it is on pause.
Perhaps both of these two problems are caused by the same thing. However, I have nothing drawing in the upper corner. If I shut off the particle system, the gray squares go away too. Doing a particles.clearall() removes it before I do a fade. And not drawing the particles until a fade is complete also prevents it. But I haven’t managed to find a way to pause the particles on the spot. Is there a way to do that?
I’m going to make the flame a little bigger and taller but I was pretty satisfied with it. I just need a tiny trail of smoke and I think it will be done. Thanks. 🙂July 16, 2009 at 2:54 pm #3385
To pause a particle manager call togglepause()
And just call it again to unpause it.
Maybe you can post the code where you add the effect to the particle manager, it should be something along the lines of:
local candleflame:tleffect=copyeffect(myEffectsLibrary.GetEffect("Candle Effect")
'move it to where ever it should be on sreen
'Add it to the particle manager
Then it’s just a case of updating and rendering the particle manager in the main loop which it sounds like you’re doing OK.July 16, 2009 at 3:53 pm #3386
My field definitions look like:
' Particle Effects Fields
Field particles:tlParticleManager 'The main particle manager for GUI effects
Field effectslib:tlEffectsLibrary 'The effect library
My loading method looks like:
' Setup Particles
Tweener = New tTweener.Create(30)
particles = CreateParticleManager()
particles.SetOrigin(ScreenWidth / 2, ScreenHeight / 2)
'load the effects library
effectslib = LoadEffects(Game.DataPrefix+"data/fx/Candle.eff")
CandleFlame = effectslib.GetEffect("Candle Flame")
Local e:tlEffect = CopyEffect(CandleFlame, particles)
My Draw loop looks like:
' Draw Candles and effects
If Game.Fading()=0 Or Game.Paused=0 Then
For Local Ticks:Int = 1 To Tweener.FrameTicks
July 16, 2009 at 4:32 pm #3387
I think I got it working. It was the SetScale, Color and Alphablending being carried over from the particle system interfering with the game graphics. It only worked when the mouse was on the screen because when the mouse was being displayed, it reset all of those things. 😆 When the mouse wasn’t on the screen, they didn’t get reset because the mouse wasn’t drawn. Now the bluing is gone and so is the flicker in the corner.
Thanks for the help. I’m still new to Blitz and everything else. 😉July 16, 2009 at 4:54 pm #3388
Cool, I’ll thought it might be something along those lines as it’s caught me out before too 😀July 16, 2009 at 6:48 pm #3389
I’ll have to keep my eye out for that kind of thing in the future. 😳
Is there a way to force the particle engine to start displaying the particles well into the simulation. For instance, I would like to load the scene with the candle already lit instead of waiting for the flame to actually be built. Could I just loop to update the particles for so many ticks to precalculate their positions?
Thanks.July 16, 2009 at 8:06 pm #3390
Yeh, pre loading effects up to a certain number of frames is something I’ve had at the back of my mind a while.
Hmm, well I just gave it some thought tried a few things and now its implemented 😀 ..so it will be in the next update which I should be able to upload tonight.July 16, 2009 at 8:09 pm #3391
Cool! I look forward to it. Thanks. 🙂
You must be logged in to reply to this topic.