Sandy引擎学习笔记:导入3ds模型纹理

  今天才发现了sandy 3.1的版本的确改进很多,特别是导入3ds模型的时候,将以前的类修改了一下,现在感觉好多了。

 

引用一个官方的例子,

下面是一支枪的纹理贴图,现在我们要加载一个3ds的文件,已经我们使用ase导入一个茶壶,因为那时候还没有进行贴图,而这里是自动贴图的方式引入到flash里面。其实很爽的一件事情。

纹理贴图:

 

Sandy引擎学习笔记:导入3ds模型纹理_第1张图片

 

引用官方一段代码:懒一下,代码以后有空再解析。呵呵,准备睡觉

mei tiaos 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.*; public class Example0074 extends Sprite { private var scene:Scene3D; private var camera:Camera3D; private var rifle:Shape3D; private var queue:LoaderQueue; private var parserStack:ParserStack; public function Example0074() { var parser:IParser = Parser.create("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( pEvt:ParserEvent ):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( 600, 300 ); camera.y = 5; camera.z = -150; scene = new Scene3D( "scene", this, camera, root ); // Listen to the heart beat and render the scene 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 = -90; 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(); } } }

 

效果图:

Sandy引擎学习笔记:导入3ds模型纹理_第2张图片

 

 

你可能感兴趣的:(flash,3D,引擎)