We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Ruin 2
Page Index Toggle Pages: 1
Ruin 2 (Read 2513 times)
Ruin 2
Feb 2nd, 2010, 7:50pm
 
Hi...

Here's a program where you can build "cities" out of blocks of different materials, and then break them with earthquakes or freeze/thaw cycles. Different materials respond differently to to the destruction methods. I am intending to add new materials and new "ruin" types (e.g hurricane, war) in the next version.

You can play with the sketch here:

http://www.openprocessing.org/visuals/?visualID=7364

(warning-the program can get slow if you create a lot of blocks and break them down into many very small pieces)
Re: Ruin 2
Reply #1 - Feb 3rd, 2010, 2:10pm
 
I will give this a try.  Looks interesting.
Re: Ruin 2
Reply #2 - Feb 3rd, 2010, 6:15pm
 
Very cool. Thanks, I'll check it out.
Re: Ruin 2
Reply #3 - Feb 4th, 2010, 9:54am
 
Nice. You get some very nice, complex forms after some iterations.

May I suggest that future versions could include a force like gravity, as well as collision between at least the larger pieces?

Good work!
Re: Ruin 2
Reply #4 - Feb 25th, 2010, 7:44pm
 
Thanks for your comments. With regard to gravity, I see this as a sort of top down view of buildings, or something like that...so I wouldn't want to have stuff falling down the screen.

I don't know why it wouldn't work for you, Jon...It just uses very basic Processing stuff. Did you try a different browser?

I wanted to add some extra "ruin" methods - e.g. "Hurricane" and "war" (localised damage). but I got very bogged down and frustrated on these methods as they just wouldn't work properly. Maybe later....
Re: Ruin 2
Reply #5 - Feb 26th, 2010, 2:10am
 
Awesome,   Smiley you have put some serious work and thought into this project , it really shows. Gives a newbie some ideas.
Re: Ruin 2
Reply #6 - Feb 26th, 2010, 11:39am
 
I'm glad it sparked something.... If you do something similar I'd be interested to see it...
Re: Ruin 2
Reply #7 - Feb 26th, 2010, 9:25pm
 
Very cool!  Especially enjoyed steel/earthquake and lead/freeze-thaw.  One suggestion: let particles that get small enough (<2 px?) be removed, so the sketch doesn't bog down with dust...

--Ben
Re: Ruin 2
Reply #8 - Feb 27th, 2010, 1:55pm
 
Thanks for the comments...

There is a limit to how small the squares can get (it's like a recursive thing, so there has to be). I tried making the minimum size larger, but when they still look like small squares it doesn't look anywhere near as cool. If you change the condition "if (sidelength>0.2)" in the earthquake and freeze methods to "if (sidelength>0.4)" you'll see what I mean. As the square size is 10x the value it is already set to 2 pixels minimum. The smoothing just makes them seem smaller (antialiasing greys out the edges).
Re: Ruin 2
Reply #9 - Feb 27th, 2010, 8:42pm
 
aye, I just mean have the 1px bits get removed after a while so you're not spending processing/rendering power on them...otherwise I have to reset often, with a 1.33 ghz machine.
Re: Ruin 2
Reply #10 - Feb 28th, 2010, 7:07am
 
Good idea. They will still be sitting there as "dust", but removed from the array....
Re: Ruin 2
Reply #11 - Feb 28th, 2010, 7:32am
 
Hmmm. Removing the dust just looks weird, as the matter gradually disappears into nothing. I tried making them become stationary by setting their strength and density to 1000 and their brittleness to zero - but this didn't make any difference to the rendering speed. I think the way to go would be to create another class of dustsquares which just get drawn every frame and don't have to undergo the movement calculations of all the other particles. When a particle gets down to a certain size it is removed from the squares array and added to the  dustsquares array.

Or....even better...remove them from the array and draw them onto a buffer image. The buffer image is then drawn as background every frame and new "dust" is drawn onto it as it appears.... (just thinking aloud here). I'll try this and see how it works.
Re: Ruin 2
Reply #12 - Feb 28th, 2010, 9:23am
 
I set this up.... I had some problems with removing things from the arraylist as I think draw() and mouseClicked() were both trying to work with the arraylist at the same time so I was getting index out of  bounds errors. In other words, draw would change the size of the array, but a loop in mouseClicked() was already using it at the old size at the same time. I fixed this by putting the code that removes squares from the array at the end of the mouseClicked method.

So now it runs faster but doesn't look quite as good, in my opinion, as the dust doesn't keep getting moved around. But it should be much faster...

I learned that you can use a PGraphics object as background without having to copy it into a PImage, so that was useful. New sketch here:

http://www.openprocessing.org/visuals/?visualID=7917
Re: Ruin 2
Reply #13 - Feb 28th, 2010, 10:50am
 
I've fixed problems with the array size changing in the past in a couple ways -- one is making sure any command to remove an entry is coupled with decreasing your iterator by 1 so it doesn't skip the next entry...and making sure the conditional in your loop ends at arrayList.size() instead of a hardcoded variable.  Another, simpler way is to run backwards through the array.

It's not much faster for me, this second way, and I agree it's a little strange looking.  What I meant is, I would fade 1px dust particles out over time ... set their transparency lower and lower and finally remove them entirely.  I *think* it would look natural, as though they were splitting too fine to see...
Re: Ruin 2
Reply #14 - Feb 28th, 2010, 2:52pm
 
Eventually all the matter becomes dust size...so if you do this it all disappears.... with a ruin you expect to see the same amount of matter...just ruined.

Thanks for your array suggestions. I was actually redrawing the member at i to avoid the skipped member problem, but it didn't occur to me to just decrement i.....
Page Index Toggle Pages: 1