Skip to content

August 10, 2007

57

The Magic Carpet

>> Looking for the source code? Just go the next post here<<

I managed to have some time to put together the simulation i was talking about last week: roughly based on a “Flade” (now APE) demo of that time, it makes use of APE for the physics and Papervision3D for the rasterization process.
Actually, using PV3D for merely rasterizing polygons its obviously an ugly solution if you, like me, don’t need all the scene management and just need to stretch bitmaps around: the real reason behind that choice is simply i was curious to see (1) how PV3D performed in a similar situation and (2) how to be able to bind APE and PV3D together.
Anyway, just modelling and simulating the carpet wasn’t enough: the motion were great and performing quite well, but it was lacking completely the sense and taste of realism one would expect from such a scene and the particular type of motion one can interact with.
I started by adding a (really) fake shadow that i’m too lazy to change and, since then, i liked the idea and adding a reflection was the next logical step for that context: it was still lacking some motion “feeling” so i also tried to mimic a directional blur simply by programmatically reducing the amount of blur on the slowest x-y direction.

I stopped experimenting with the blur thing, but i think it could be somewhat enhanced: i was thinking about a 3×3 / 5×5 kernel convolution filter in order to enhance angular motion, but i really have no time to try this out… do you know if this has been already attempted before?
Anyway, beside having a carpet pinned in a void chamber, although funny and nice to interact with, the scene lighting and colors weren’t so exciting, so i decided to play with bitmaps and filters with realtime compositing and post-processing in mind, eventually ending up with a bloom-like filter that seems to be able to enhance the imagery quite well.

The UI will permit to adjust the values of the simulation, output, effects and post-processing: since the computations can be really heavy and stopping the VM from working, an automatic adjustment of the physics integration timestep is enabled by default and it will look green/red when working for you, meaning respectively it’s raising/lowering the timestep.

During the development i’ve tried different versions of the Flash Player and here are the results:

- 9.0.459.0.47: on my machine i got something like 50fps with the default settings, some glitches can occur when changing the “Simulation” tab’s settings and i rarely got a Flash Player crash;

- 9.0.60.120: i got 60/65fps with default settings, no glitches occurs while modifying “Simulation” values and no crashes directly correlated with this have occured. There is a really odd behavior of the Flash Player btw, where a vertical band on the left can be seen when playing with the carpet smashing it from right to left: the vertical band’s width seems to be related to the position of the carpet but i’m still investigating that; playing with the carpet on the vertical band DOES hang the Flash Player. Hope to be able to tell more info on that: in the meantime, turning off the post-processing will prevent the problems from happening.

As a final note, i highly recommend to install the latest beta of the Flash Player since the performance really got a boost.

Let me know how it works for you: also, i plan to release the source code for both the demo and my modified version of APE (to let it to work with a fixed timestep expressed in Hz) so i’ll update these pages pretty soon.

57 Comments Post a comment
  1. Aug 21 2007

    Man, this is really amazing!!! Respect!

  2. Paul
    Aug 21 2007

    Totally owsome! Man, you rule!

  3. Aug 21 2007

    Amazing only starts to cover it…this freaking ROCKS \m/

  4. Aug 21 2007

    Hey big thanks for your feedback!

  5. Aug 21 2007

    Brilliant work. Even the shadows/blurs/reflections look gorgeous. And the source code to boot! Excellent contribution.

  6. Aug 21 2007

    Its magic! Well done, didn’t see a lot using APE (yet) with PaperVision 3D.

  7. Aug 22 2007

    god…, don’t stop doing this!

  8. Aug 22 2007

    Great work!!! This is a great idea! I especially liked the fact that the simulation is “careful” not to crash flash and auto adjusts. Once again, great work, keep it up!

  9. George
    Aug 22 2007

    great stuff

  10. Aug 24 2007

    I’m incredibly impressed by the performance. The postprocessing is what really makes this demo shine– I’m curious about what you used for the bloom effect. That, in combination with the motion blur, really takes it to the next level. I’ve played around with APE and found the API pleasantly simple yet powerful. Still have yet to get in depth with PV3D though!

    Kudos^100 to you!! And I must say, kudos to the new AVM developers, the performance boosts are some excellent work.

  11. Bl4deRunner
    Aug 27 2007

    This is really totally awsome! Adobe should have a talk with you!

  12. Aug 27 2007

    alec cove not alex cove

  13. Aug 29 2007

    What I don’t get…what I’m trying to understand from the code, having not ever used APE…is how you’re deriving the z coordinates. Making a point mesh was a great call for fabrics, etc…. it’s a really fantastic demo. But how are you getting the z for the points, or are they just falling through z to zero at a static rate of acceleration irregardless of their adjoining points?

  14. Aug 29 2007

    Beh, complimenti per la naturalezza del movimento e per la resa complessiva!

  15. Aug 30 2007

    All my respect ! Thanks for sharing it!

  16. chafe nest
    Aug 31 2007

    damn man. good work.

  17. Ciccio
    Sep 3 2007

    You are an hero! Brao vecio

  18. Sep 5 2007

    excellent !
    good work.

  19. Sep 13 2007

    this is really excellent!

  20. Sep 18 2007

    I never thought this could be done with Flash. At first, I hated what Adobe did with Actionscript, but maybe it’s replacing Java once and for all

  21. Oct 13 2007

    This is amazing! Great work!!!

  22. think!!
    Oct 14 2007

    amazing, respect.

  23. Chris
    Oct 30 2007

    blown away!

  24. Y-man
    Oct 30 2007

    really cool!
    but why doesn’t thi carpet roll up when spinnin’ or i don get smth ?
    anyway this’s awesome plz don’t stop )

  25. pv3d newbie
    Nov 13 2007

    how do you open thsi file what is a project file and ACTIONSCRIPTPROPERTIES File

  26. Dec 3 2007

    where’s source code?thanks

  27. Dec 5 2007

    Nice work. Keep going same way.

  28. idefix
    Dec 12 2007

    Man, this is just beautiful. I’m stunned. Really. You really got me enthusiastic to start working on 3d physics in flash. I haven’t done a lot of work with AS3 (my company wants me to work in AS2 for now), but I’m definitely going to dive deep into it now. Are you planning on releasing the source code anytime? It’s gonna be a really big help and inspiration for a lot of people I’m sure. Great work again. Compliments.

  29. Dec 13 2007

    @idefix and @ryan

    I’m happy you’ll start digging into physics and Flash, and sure you can take a look to the source code at http://manuel.bit-fire.com/2007/08/11/carpets-sources/

  30. Octopus
    Dec 14 2007

    Finally, a papervision3D demo that is not disappointing! Of course it’s the (APE) physics that make this impressive. And after spending several hours perusing the web for Papervision3D demos this is the first one I’ve come across that truly impresses me! Great job!

  31. Dr.flash
    Jan 4 2008

    wow……………………………..

  32. Jim
    Jan 29 2008

    that is very, very good.
    i stublemed onto this looking for carpet related blog posts.

    my friend matt askey had a very different experience with the carpet on the floor of my kitchen this weekend.

    That has very little to do with you post though so i appologise, but again the flash & Physics is impressive to say the least.

    Jim

  33. nice effect

  34. Exey
    Feb 5 2008

    Thanx, very inspiring!
    Manuel, Xero. I tried to porting Magic Carpet on GreatWhite, it working but not right, because i got into muddle in new pv3d20′s center coordinates point, i hardcoded it:

    in Simulator.as > CenterMesh():
    var x: int = ( Configuration.OUTPUT_WIDTH – aWidth ) / 2. – Configuration.OUTPUT_WIDTH/2;
    var y: int = 50 – Configuration.OUTPUT_HEIGHT/2;

    in ParticlePicker.as > tick():
    pickedParticle.px = Resources.theStage.mouseX – Configuration.OUTPUT_WIDTH/2;
    pickedParticle.py = Resources.theStage.mouseY – Configuration.OUTPUT_HEIGHT/2;

    Where is else need to fix coordinate point?
    http://exey.ru/MagicCarpet_pv3d20.zip

  35. Mar 3 2008

    Nice work

  36. Sep 11 2008

    awesome effect ,i like it

  37. Sep 17 2008

    Great effect, where did you learned this dude

  38. Oct 10 2008

    Wow, I just love this, and I cannot imagine the amount of work! I just got started with Papervision 3D. I am interested in getting something liek this on my site. if you go to http://www.blindmanstudio.com you will see my site’s logo/avatar ont he top. he is a collada model. There is a blindfold on him with a piece hanging off the back. I was wondering would it be at all possible to get a cloth sim going on that piece? and keep it attached to him?

    if you could please give me some feedback on the possibility of this, I will be looking at the source code to try and figure it out int he meantime…

    if you are willing to help, my contact info is on my site!
    and thanks again for giving the source on this, SO much I can learn from it!

  39. Oct 27 2008

    Great work.

  40. Nov 14 2008

    Thanks for the information. It would be nice if more people commented on this topic. It’s not too confusing if you read and understand then please teach what your learning..

  41. lee
    Aug 21 2011

    Description Resource Path Location Type 1137: Incorrect number of arguments. Expected no more than 0.
    AbstractParticle.as /MagicCarpet2/org/cove/ape line 88 Flex Problem
    .
    .
    .


    curr = new Vector(x, y);
    prev = new Vector(x, y);
    code error.?

    Using… flash builder 4, flex sdk 4.5.1

  42. Manuel
    Aug 21 2011

    @lee, i don’t know if this code still compiles fine with the latest version, it looks like the parameterized constructor isn’t there for the Vector type..

  43. lee
    Aug 22 2011

    Hello.
    You made it a very good magic carpet.
    I strive to do this operation, but failed.
    We got a problem in the following.

    ex1) error
    curr = new Vector (x, y);
    prev = new Vector (x, y);

    ex2) pass
    curr = new Vector ();
    prev = new Vector ();

    My development environment is as follows.
    flash builder 4, flex sdk 4,1 or 4.5

    As shown by testing the development environment to my email please.

    Thank you.

Trackbacks & Pingbacks

  1. Magic Carpet « Papervision3D
  2. Fábio Pedrosa » Magic Carpet
  3. links for 2007-08-23 « Simply… A User
  4. top paper vision demos - Graphic Design Forum and Web Design Forum
  5. The Magic Carpet » Darren Richardson
  6. The Magic Carpet
  7. listtoday
  8. blog.nm-graefen » Blog Archive » Manuel Bua - The Magic Carpet
  9. Home of a Risktaker | Hikmat b. Iskandar - Malaysian Web Designer. Software Developer. » Holy %@#$, this is Flash!
  10. blog.ad2.com » Blog Archive » Magic Carpet Ride
  11. Compiz-like wobbling windows in AS3  —  Manuel’s Coding Blog
  12. Interface Design » Manuel Bua’s Magic Carpet
  13. sonson
  14. Le Tapis magique - Noevia.com

Share your thoughts, post a comment.

(required)
(required)

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments