- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
原来Sandy还可以导入模型文件(ASE)
我调试这个例子时总有错误提示(提示路径错误),但不影响使用,初步估计是这个版本的Bug。
例子中创建组的方式有了点变化
var g:Group = Group( p_eEvent.group);
代码:
package
{
import flash.display.Sprite;
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.parser.*;
/**
* ...
* @author ever5u
*/
public class fuxi extends Sprite
{
private var scene:Scene3D;
private var camera:Camera3D;
private var pot:Shape3D;
public function fuxi() {
var parser:IParser = Parser.create("teieraASE.ASE",Parser.ASE );
parser.addEventListener( ParserEvent.FAIL, onError );
parser.addEventListener( ParserEvent.INIT, createScene );
parser.parse();
}
private function onError( pEvtarserEvent ):void {
trace("there is an error in loading your stuff");
}
private function createScene(p_eEventarserEvent ):void {
//创建摄像机
camera = new Camera3D( 300, 300 );
camera.y = 30;
camera.z = -200;
camera.lookAt(0,0,0);
//创建 Group
var g:Group = Group( p_eEvent.group);
//处理模型
pot = g.children[0] as Shape3D;
//着色设置
var materialAttr:MaterialAttributes = new MaterialAttributes(
new LineAttributes( 0.1, 0x2111BB, 0.1 ),
new LightAttributes( ***e, 0.1)
);
var material01:Material = new ColorMaterial( 0xFFCC33, 1, materialAttr );
material01.lightingEnable = false;
var app01:Appearance = new Appearance( material01 );
//应用着色
pot.appearance = app01;
scene = new Scene3D( "scene", this, camera, g );
addEventListener( Event.ENTER_FRAME, enterFrameHandler );
}
private function enterFrameHandler( event : Event ) : void {
pot.pan += 2;
scene.render();
}
}
} |
|