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.45 – 9.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.
Trackbacks & Pingbacks
- Magic Carpet « Papervision3D
- Fábio Pedrosa » Magic Carpet
- links for 2007-08-23 « Simply… A User
- top paper vision demos - Graphic Design Forum and Web Design Forum
- The Magic Carpet » Darren Richardson
- The Magic Carpet
- listtoday
- blog.nm-graefen » Blog Archive » Manuel Bua - The Magic Carpet
- Home of a Risktaker | Hikmat b. Iskandar - Malaysian Web Designer. Software Developer. » Holy %@#$, this is Flash!
- blog.ad2.com » Blog Archive » Magic Carpet Ride
- Compiz-like wobbling windows in AS3 — Manuel’s Coding Blog
- Interface Design » Manuel Bua’s Magic Carpet
- sonson
- Le Tapis magique - Noevia.com

Man, this is really amazing!!! Respect!
Totally owsome! Man, you rule!
Amazing only starts to cover it…this freaking ROCKS \m/
Hey big thanks for your feedback!
Brilliant work. Even the shadows/blurs/reflections look gorgeous. And the source code to boot! Excellent contribution.
Its magic! Well done, didn’t see a lot using APE (yet) with PaperVision 3D.
god…, don’t stop doing this!
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!
great stuff
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.
This is really totally awsome! Adobe should have a talk with you!
alec cove not alex cove
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?
Beh, complimenti per la naturalezza del movimento e per la resa complessiva!
All my respect ! Thanks for sharing it!
damn man. good work.
You are an hero! Brao vecio
excellent !
good work.
this is really excellent!
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
This is amazing! Great work!!!
amazing, respect.
blown away!
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 )
how do you open thsi file what is a project file and ACTIONSCRIPTPROPERTIES File
where’s source code?thanks
Nice work. Keep going same way.
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.
@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/
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!
wow……………………………..
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
nice effect
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
Nice work
awesome effect ,i like it
Great effect, where did you learned this dude
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!
Great work.
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..
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
@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..
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.