- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
接下来要介绍的可是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 queueoaderQueue;
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( ***e , 0.1)
);
var material:Material = new ColorMaterial( 0xD7D79D , 1 , materialAttr );
material.lightingEnable = ***e;
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 = ***e;
var app04:Appearance = new Appearance( material04 );
// 第五套着色(导入库中MC)
var myMC:MovieClip = new _MC();
var material05:MovieMaterial = new MovieMaterial(myMC, 40);
material05.lightingEnable = ***e;
var app05:Appearance = new Appearance( material05 );
// 第六套着色(导入外部MC)
var material06:MovieMaterial = new MovieMaterial( queue.data["t2"], 40);
material06.lightingEnable = ***e;
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
|
|