Showing posts with label Particle Engine. Show all posts
Showing posts with label Particle Engine. Show all posts

Tuesday, May 26, 2009

Monday, March 16, 2009

Particle Generator Bugfixes

A very kind (and smart) reader sent in a handful of bugfixes for my iPhone particle system, including a fix for the bug that was causing the test application to freeze. I believe those fixes also solve the problem with deleting particles, so I can put back in the code I had written and then removed that freed up the particle memory when a generator no longer has any visible particles. Will probably be a few weeks before I can get to doing that, though.

Thanks WG! That was a huge help.

Friday, March 6, 2009

Bigger version of video:

Here's a bigger version of the particle video:


Video of the Particle Generator in Action

Here's just a quick video I threw together to show the particle generator in action. Unfortunately, Blogger reduces the size down to a point where you can't see much, but you can at least get an idea of the flexibility built into the particle system.



Note: A bigger version is available here

At Last, Particle Generator


Okay, I was able to get the particle generator code back together at the 360 iDev conference. I now must put this project on the shelf because I am backed up on my paying work, but I'm putting it out there for anyone who's interested.



First, let me say that I am not an OpenGL expert. I wrote this to help me learn OpenGL and particle systems better, but it's almost certain that there's room for improvement in many places.



Second, there are a couple doozie bugs in here that keep it from being production ready. First and foremost is that any attempt to free the particles ends up in an infinite loop. The memory for particles is not released, it is constantly reused. There are two linked lists, one that holds the particles that are visible, and another to hold those that are no longer visible. When a particle reaches the end of its lifespan, it is moved from one list to the other. When a new particle is needed, one is grabbed from the pool if there is one there. This way, we avoid the overhead of constant memory allocation and deallocation. But, when the particle is done emitting, I'd like the option to free the memory, but right now, that causes a gnarly infinite loop.



Third, the sample app puts a whole bunch of emitters into an array. If you tap the screen, it tells the current emitter to stop emitting, and tells the next one to start. When it gets to the end, it tells the last one to stop, and goes back to tell the first one to start again, but when that happens, we get a pthread lock contention issue where two threads are each waiting for the other, causing the application to freeze. I'm not manually creating any threads, so tracking down this one could be really hard.



You can find the Google Code project right here.. If you prefer not to use subversion, you can download the initial version as a zip file right here.

Wednesday, January 14, 2009

Another Particle Update

Thanks in no small part to the capable brain of Noel Llopis, I've gotten past what I think is the last great barrier to getting the particle system tutorial done. As you can see, sprites are now working, which opens up a whole world of new effects.



There is still a lot of cleanup to do, and I need to continue with some of the planned performance enhancements and probably look for some new ones, but at least, thanks to some help from smart readers, the particle system has stopped being an albatross around my neck.

Look for a final release and tutorial by the end of next weekend.

Monday, January 5, 2009

Particle Update

I'm working on the Particle tutorial. I'm having a weird problem related to mapping a texture to particles, which is necessary to accomplish some of the cooler effects (though I'm unsure if the iPhone has enough horsepower to do much with it). I'm sure it's a stupid thing - a configuration I forgot to enable or something like that, because everything seems to be right. I'm hoping that when I look at it today with a fresh, moderately-well-rested, and only slightly-hungover eye, I'll see what I was doing and can finish the tutorial.

I'm working at Moscone South, and will continue to do so as long as I can find a power outlet at some point.

Thursday, January 1, 2009

Another OpenGL Particle System Teaser




This is just one possible configuration - one of the simpler ones, actually, as it is only using point rendering and simple gravity - no textures, no wind, no transparency, etc. I call this configuration "fountain", and it's can be created in one line of code:
ParticleEmitter3D *fountain = [ParticleEmitter3D fountain];
then, you just need to tell the fountain to draw itself each time through your draw loop or callback...
[fountain drawSelf];
It's probably going to be a few days before I get the first version of the code posted - it's got some rough edges still, plus a few more bits of functionality I feel are needed before it can survive public scrutiny.

The above movie was taken on the simulator. The code does work on my first generation iPhone but I have to reduce the number of points emitted per second to get it to look good with no hiccups. I haven't yet tested it on my second generation iPod Touch to see how much of a difference the new processor and FPU make. I'm also hoping that pooling and reusing the particles, rather than constantly allocating and freeing them will help a fair amount.

Wednesday, December 31, 2008

Coming Soon - My OpenGL Particle Engine



Got a start on this over the weekend, and will probably spend some time on it New Year's day. Right now, the basic functionality and physics work, but it only supports simple point drawing - no shapes or texture mapping. I'm also working on recycling the particles rather than constantly allocating and freeing the memory.

I have no idea how this is going to perform on an actual device - I've been working on the simulator so far, but I will be curious to see what these little machines can do when I start adding textures, transparencies and the rest.

Oh, and Happy New Year, everybody.