{"id":29,"date":"2009-06-16T00:08:00","date_gmt":"2009-06-16T07:08:00","guid":{"rendered":"http:\/\/www.patrickmatte.com\/?p=29"},"modified":"2015-11-07T17:04:26","modified_gmt":"2015-11-08T00:04:26","slug":"simulating-liquid-with-a-physics-engine-in-actionscript-3","status":"publish","type":"post","link":"https:\/\/www.patrickmatte.com\/?p=29","title":{"rendered":"Fluid simulation with physics"},"content":{"rendered":"<div class=\"text\">\n<div class=\"columnLeft\">I created a quick prototype of a realtime liquid simulation for a project over at Chiat a couple weeks ago. The result might not be very realistic, a little cartoony you might say, but it&#8217;s definitely fun to play with (any program that features real-time physics just fascinates me). I made a quick demo to show you how it&#8217;s done.<\/p>\n<p>I took a look at some <a href=\"http:\/\/geekglue.blogspot.com\/2008\/01\/actionscript-2d-physics-engines.html\" target=\"_blank\">reviews<\/a> to choose the physics engine I would use and <a href=\"http:\/\/www.cove.org\/ape\/\" target=\"_blank\">APE<\/a> seemed to be the easiest one. It was pretty simple indeed as I was able to build my original demo in a single day. <\/div>\n<div class=\"columnRight\">It was a little tricky to create the physics bottle that would hold the particles. The easiest way I found was to put movieclips on stage in the shape of the bottle and loop through each pieces and create a corresponding APE RectangleParticule. The tricky part is that when you rotate a movieclip in Flash, the height and width of the clip changes, so i had to nest a movieclip within to be able to read the correct height and width of the particle.<\/p>\n<p><a href=\"http:\/\/www.patrickmatte.com\/stuff\/physicsLiquid\/flash.zip\">Download the source<\/a><\/div>\n<\/div>\n<p><iframe id=\"entry-header\" scrolling=\"no\" style=\"position:relative; width:100%; height:600px; margin:0 auto\" src=\"http:\/\/www.patrickmatte.com\/stuff\/physicsLiquid\/\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I created a quick prototype of a realtime liquid simulation for a project over at Chiat a couple weeks ago. The result might not be very realistic, a little cartoony you might say, but it&#8217;s definitely fun to play with (any program that features real-time physics just fascinates me). I made a quick demo to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":650,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[20,21],"class_list":["post-29","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-experiments","tag-flash","tag-physics"],"_links":{"self":[{"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/posts\/29"}],"collection":[{"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":36,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":818,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions\/818"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=\/wp\/v2\/media\/650"}],"wp:attachment":[{"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patrickmatte.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}