Blog

Art and music

Tonight, Sean’s out of town and M. is performing in a musical uptown, so the house will be free for Flickershow recording, hooray!

Only yesterday I was reading Muffy’s reports from the Open Ears festival and wishing I’d made it back to KW to catch it. I don’t generally get to see many shows, and the reason mostly boils down to Too Damn Busy. Either I’m working late (Sean and I seem to be home at 10pm as often as not), recording or playing with Flickershow, or recovering from the above.

I’m determined to change things around now. Coming home at a more reasonable time, for one thing; for another, working Saturday and staying home to work on music in the middle of the week, when the house is empty.

And I think I’ll have to check out some of the events at Deep Wireless: A Festival Of Radio Art. (Thanks, Torontoist.)


Particle trails with gravityHere’s the latest version of the particle sim - the particles attract this time around, and have random values for mass.

I’ve cleaned up the source and commented the hell out of it, and collected most of the major parameters so they’re easy to adjust before compiling.

Source plus the containing FLA file:
Particles1_8.zip

Shortcut URL

Comments

  //  Interaction of particles

  for (i=numParticles; i; i—) {
      for (j=numParticles; j-1; j—) {

should run a bit faster - this is a Cheap Time Optimization that i really ought to get in the habit of using. It works in pretty much any language that has a ‘for’ construct modeled after C.

basically, it runs faster because the check becomes a simple boolean truth check instead of a variable retrieve and compare. It’s a little harder to read, of course. Time optimizations always are. It tends to make a big difference when you iterate an interpreted language over any sizeable number of objects, though!

Also if I was doing this I’d have probably defined the area by throwing a movieclip on the stage and getting bounds from that. And would’ve probably tried to write it such that all the variables live on that clip - that way I could have a couple particle objects in the scene, if I wanted to. (I’ve done this, when I built a simple ‘snow’ particle system - define the area by movie clips, and layer a few with different parameters.)

Posted by Egypt Urnash on 3 May 2007 at 1:43 AM

Ahh, that makes sense… thanks! I’ll have to go over it in more detail to see if I can save on those trig calculations too.

I notice the piece slows down over time… wasn’t expecting it to keep track of all those line segments! Given that it’s vector-based, I should have guessed.

Making snow is a real pain in the ass without Actionscript, as we discovered some months ago, long before I started learning all this stuff.

As it is, I’m still getting the hang of how to program in Flash, where to put code, and so forth. Any favorite resources you’d recommend, online or off?

Posted by Eli McIlveen on 3 May 2007 at 8:40 PM

Deciding where to put stuff is as much a matter of personal style as anything else! It depends on the project, too.

You could try shifting to the newer version with lots of bitmap stuff going on - just draw the lines and bake into bitmap, rather than keeping them vector. I think that’s doable; I haven’t really investigated the new stuff much. (you might have to clear your drawing object, draw your lines, bake that into bitmap, than add that to another bitmap that’s actually the displayed one? of course you could also then integrate some fades or something into it.)

Unfortunately I don’t think there’s any simple ways to save on the trig - the gravity logic depends on the distance, which involves a square root. When you’re doing basic circle-to-circle collision detection you can get a serious gain by just working with the squared distances and never sqrt()ing, buuut…

on the other hand you could also maybe gain some speed by going through and calculating the distance between each pair of objects once, then looping through and modifying them. that might be a slightly more accurate simulation, too, as I think that the effect of object 1’s gravity on object 2 will be magnified by o1 moving towards o2 before you ever process o2.

As to resources… damn, I dunno any more, I’m way out of the loop. Flashkit.com used to be a decent resource back in ‘03 or so but it’s really hard to navigate now. Any good Javascript book will help too. also moock.org has some decent stuff I think, he’s written some of the better books out there.

Posted by Egypt Urnash on 3 May 2007 at 9:03 PM

Commenting is not available in this weblog entry.