您的位置:首页 > 其它

Sandy引擎学习笔记:swf影片剪辑纹理贴图

2008-10-15 22:51 543 查看
Sandy引擎可以像3dsmax 传统的3d***软件 那样可以支持外部贴图,同样也可以支持swf 的贴图,和flv 的贴图显示,这样一件让人觉得兴奋的事情。

下面引入官方一个代码:(偷懒一下,下次补回更多解析)













package

{

import flash.display.*;

import flash.net.URLRequest;

import flash.events.*;

import flash.ui.*;

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.*;

public class My3D extends Sprite

{

private var scene:Scene3D;

private var camera:Camera3D;

private var box:Box;

private var queue:LoaderQueue;

public function My3D()

{

queue = new LoaderQueue();

queue.add( "test", new URLRequest("main.swf") );

queue.add( "test2", new URLRequest("main2.swf") );

queue.addEventListener(SandyEvent.QUEUE_COMPLETE, loadComplete );

queue.start();

}

public function loadComplete(event:QueueEvent ):void

{

// We create the camera

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

{

// Create the root Group

var g:Group = new Group();

// Create a cube so we have something to show

box = new Box( "box",100,100,100,"tri");

box.rotateX = 30;

box.rotateY = 30;

box.x = 0;

// we define a simple color material

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 app:Appearance = new Appearance( material );

// we define two Movie Material

var material01:MovieMaterial = new MovieMaterial( queue.data["test"],40);

material01.lightingEnable = true;

var app01:Appearance = new Appearance( material01 );

var material02:MovieMaterial = new MovieMaterial( queue.data["test2"],40);

material02.lightingEnable = true;

var app02:Appearance = new Appearance( material02 );

box.appearance = app;

box.aPolygons[0].appearance = app01;

box.aPolygons[1].appearance = app01;

box.aPolygons[2].appearance = app02;

box.aPolygons[3].appearance = app02;

//box.aPolygons[10].appearance = app02;

//box.aPolygons[11].appearance = app02;

g.addChild( box );

return g;

}

// The Event.ENTER_FRAME event handler tells the Scene3D to render

private function enterFrameHandler( event : Event ):void

{

box.tilt += 1;

box.pan += 1;

//sphere.pan += 1

scene.render();

}

}

}



其实和普通的图片贴图区别,类只是名称改变而已,操作和图片贴图差不多

MovieMaterial(p_oMovie:Sprite, p_nUpdateMS:uint = 40, p_oAttr:MaterialAttributes = null, p_bRemoveTransparentBorder:Boolean = false, p_nHeight:Number = 0, p_nWidth:Number = 0)
Creates a new MovieMaterial.
//创建一个影片剪辑材质


实际的用途用作材质贴图,为flash贴图增加一种不错的格式;







有点累了,下次补上其他 解析


加载外部文件的的类结合到URLRequest一起使用,既可以加人swf jpeg ,flv等等:
queue = new LoaderQueue();

queue.add( "test", new URLRequest("main.swf") );

queue.add( "test2", new URLRequest("main2.swf") );
queue.addEventListener(SandyEvent.QUEUE_COMPLETE, loadComplete );
queue.start();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: