nintendo ds emulator for psp 3000 guitar chord chart printable desktop destroyer christmas version free download samsung moment vs htc hero vs palm pre wireless bridge linksys wrt54g2 cigarettes online how to install bluetooth dongle vista dodge charger forum dress up games for adults only free online jeep grand cherokee for sale xbox 360 secret achievements borderlands guitar tabs for hey there delilah mazda 3 speed turbo compaq laptops drivers free download winter olympics 2010 opening ceremonies tickets jeep wrangler for sale subaru impreza outback sport 2010 pontiac g8 gxp for sale canada laminate countertops price per square foot scanner software freeware mac tattoo ideas for girls galleries canon 7d firmware hack toyota yaris recall 2009 design your own wedding dress online game snowboard pants with suspenders tattoo removal cost estimate moviefone promotional code grasslands facts for kids notebook computers under 400 kawasaki atv repair manual download bmw forums e46 trucks for sale in pakistan pizza dough recipe for bread machine facebook chat emoticons ancient egyptian hieroglyphics for kids 2006 mazda 6 aftermarket parts bathroom wall tile ideas dodge viper srt 10 for sale rolex datejust price range famous people with dyslexia posters toyota tacoma prerunner 4x4 subaru forester 2010 accessories warcraft 3 image extractor 2 download student loan forgiveness obama nikon d90 video tutorial 1967 pontiac gto muscle car used porsche 911 for sale usa bathroom renovation ideas pictures 2005 kia sorento problems multiplayer rpgs for wii flash games 247 bike mania 4 kia soul price in egypt honda civic hatchback for sale software engineer salary india sony vaio laptops drivers chevrolet for sale medieval rpg flash games wedding invitations costco jaguar cars history infiniti g35 parts toyota center kennewick small bathroom renovation ideas pictures underwear drawer famous deaf people today satellite tv providers canada volkswagen passat for sale suzuki sx4 awd 2010 samsung mobile phones in india with price english dating sims for girls guitar tuner drop c carnival cruise fare codes mazda cx7 reviews 2009 auctions online michigan princess cut diamond and sapphire engagement rings satellite radio antenna booster fishing knots and rigs toyota recall list rav4 pants off dance off uk cheeky girls bob hope chrysler classic grassland animals pictures usb modem speed booster mitsubishi lancer forum malaysia keyboard stickers arabic cartridge world prices australia canon t1i video tips toyota tacoma recall rust frame how to debrand sony ericsson c905a wifi hyundai santa fe reviews 2009 samsung mythic a897 avery templates for business cards fishing reports california delta website builder freeware dvdfab 6 registration keygen mazda miata hardtop sale famous short friendship poems snowboarding jackets on sale in canada rolex watches for women bathroom cabinets and vanities ikea keyboard shortcuts symbols music note compaq evo drivers free download volkswagen beetle parts catalog snowboarding gloves grenade bruce laminate floors reviews cruise critic chrysler crossfire srt6 convertible suzuki oem motorcycle parts basketball plays flex offense snowboard boots and bindings canon powershot g11 accessories porsche cayenne 2010 model memory foam dog bed seen on tv cablevision channel guide bronx pontiac gto judge wallpaper suzuki sx4 crossover reviews camcorder buying guide india dress up who betty boop subaru legacy gt bathroom shower tile ideas volkswagen beetle accessories bmw financial services go green sweepstakes replica coach purses wholesale ticketmaster promo codes portrait photography tips lighting samsung led tv 6000 2001 chrysler town and country parts diagram hyundai sonata 2010 picture grassland animals and their adaptations bmw m3 gtr printer drivers epson r200 pontiac grand prix gxp mitsubishi outlander forum yamaha vintage snowmobiles lexus rx 350 recalls kia sorento 2011 canada funny winter solstice quotes dress up barbie kitchen glass tile backsplash pictures receiver hitch winch mitsubishi lancer forum canada subaru sti 2010 sedan basketball drills for 6 year olds saturn sl performance parts used mitsubishi evo 9 for sale desktop destroyer 2 grassland animals facts guitar chord chart pdf rpg maker vx resources pack porsche forums usa saturn astra performance parts skype download for blackberry 8900 truck accessories san antonio texas guitar pro 6 torrent download ventrilo server status script on your website bluetooth headset for ipod touch 3rd gen replica louis vuitton belts buy converse shoes online cheap sony vegas movie studio 9 keygen compaq presario cq60 drivers for windows 7 laura ashley laminate flooring installation instructions dodge caliber problems compaq presario f700 drivers for windows xp lands end coupon code 20 off gift ideas for boyfriend microsoft templates online desktop destroyer game christmassy rolex oyster perpetual cosmograph daytona price bridesmaid dresses plus size indesign templates for business cards free logo creator freeware volkswagen beetle engine codes northface denali jackets on sale for women wedding cakes and prices desktop destroyer toyota and lexus recall 2009 free dating websites for single parents samsung eternity games saw video game walkthrough guide subaru impreza wrx for sale in pa compaq presario cq50 drivers for vista bmw financial services phone number mitsubishi lancer parts diagram subaru outback 2010 price toyota recall list november 2009 bathroom ideas for small spaces software testing tutorial download toyota floor mat recall list bmw x5 aftermarket parts opelousas general hospital baby pictures samsung plasma tv calibration hand blown glass pipes bongs tattoos for girls on hip 2010 volkswagen gti reliability nissan leaf specs software engineering interview questions with answers truck games download free bmw usa factory exact replica louis vuitton handbags sample wedding vows write your own compaq c700 infinity ward host migration problems honda accord crosstour commercial song rolex daytona price 2009 kia cars usa sawgrass mills mall directory wedding dresses 2010 pictures rolex watches models bmw x5 e70 forum templates for resumes and cover letters cablevision channel guide nj cadillac cts v coupe toyota corolla parts porsche boxster spyder 2011 compaq presario v3000 drivers for vista gps maps free download cyprus xbox 360 repair center animation factory rapidshare hd screensavers for mac free printer ink cartridges refill playstation roms torrent roses are red jokes basketball reference police scanner radio frequencies warcraft 3 frozen throne cd key buy rolex serial numbers chart best backpacks for college 2009 hyundai accent 2010 pictures jeanstar jeans retailers 2010 porsche panamera hybrid bathroom accessories unlimited tattoo fonts cursive generator infinity ward nat settings winter 2010 olympics opening ceremony jeeps for sale in alabama skype for blackberry curve 8520 wallpaper desktop widescreen suzuki 2010 motorcycles release date limewire pro free mac os x bluetooth headphones ps3 use printer offline error processing command scanner reviews 2009 cnet guitar scales pdf free download toyota financial repossession software testing life cycle ppt kia motors philippines kitchen islands on wheels opel astra 2010 model lexus suv hybrid 2010 hyundai santa fe forum uk laminate countertops home depot subaru baja tonneau wow cataclysm beta download samsung omnia i910 mazda 323 forum honda accord forum malaysia subaru wrx 2010 pictures recipes for ground beef meatballs porsche cayenne 2010 spy shots play gamecube iso on wii usb trucks gone wild carp fishing games free online lexus rx 350 recall bathroom vanity ideas fishing boats for sale in california guitar hero online keyboard guitar center used gear pontiac solstice hardtop convertible wowhead gatherer database wireless router setup with comcast ford edge forum jeeps for sale by owner bathroom sinks modern microsoft bluetooth dongle vista driver hummer accessories in dubai volkswagen jetta tdi 2010 review perfume emporium uk kia forte koup turbo charger gamecube emulator mac os off road tires and wheels packages mazda tribute forum bathroom floor tile size trucks for sale by owner in florida gamecube emulator games playstation 2 emulator bios plugins jackets with fur hoods for men furniture factory outlet nj roses are red violets are blue love poems funny quotes and sayings for facebook dodge charger parts diagram toyota recall gas pedal sticking volkswagen beetle parts bathroom flooring ideas summer glau underwear marriage vows samples snowboard sizing chart by weight honda accord for sale cheap furniture liquidators baton rouge louisiana antique bicycles western flyer pocket tanks deluxe download free subaru legacy 2010 screensavers free downloads for phones rolex daytona gold egyptian love symbols skype video conference 3 way chrysler town and country parts diagram bicycle parts warehouse dvd decrypter windows 7 tattoos for guys helmet decals racing cablevision channel lineup bicycle outlet warehouse nissan cars for sale in sri lanka mitsubishi evo for sale mercedes benz forum singapore how much does siding cost per square foot pizza hut hawaii coupon code playstation support rolex watches price escuchar radio online mexico replica toy guns australia common chrysler pacifica problems volkswagen gti r playstation store redeem codes for psp rpg online games flash marriage statistics 2009 uk jacket size chart women music theory for dummies pdf bathroom designs for small spaces tattoo removal cost hyundai tiburon performance parts mitsubishi outlander 2009 accessories samsung solstice games free mazda parts diagram bridesmaid hairstyles pictures 2009 basketball court dimensions youth background music for video editing fake rolex submariner watch suzuki 50cc atv for sale backgrounds for computer for kids mitsubishi lancer for sale in bangalore 95 saturn sl2 parts pitbull protection kia sorento 2010 interior music theory worksheets note values gamecube emulator mac torrent laptop bags for men famous american artists 19th century mercedes sl amg wheels volkswagen parts people toyota brake recall 2009 opel astra diesel hybrid cameras at walmart canada pool table dimensions wiki designer indian wedding dresses dating sim games anime jeep golden eagle for sale zte modem drivers for windows 7 samsung rogue software for pc rolex watches truck paper classified driver software refacing fireplace pictures snowboard size chart for men desktopx themes toyota forklift parts online roses are red poems skype download for blackberry 8520 subaru outback 2010 accessories free laundromat business jaguar v12 performance parts compaq presario v2000 drivers for windows 7 apartments in atlanta ga based on income guitar pro torrent suzuki sx4 turbo famous sad love poems basketball court dimensions in feet used server racks atlanta kia motors philippines website bathroom remodeling ideas for small bathrooms famous french artists of the 19th century webmail hack software downloads free rolex oyster perpetual datejust xbox 360 oblivion cheats nikon coolpix s220 speed dating questions for men co ed episiode download jeans size chart furniture liquidators chicago il wallpaper borders for kids rooms mazda tribute reviews 2002 laminate flooring installation video motorola h500 samsung rogue verizon forum jewelry supplies wholesale nyc bluetooth software for windows xp sp3 plant cell structure worksheet mercedes benz e class convertible 2010 famous computer crime cases logo creator free download samsung rogue manual download contemporary bathroom lighting ideas free fake diploma software winter jackets for petite women tires plus coupon is samsung solstice wifi mattresses cheap juice plus ingredients dating dress up games for girls mid length hair styles sealed cork floor tiles top 20 wedding ceremony entrance songs porsche 911 forum gmc sierra denali 2010 aluminum siding brakes for sale mazda5 review subwoofer enclosures diy keyboards for macbook pro canon printers troubleshooting download ruby rom mazda 626 parts diagram pontiac g8 gxp review recipes for pork chops underwear for men pouch portfolio lighting fixtures lowes bathroom vanities and cabinets lowes roses are red violets are blue poems for children roses are red violets are blue funny love strelske igre download multiplayer wedding invitations templates free update evolution soccer download free printers for sale at costco dress up celebrities boys and girls samsung solstice apps download clothes over bros dresses program dish tv remote codes snowboard sizing chart for kids xbox 360 elite specs antivirus torrent free microsoft office download full version ford models europe sony vegas download mac best perfumes with pheromones layouts for bikerornot auto loan calculator excel spreadsheet designer wedding dresses games for girls free spanish games pes download subaru tribeca owners forum warcraft 3 cd key samsung dlp tv repair manual jeans size chart boys sven download tattoo cursive lettering quickheal antivirus software swf games snow harley davidson oem parts fiche samsung eternity manual download printer drivers epson r300 ford escape mileage sony ericsson k800i symbols on screen download cd key for cod2 guitar chord linux netbook distro comparison backgrounds for powerpoint microsoft snowboarding gloves with built in wrist guards wireless n gigabit router reviews subaru club volkswagen passat diesel problems bathroom vanities discount toronto juniper credit samsung led tv manual bluetooth headset ps3 pass key garden twist pattern ground turkey recipes food network famous poems about death of a loved one cables unlimited wireless usb adapter kit chevrolet camaro price in india digital cable filter trucks for sale by owner in illinois shirt design template funny marriage quotes and sayings jaguar xj220 for sale compaq presario r3000 drivers download handheld gps comparison guide black hair cuts compaq presario cq60 drivers for vista cadillac srx 2010 commercial song jeeps for sale cigarette rolling machine auto parts warehouse coupon code rock island auction samsung lcd tv models india pizza sauce recipes epicurious summer fashion internships gmc acadia forum samsung eternity software for mac nail art step step cadillac srx commercial song falling samsung pn50b650 plasma tv mitsubishi tv manual download auction sites like ebay dress up celebrities for girls best type of carpeting for stairs


Tag Archive for 'Explode Image'

Papervision Explode Image / Rebuild

In early 2008 I wrote a blog article on how to explode an image and rebuild it again. Recently this effect has been used in some amazing ways. Site's like Audi have taken this concept much further with the rows of these tiny boxes swimming in formation.

Today I decided to re-create that simple effect using the latest papervision code and provide a much needed update.

Creating this effect is actually fairly simple. You take an image, use some code to break it into smaller bitmaps which then are used as the materials for your planes. Then you just place the planes in a grid to re-create your image.

Here is a sample of the code that get's our image blocks to be used for our materials:

Actionscript:
  1. //Creates a 30 x 18 bitmapData block
  2. var bitmap_data:BitmapData  = new BitmapData(cellWidth, cellHeight, true, 0x00FFFF);
  3.                
  4. //Create a new Matrix - A matrix is a rectangular array / table
  5. //of numbers with any number of rows / columns.
  6. var matrix:Matrix         = new Matrix();
  7.  
  8. //Get's our desired x / y location information where we will
  9. //pull a block of our image
  10. matrix.translate( -cellWidth * cellX, -cellHeight * cellY);
  11.  
  12. //Write the data to our bitmap data object with our source and
  13. //matrix / block info
  14. bitmap_data.draw(imageMC, matrix);

Once you've created your grid you just need to store the locations of all your x,y,z,rotation etc so that when you break apart the image you can easily piece it back together.

Actionscript:
  1. planeVO.origX         = pl.x;
  2. planeVO.origY            = pl.y;
  3. planeVO.origZ         = pl.z;
  4. planeVO.origRotationY      = pl.rotationY;
  5. planeVO.origRotationX      = pl.rotationX;
  6. planeVO.origRotationZ      = pl.rotationZ;
  7. planeVO.planeRef          = pl;

PlaneVO is nothing more than a simple value object. A value object gives us a nice strongly typed object to store the variables we want to access later.

PlaneVO.as

Actionscript:
  1. package
  2. {
  3.     import org.papervision3d.objects.primitives.Plane;
  4.     /**
  5.      * ...
  6.      * @author Charlie Schulze, Woven Interactive, LLC
  7.      */
  8.     public class PlaneVO
  9.     {
  10.         public var origX:Number;
  11.         public var origY:Number
  12.         public var origZ:Number
  13.         public var origRotationY:Number
  14.         public var origRotationX:Number
  15.         public var origRotationZ:Number
  16.         public var planeRef:Plane;
  17.     }
  18.    
  19. }

Now on to the full code. I have left comments throughout to explain what is happening. Try changing some of the math or swapping the image with your own. Once you mess with it for a little while you'll find it's easy to create some amazing effects.

Actionscript:
  1. package
  2. {
  3.     import br.com.stimuli.loading.BulkLoader;
  4.     import br.com.stimuli.loading.BulkProgressEvent;
  5.     import com.foomonger.utils.Later;
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.DisplayObject;
  9.     import flash.display.MovieClip;
  10.     import flash.geom.Matrix;
  11.     import gs.easing.Quint;
  12.     import gs.TweenMax;
  13.     import org.papervision3d.materials.MovieMaterial;
  14.     import org.papervision3d.objects.DisplayObject3D;
  15.     import org.papervision3d.objects.primitives.Plane;
  16.     import org.papervision3d.view.BasicView;
  17.    
  18.     /**
  19.      * ...
  20.      * @author Charlie Schulze, charlie[at]woveninteractive[dot]com
  21.      */
  22.    
  23.     public class Main extends BasicView
  24.     {
  25.         protected var bulkInstance:BulkLoader;
  26.         protected var imageMC:MovieClip;
  27.         protected var imageString:String
  28.         protected var planeVOs:Array = [];
  29.         protected var planesContainer:DisplayObject3D;
  30.        
  31.         public function Main():void
  32.         {
  33.             super();
  34.            
  35.             //Set the image we want to load
  36.             imageString  = "images/king.gif";
  37.            
  38.             //Load our image
  39.             loadImage();
  40.         }
  41.         protected function loadImage():void
  42.         {
  43.             //BulkLoader is complete overkill for this but thought it would be a
  44.             //nice extra for everyone to see in action. Extremely useful set of classes.
  45.            
  46.             //Create our unique bulkInstance / available anywhere in our app by
  47.             //that name "bulkImageLoader"
  48.             bulkInstance = new BulkLoader("bulkImageLoader");
  49.            
  50.             //Add our image
  51.             bulkInstance.add(imageString);
  52.            
  53.             //Add our listeners
  54.             bulkInstance.addEventListener(BulkProgressEvent.COMPLETE, onImageLoaded);
  55.            
  56.             //Start Loading
  57.             bulkInstance.start();
  58.         }
  59.         protected function onImageLoaded(evt:BulkProgressEvent):void
  60.         {
  61.             init();
  62.         }
  63.         protected function init():void
  64.         {
  65.             createChildren();
  66.             explode();
  67.             startRendering();
  68.         }
  69.        
  70.         protected function createChildren():void
  71.         {
  72.             //Create the clip we will be getting our bitmap data from
  73.             imageMC = new MovieClip();
  74.            
  75.             //add our bitmap
  76.             imageMC.addChild(bulkInstance.getBitmap(imageString));
  77.  
  78.             //Optional - Create a container to hold our planes
  79.             planesContainer = new DisplayObject3D();
  80.            
  81.             //Array to store our value objects
  82.             planeVOs = [];
  83.            
  84.             for (var i:int = 0; i <65; i++)
  85.             {
  86.                 /**
  87.                  * Here is how we get our loop / colunm / cellWidth / cellHeight numbers
  88.                  *
  89.                  * 5 columns * 13 rows = 65 (number of loops)
  90.                  * 5 columns divided by the width (150) of our image = 30 pixels
  91.                  * 13 rows  divided by the height (234) of our image = 18 pixels
  92.                  */
  93.  
  94.                 var columns:uint          = 5;
  95.                 var cellWidth:int       = 30;
  96.                 var cellHeight:int    = 18;
  97.                 var cellX:int         = (i % columns)
  98.                 var cellY:int         = Math.floor(i / columns);
  99.  
  100.                 //Creates a 30 x 18 bitmapData block
  101.                 var bitmap_data:BitmapData  = new BitmapData(cellWidth, cellHeight, true, 0x00FFFF);
  102.                
  103.                 //Create a new Matrix - A matrix is a rectangular array / table
  104.                 //of numbers with any number of rows / columns.
  105.                 var matrix:Matrix         = new Matrix();
  106.                
  107.                 //Get's our desired x / y location information where we will
  108.                 //pull a block of our image
  109.                 matrix.translate( -cellWidth * cellX, -cellHeight * cellY);
  110.                
  111.                 //Write the data to our bitmap data object with our source and
  112.                 //matrix / block info
  113.                 bitmap_data.draw(imageMC, matrix);
  114.                
  115.                 //Create a bitmap with our bitmapData and add it to a movieclip
  116.                 var bitmap:Bitmap       = new Bitmap(bitmap_data);
  117.                 var myMovie:MovieClip     = new MovieClip();
  118.                
  119.                 myMovie.addChild(bitmap);
  120.                
  121.                 //Use the movieclip with our bitmap inside as our movieMaterial
  122.                 //needs to be cast as a DisplayObject to work
  123.                 var movieMat:MovieMaterial  = new MovieMaterial(myMovie as DisplayObject, true);
  124.                 movieMat.smooth             = true;
  125.                
  126.                 //Create a plane with our moviemat the size of our cellWidth/Height
  127.                 var pl:Plane             = new Plane(movieMat, cellWidth, cellHeight, 0, 0);
  128.                
  129.                 //Create a value object to store our origianl infomation
  130.                 //for when we animate we can then rebuild easily
  131.                 var planeVO:PlaneVO         = new PlaneVO();
  132.  
  133.                 //We want to place the planes to re-create our original image
  134.                 pl.x                        = ((cellX * cellWidth) + cellWidth) -(imageMC.width / 2);
  135.                 pl.y                   = -((cellY * cellHeight) + cellHeight) +(imageMC.height / 2);
  136.                
  137.                 //Set the original properties of our value object
  138.                 planeVO.origX         = pl.x;
  139.                 planeVO.origY            = pl.y;
  140.                 planeVO.origZ         = pl.z;
  141.                 planeVO.origRotationY      = pl.rotationY;
  142.                 planeVO.origRotationX      = pl.rotationX;
  143.                 planeVO.origRotationZ      = pl.rotationZ;
  144.                 planeVO.planeRef          = pl;
  145.                
  146.                 //Add our planeVO to our array
  147.                 planeVOs.push(planeVO)
  148.                
  149.                 //Add planes to our container
  150.                 planesContainer.addChild(pl);            
  151.             }
  152.            
  153.             //Add our container to our scene
  154.             scene.addChild(planesContainer);
  155.            
  156.             camera.zoom = 100;
  157.            
  158.             //rotate our container for an skewed effect
  159.             planesContainer.rotationY = 30;
  160.             planesContainer.rotationX = 30;
  161.         }
  162.        
  163.         protected function explode():void
  164.         {
  165.             //Create a for loop of our plane objects set random numbers to explode our image
  166.            
  167.             for (var i:int = 0; i <planeVOs.length; i++)
  168.             {
  169.                 var planeVO:PlaneVO     = planeVOs[i];
  170.                 var plane:Plane         = planeVO.planeRef;
  171.                
  172.                 var ranNumber:Number = Math.round(Math.random() * 200 - 200);
  173.                 var delayAmount:Number = i * .05;
  174.                 var shortDelayAmount:Number = delayAmount * .6;
  175.                
  176.                 var randomX:Number = (Math.random() * 4000) - 6000;
  177.                 var randomY:Number = (Math.random() * 8000) - 1000;
  178.                 var randomZ:Number = (Math.random() * 1000) + 5000;
  179.  
  180.                 TweenMax.to(plane, 2, { x:planeVO.origX + randomX, delay:shortDelayAmount,
  181.                                         z:randomZ, y:150 + planeVO.origY + randomY,
  182.                                         rotationY:180,ease:Quint.easeInOut} );
  183.             }
  184.            
  185.             //In 3 seconds rebuild
  186.             Later.call(this, rebuild, 3000, true);
  187.         }
  188.        
  189.         protected function rebuild():void
  190.         {
  191.             //Rebuild our image with the locations we stored in our VO
  192.            
  193.             for (var i:int = 0; i <planeVOs.length; i++)
  194.             {
  195.                 var planeVO:PlaneVO     = planeVOs[i];
  196.                 var plane:Plane         = planeVO.planeRef;
  197.                 var delayAmount:Number  = i * .005;
  198.                 TweenMax.to(plane, 1.8, { x:planeVO.origX, delay:delayAmount,
  199.                                         z:planeVO.origZ, y:planeVO.origY,
  200.                                         rotationY:planeVO.origRotationY,ease:Quint.easeInOut} );
  201.             }
  202.            
  203.             //In 5 seconds explode the image again
  204.             Later.call(this, explode, 5000, true);
  205.         }
  206.     }
  207. }

Post to Twitter Post to Delicious Delicious Post to Digg Digg This Post Post to Facebook Facebook Post to StumbleUpon Stumble This Post


Follow papervision2 on Twitter

Flash and the City banner
2010 Flash And The City Speaker

RSS Feed