Thanks Alexandar, this is great. How far off are you from having an interactive MovieMaterial? I took a look at the standard Away3D MovieMaterial in the hopes that I could bring that functionality to your class above, but I'm not certain what aspects of it enable the interactivity of the passed MovieClip. I'd really like to get this figured out but unfortunately it's a bit over my head!
Thanks, Casey On Oct 14, 10:40 pm, Alexander <[email protected]> wrote: > It's not there (yet), here is a simple usable implementation: > > package away3dlite.materials > { > import flash.display.BitmapData; > import flash.display.DisplayObject; > import flash.display.Graphics; > import flash.geom.Matrix; > import flash.geom.Rectangle; > > public class MovieMaterial extends BitmapMaterial > { > public var movie:DisplayObject; > public var movieTransparent:Boolean; > private var userClipRect:Rectangle; > private var transRect:Matrix; > > public function MovieMaterial( movieAsset:DisplayObject, > transparent:Boolean=false, rect:Rectangle=null ) > { > movieTransparent = transparent; > movie = movieAsset; > initRect(rect); > createBitmap(movie); > drawBitmap(); > } > > protected function initRect(rect:Rectangle=null):void > { > userClipRect = rect || movie.getBounds(movie); > transRect = new Matrix(1, 0, 0, 1, -userClipRect.x, - > userClipRect.y); > } > > protected function createBitmap(asset:DisplayObject):void > { > if(_graphicsBitmapFill.bitmapData) > _graphicsBitmapFill.bitmapData.dispose(); > > if (userClipRect) > { > _graphicsBitmapFill.bitmapData = new > BitmapData(int > (userClipRect.width+0.5), int(userClipRect.height+0.5), > movieTransparent, 0x000000); > } > else if (asset.width == 0 || asset.height == 0) > { > _graphicsBitmapFill.bitmapData = new > BitmapData(256, 256, > movieTransparent, 0x000000); > } > else > { > _graphicsBitmapFill.bitmapData = new > BitmapData(int(asset.width > +0.5), int(asset.height+0.5), movieTransparent, 0x000000); > } > } > > public function drawBitmap():void > { > _graphicsBitmapFill.bitmapData.fillRect > (_graphicsBitmapFill.bitmapData.rect, 0x000000); > _graphicsBitmapFill.bitmapData.draw(movie, transRect, > movie.transform.colorTransform, null); > } > > } > > > > }
