- 最后登录
- 2018-12-19
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 54706
- 纳金币
- 32328
- 精华
- 41
|
导入3ds格式文件,通过网络加载3DS文件。
不做什么说明了,我对3dsmax不了解,这里只是做个了解。
代码:
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.parser. * ;
import sandy.util. * ;
import sandy.events. * ;
/**
* ...
* @author ever5u
*/
public class fuxi extends Sprite
{
private var scene:Scene3D;
private var camera:Camera3D;
private var rifle:Shape3D;
private var queueoaderQueue;
private var parserStackarserStack;
public function fuxi()
{
var parser:IParser = Parser.create("http://www.flashsandy.org/max/asset/mar_rifle.3ds" , Parser.MAX_3DS , 1 , "JPG");
parserStack = new ParserStack();
parserStack.add("rifle" , parser);
parserStack.addEventListener(ParserStack.COMPLETE , parserComplete );
parserStack.start();
}
private function onError( pEvtarserEvent ):void
{
trace("there is an error in loading your stuff");
}
private function parserComplete(pEvt:Event ):void
{
rifle = parserStack.getGroupByName("rifle").children[0] as Shape3D;
var root:Group = createScene();
camera = new Camera3D( 300 , 300 );
camera.y = 5;
camera.z = - 150;
scene = new Scene3D( "scene" , this , camera , root );
addEventListener( Event.ENTER_FRAME , enterFrameHandler );
stage.addEventListener(KeyboardEvent.KEY_DOWN , keyPressedHandler);
}
private function createScene():Group
{
var g:Group = new Group();
rifle.x = 0;
rifle.y = 0;
rifle.pan = - 30;
g.addChild(rifle);
return g;
}
private function keyPressedHandler(event:flash.events.KeyboardEvent):void
{
switch(event.keyCode)
{
case Keyboard.UP:
rifle.roll += 5;
break;
case Keyboard.DOWN:
rifle.roll -= 5;
break;
case Keyboard.LEFT:
rifle.pan -= 5;
break;
case Keyboard.RIGHT:
rifle.pan += 5;
break;
}
}
private function enterFrameHandler( event : Event ) : void
{
scene.render();
}
}
} |
|