接下來要介紹的可是Sandy的重頭戲了,MC貼圖! Sandy可以使用影片剪輯進行貼圖,還可以支持視頻的貼圖(FLV格式)。 這里正好復習一下之前的貼圖方法。
代碼:
package { import flash.display. * ; import flash.events. * ; import flash.ui. * ; import flash.net.URLRequest; import sandy.core.Scene3D; import sandy.core.data. * ; import sandy.core.scenegraph. * ; import sandy.materials. * ; import sandy.materials.attributes. * ; import sandy.primitive. * ; import sandy.util. * ; import sandy.events. * ; /** * ... * @author ever5u */ public class fuxi extends Sprite { private var scene:Scene3D; private var camera:Camera3D; private var box:Box; private var queue:LoaderQueue; public function fuxi() { queue = new LoaderQueue(); queue.add( "t1" , new URLRequest("load/01.swf") ); queue.add( "t2" , new URLRequest("load/02.swf") ); queue.add( "t3" , new URLRequest("load/03.jpg") ); queue.addEventListener(SandyEvent.QUEUE_COMPLETE , loadComplete ); queue.start(); } private function loadComplete(_evt:Event):void { camera = new Camera3D( 300 , 300 ); camera.z = - 400; var root:Group = createScene(); scene = new Scene3D( "scene" , this , camera , root ); addEventListener( Event.ENTER_FRAME , enterFrameHandler ); } private function createScene():Group { var g:Group = new Group(); box = new Box( "box" , 100 , 100 , 100 , "quad"); // 第一套著色(顏色) var materialAttr:MaterialAttributes = new MaterialAttributes( new LineAttributes( 0 , 0xD7D79D , 0 ) , new LightAttributes( true , 0.1) ); var material:Material = new ColorMaterial( 0xD7D79D , 1 , materialAttr ); material.lightingEnable = true; var app01:Appearance = new Appearance( material ); // 第二套著色(導入庫中貼圖) var bitmap:BitmapData = new MyPalm(0, 0); var material02:Material = new BitmapMaterial( bitmap ); var app02:Appearance = new Appearance( material02 ); // 第三套著色(導入外部圖片) var material03:Material = new BitmapMaterial( queue.data["t3"].bitmapData ); var app03:Appearance = new Appearance( material03 ); // 第四套著色(導入外部MC) var material04:MovieMaterial = new MovieMaterial( queue.data["t1"], 40); material04.lightingEnable = true; var app04:Appearance = new Appearance( material04 ); // 第五套著色(導入庫中MC) var myMC:MovieClip = new _MC(); var material05:MovieMaterial = new MovieMaterial(myMC, 40); material05.lightingEnable = true; var app05:Appearance = new Appearance( material05 ); // 第六套著色(導入外部MC) var material06:MovieMaterial = new MovieMaterial( queue.data["t2"], 40); material06.lightingEnable = true; var app06:Appearance = new Appearance( material06 ); //應用著色 //box.appearance = app01; box.aPolygons[0].appearance = app01; box.aPolygons[1].appearance = app02; box.aPolygons[2].appearance = app03; box.aPolygons[3].appearance = app04; box.aPolygons[4].appearance = app05; box.aPolygons[5].appearance = app06; g.addChild(box); return g; } private function enterFrameHandler( event : Event ) : void { box.rotateX = mouseX; box.rotateY = mouseY; scene.render(); } } }
效果: Sandy_15.rar
出處:藍色理想
責任編輯:bluehearts
上一頁 Flash3D學習——Sandy學習筆記 [15] 下一頁 Flash3D學習——Sandy學習筆記 [17]
◎進入論壇RIA設計與應用版塊參加討論
|