局部貼圖,可以給每個面貼圖。
代碼:
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. * ; /** * ... * @author ever5u */ public class fuxi extends Sprite { private var scene:Scene3D; private var camera:Camera3D; private var box:Box; private var app01:Appearance; private var app02:Appearance; private var app03:Appearance; public function fuxi() { 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 materialAttr01:MaterialAttributes = new MaterialAttributes( new LightAttributes( true , 0.1) ); var material01:Material = new ColorMaterial( 0xFFCC33 , 1 , materialAttr01 ); material01.lightingEnable = true; app01 = new Appearance( material01 ); // 第二套著色 var materialAttr02:MaterialAttributes = new MaterialAttributes( new LightAttributes( true , 0.1) , new LineAttributes(3 , 0xF43582 , 1) ); var material02:Material = new ColorMaterial( 0xAAEE99 , 1 , materialAttr02 ); material02.lightingEnable = true; app02 = new Appearance( material02 ); // 第三套著色 var materialAttr03:MaterialAttributes = new MaterialAttributes( new LightAttributes( true , 0.1) , new OutlineAttributes(3 , 0xFC5858 , 1) , new LineAttributes(1 , 0x000000 , 1) ); var material03:Material = new ColorMaterial( 0x9DCCEA , 1 , materialAttr03 ); material03.lightingEnable = true; app03 = new Appearance( material03 ); //應(yīng)用著色 //box.appearance = app01; box.aPolygons[0].appearance = app01; box.aPolygons[1].appearance = app02; box.aPolygons[2].appearance = app03; box.aPolygons[3].appearance = app02; box.aPolygons[4].appearance = app01; box.aPolygons[5].appearance = app03; g.addChild(box); return g; } private function enterFrameHandler( event : Event ) : void { box.rotateX = mouseX; box.rotateY = mouseY; scene.render(); } } }
效果:
出處:藍色理想
責(zé)任編輯:bluehearts
上一頁 Flash3D學(xué)習(xí)——Sandy學(xué)習(xí)筆記 [14] 下一頁 Flash3D學(xué)習(xí)——Sandy學(xué)習(xí)筆記 [16]
◎進入論壇RIA設(shè)計與應(yīng)用版塊參加討論
|