Archive for the ‘Source Code’ Category

SRC: Particle Emitter, pt. 2

Thursday, February 14th, 2008

My creative process is very sculptural. Seeing as how I graduated with a degree in sculpture, this is no surprise. When I code, I keep adding and adding and adding until I reach a point where I start to get confused. Then I step back and look at the piece from all angles until I see some direction I would like to explore. Then I do a little clean up to eliminate the parts that don’t belong in the new direction, and then its back to adding.

With this in mind, I have revisited the first source release. I have chosen not to release something entirely different, instead opting to build on the foundation that the first source provided. I think it might be useful for people to see that I generally don’t build towards a specific goal. I just wander. Sometimes I wander down dead ends, but sometimes I find myself in places that I hadn’t imagined could exist. Man, I need more coffee. These code-metaphors are starting to get a little cheese.

So here it is, release 2.

Same deal as before but with a few extra features. As before, you can toggle the perlin noise, gravity, floor plane, and particle trail. The gravity and floor are now on by default.

‘P’ will toggle a Perlin Noise influence to the Particle velocity.
‘G’ will add a gravity influence to the Particle velocity.
‘F’ will toggle on an invisible floor allowing the Particles to bounce.
‘T’ will toggle the rendering of a Particle trail.

In addition, you can also turn on a basic smoke emitter and save out image sequences.

‘N’ will toggle the smoke effect (nebula).
‘S’ will toggle the saving out of images, one per loop.

Some features of this piece of source code:
• Basic camera controls using Kristian Damkjer’s OCD library. Right click and drag will reorient the camera.
• Added basic smoke effects.
• Added fake-lighting textures on the floor plane.
• Some simple depth testing to allow the floor plane to occlude the additive blended bits. I will probably expand on this in the next release because I have received a lot of comments about this particular process.
• Particles can now split if they hit the floor with enough force.
• Loaded images are now in the Images class. Organizational change more than a functional one.
• Saves out image sequences when the ’s’ key is pressed. Hit ’s’ again to turn of feature.

I must warn you this source release is not optimized to be processor friendly. If you leave the trails and smoke off, it can do okay. However, since the particles can split into even more particles, if you slam the emitter into the floor while holding down the left mouse button, you will create a fountain of particles that will multiply when they hit the floor and the frame rate will drop.

I could have limited the max particles the piece can have at once, but instead I will leave it as is. Maybe someone like Simon (cough) will attempt another shader version.

This source was a bit more rushed than the last one so it is not as well commented. If you are starting here and find yourself confused, I would recommend checking out pt. 1 first.

UPDATE: This code doesn’t quite work with Processing 1.0. There will be some bindTexture errors. This post should help you resolve those errors until I can find the time to redo this source code properly.

Click here to download the source code.

SRC: Particle Emitter

Monday, February 11th, 2008

For this first release, I am showing how I go about making a generic particle emitter. I used Processing v.135 and Karsten Schmidt’s Vec3D library. It was developed on a MacBook Pro laptop, but this shouldn’t be a problem.

There is an emitter on screen which will follow your cursor position. When you click and hold the left mouse button, it will create particles with a randomized velocity and send them out into the world.

‘P’ will toggle a Perlin Noise influence to the Particle velocity.
‘G’ will add a gravity influence to the Particle velocity.
‘F’ will turn on an invisible floor allowing the Particles to bounce.
‘T’ will toggle the rendering of a Particle trail.

Some features of this piece of source code:
• Some example usage of Karsten’s Vec3D library.
• ArrayList to handle the variable number of particles.
• Location history used as a ribbon trail.
• OpenGL display lists and additive blending.

Click here to download the source code.

UPDATES———————————————————————
• February 11th, 2008: Implemented an OpenGL reorganization as per Simon Gelfius’ recommendation. Should improve performance a bit.

• December 8th, 2008: This code doesn’t quite work with Processing 1.0. There will be some bindTexture errors. This post should help you resolve those errors until I can find the time to redo this source code properly.

Source code rumination

Friday, February 8th, 2008

Maybe rumination is too strong a word. Im not really thinking intensely about it. Rather I am thinking vaguely about offering it. And by ‘it’ I mean ’some’.

I need to be better about giving back to the community which has been so generous with its assistance in helping me. I want to post more source code but it puts me in a bit of a quandary. What should I give? How much should I give? Frankly, I have no idea.

I am opposed to handing out the source for any of the art projects I am working on. Pieces like Magnetic Ink, Magnetosphere, and Solar are works in progress so it would feel weird to just hand over the code. Plus, some of those pieces are being used for client work so it wouldn’t be fair to our clients for me to hand it over.

There is also the problem of not wanting to teach poor coding practices to beginners. I don’t pretend to have the right answers to all the coding problems I encounter. For some of those problems, I am using code that I know to be crappy but its a level of crappy that I understand and therefore don’t mind using. But it would feel odd for me to hand off code that is held together with band-aids.

On the plus side, I look forward to getting assistance from the general public. Maybe people will show me better ways to accomplish tasks and I always learn faster by example. Perhaps we can rip off those band-aids together.

So now I put it to you, what source code would you be interested in? Ask for specific snippets and I will be much more likely to oblige. Ask for ‘all the code for magnetosphere’, and you will get nothing.