Close Show/hide page

3D Sine Wave Study w/ Papervision3D

Thumbnail - Click me

A wavey liquid surface being hit by rocks.

For best performance, you’ll want to use the 9.0.60 version of Flash Player with a multi-core CPU. Press D to lower the level of detail if it’s killing your browser.

Other controls:

T cycles through different textures
B cycles through texture blend modes
W shows the 3D wireframe
+/- moves the camera in and out
Spacebar pauses the action, allowing you to rotate around the scene

Conceptually, here’s whats going on…

Each ’splash’ is a heightmap of z-values that correspond to the vertices of the plane (instance of the PV3D class Plane3D). For each value in the heightmap, we start with a sine function, where the ‘angle’ is the distance from the center of the splash plus an offset value that is incremented over time. Distance is also used to determine the sine wave’s decay. Finally, a multiplier variable going from 1 to 0 is used to flatten the heightmap over the life of the splash.



To make the plane look more dynamic, a wavey-looking heightmap is created (again, using Math.SIN) with some parameters for period and amplitude that decrease slowly, but increase when rocks hit the surface.

Each heightmap is then simply added to the z-values of the flat plane's vertices. (The x and y values stay constant).

Compiled with version 1.5 of Papervision3D, with rectangle culling enabled.

26 Responses to “3D Sine Wave Study w/ Papervision3D”

  1. Bela:

    Lee, once again you’ve come up with something amazing! You do know how to pull the best out of Papervision.

    I can’t wait to see what you come up with next.

  2. Lee:

    Thanks, Bela.

  3. Alias Cummins:

    Nice work!

  4. John Grden:

    That’s sick. Just sick.

  5. markval:

    the WOW factor is going up again!

    Nice Job!

  6. Mr.doob:

    Looks cool!

    Reminds me to this:
    http://www.pouet.net/prod.php?which=1239

    What about using this kind of materials on it?
    http://mrdoob.com/?postid=388

  7. Fardeen:

    Impressive ! Congrats !

  8. beastriker:

    Nice! really nice)) event though slow on my machine

  9. James:

    Very nice! Amazing what you can come up with. How are you creating your animated textures? Are they being imported in as image sequences? It seems to load too fast to be a looping image sequence.

  10. admin:

    James-

    The animation of the texture is done dynamically and isn’t ‘hardcoded’ using a sequence of bitmaps or an FLV. This is how it was is done:

    A first layer is animated by draw()’ing the bitmap to the TextureMaterial of the plane, with an offset value which increments with each frame. Another copy is drawn adjacent and to the ‘left’ of it so that it appears to keep repeating.

    The fun part comes when we do the same thing again (using the same bitmap), but this time using a BlendMode (hardlight by default) to create a second layer on top of the first. This second layer uses a separate offset value, and is flipped vertically for the sake of variation.

  11. harry:

    woaw :) real fysics. it’s starting to itch over here, I wanna make a game in flash :)

    keep this coming

  12. Resist:

    NOOB!!!! :)

  13. James:

    I really need to start diving into these blending options. I still have a hard time thinking in terms of bitmap effects in Flash. I’ve gone too long faking stuff, I need to break that habit. And I’m a traditional animator, who understands code, not a programmer by any stretch of the word. So everything I do is done the long way around, I frame by frame whatever I can.
    Thanks for the insight, and again, great stuff!

  14. Kalyan Katika:

    awesome!.

  15. xero / fontvir.us:

    \m/ pwnage!
    this looks great!

  16. Marcy_LH:

    nice work, real nice work…

    best regards

    Marcy

  17. Chris R:

    wow awseome! the detail settings are also a nice feature, when it is in die browser die! mode, both of my cores from my m90 laptop are almost fully used:P

  18. Chris R:

    ohw that was with the papiervison demo from pv itself running in the background.. hopefully there will be dualcore support within a single animation is build in in the future:)

  19. admin:

    Chris,

    If you have dual core CPU, install the most recent beta Flash Player, as it will, in fact, put both cores to use for a single piece of Flash.

    http://labs.adobe.com/technologies/flashplayer9/

    On CPU-heavy Flash pieces, I’ll get maybe a 50% increase in framerate using the new player.

    Lee

  20. Chris Greenfield:

    Hi Lee,

    This work has been really useful in explaining what I’m working on in my final year architecture project. I was wondering if you might be able to help me save hours and hours of arithmatic with your program?

    Can you please email me so I can describe the problem.

    Just to give you an idea, I’m working with sound waves, consonance and dissonance in music etc. and I’m using the waveform to generate a form in space where each node(like the little drops in your animation) represents a certain frequency (and wavelength). I’m trying to work out the interference pattern from that to get the form, but it’s very laborious! If I could somehow input some specific numbers and adjust the rules slightly (i.e. no decay), and then snapshot it at the point where I want to extract the 3D form, that would be REALLY helpful.

    Cheers, Chris.

  21. Mike:

    Are you planning on posting the source to this very wonderful piece of work?

  22. Cameron:

    Great work!

  23. Romantic:

    Nice!

  24. romantic:

    Nice work!

  25. 3d animation services:

    That is interesting. Thanks for sharing it.

  26. Source Code:

    “Are you planning on posting the source to this very wonderful piece of work?”

    x2

Leave a Reply