So I whipped together a little app that basically ripples water
http://davesorrell.com/images/private/ripples.png
All the rippling in the top corner was caused by one splash ricocheting off the walls. The app certainly isn't fast, but it does everything I wanted it to, and it is clear proof of concept that this method of creating that ripple effect does work.
Now... someone wanna help me speed it up a bit? :p
Re: So I whipped together a little app that basically ripples water
Um... so what did you do, exactly, to make it ripple? Are you just using GDI+ to do this(ACK!)?
Re: So I whipped together a little app that basically ripples water
Oh hell no. System.Runtime.InteropServices.Marshal.Copy() actually runs slightly faster than the bitmap pointers I had been using, and is a little easier to read, so that's what I went with. That, and a lot of math...
Re: So I whipped together a little app that basically ripples water
Why don't you post the code? I'd like to see it in action. You could put it in the code bank if you like.
Re: So I whipped together a little app that basically ripples water
Quote:
Originally Posted by
timeshifter
System.Runtime.InteropServices.Marshal.Copy() actually runs slightly faster than the bitmap pointers I had been using
Your pointer math does suck though, you have to take that into account.
Re: So I whipped together a little app that basically ripples water
Because I never did any real pointer math... care to educate me in yet another area?
Re: So I whipped together a little app that basically ripples water
Sure, post your project and we'll see what we can do. I've studied wave theory, so there's a chance I could help you optimise your math.
1 Attachment(s)
Re: So I whipped together a little app that basically ripples water
I haven't, and my math is merely the sum of my perception of loosely what's happening in a ripple. It's entirely possible that I'm completely off the mark in terms of true wave dynamics, but damnit, it looks cool :afrog:
1 Attachment(s)
Re: So I whipped together a little app that basically ripples water
Oi... just got the same system implemented for an isometric field instead of a pixel map... runs a heck of a lot faster and looks cooler, IMO. Sadly, I probably should spend the last three hours of the work day doing some actual work (I've been doing this all day), but maybe tonight I'll get around to adding some nice gradients based on height. The points in the array are associated with the vertexes here, not the cells... took a bit of trial and error before I finally got a single conditional which tests everything needed to determine if any given point should be the anchor for a cell...
EDIT: Oh, and if someone could figure out why the heck the app posted (and this new one) runs into that stupid stack overflow GDI+ error? I'm somewhat at a loss for what it's screaming about...
EDIT2: Got it. turns out the Stack Overflow was because I was driving the calculate loop with a timer (and the app clearly doesn't run at above 64 FPS), and disposing of the Graphics object every frame doubled the framerate...
Re: So I whipped together a little app that basically ripples water
Just updating the attachment above... added a couple new things, and this code should be pretty darn stable. At least, I haven't been able to make it crash.