- 最后登录
- 2022-10-8
- 注册时间
- 2010-12-6
- 阅读权限
- 100
- 积分
- 14150
- 纳金币
- 76544
- 精华
- 23
|
1.首先制作两个movieclip(main.swf和main2.swf).
2.将这两个swf加载到我们希望的swf中。
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();
3.将加载的swf赋予模型的材质属性
var material01:MovieMaterial = new MovieMaterial(
queue.data["test"],40);
material01.lightingEnable = ***e;
var app01:Appearance = new Appearance( material01 );
var material02:MovieMaterial = new MovieMaterial(
queue.data["test2"],40);
material02.lightingEnable = ***e;
var app02:Appearance = new Appearance( material02 );
最终代码:
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 Example010 extends Sprite
{
private var scene:Scene3D;
private var camera:Camera3D;
private var box:Box;
private var queueoaderQueue;
public function Example010():void
{
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(eventueueEvent ):void
{
// We create the camera
camera = new Camera3D( 300, 300 );
camera.z = -400;
// We create the "group" that is the tree of all the visible objects
var root:Group = createScene();
// We create a Scene and we add the camera and the objects tree
scene = new Scene3D( "scene", this, camera, root );
// Listen to the heart beat and render the scene
addEventListener( Event.ENTER_FRAME, enterFrameHandler );
}
// Create the scene graph based on the root Group of the scene
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( ***e, 0.1)
);
var material:Material = new ColorMaterial( 0xD7D79D, 1, materialAttr );
material.lightingEnable = ***e;
var app:Appearance = new Appearance( material );
// we define two Movie Material
var material01:MovieMaterial = new MovieMaterial(
queue.data["test"],40);
material01.lightingEnable = ***e;
var app01:Appearance = new Appearance( material01 );
var material02:MovieMaterial = new MovieMaterial(
queue.data["test2"],40);
material02.lightingEnable = ***e;
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();
}
}
}
|
|