아래 예제를 실행하면 처음으로 3D Object를 확인 할 수 있다 ^_^ 감격의 기쁨 ~

 [ 그림 : 결과물 ]

- Scene, Camera, Viewport를 생성한다음 Object를 삽입한 이후 Rendering 한다가 기본임을 알고 넘어가면 쉽다.


 

this.addChild(_viewport);

_scene.addChild(_sphere);
_renderer.renderScene(_scene,_camera,_viewport);


1. 우리가 실제 볼 viewPort를 sprite에 넣어준다.
2. Scene에 Object를 삽입한다.
3. 우리가 지정한 Scene, Camera, Viewport 를 기준으로 렌더링을 한다.
=> 결과물은 viewport를 통해 볼 수 있게 된다.


 

//Main.mxml
<?xml version="1.0" encoding="utf-8"?>

<mx:Application

       creationComplete="init()"

       xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

       <mx:Script>

             <![CDATA[

                    import mx.core.UIComponent;

                    import sample.BasicSample;

                   

                    private function init():void{

                           var bs:BasicSample = new BasicSample();

                           var ui:UIComponent = new UIComponent();

                           ui.addChild(bs);

                           this.addChild(ui);

                    }

             ]]>

       </mx:Script>

</mx:Application>

//BasicSample.as

package sample

{

       import flash.display.Sprite;

      

       import org.papervision3d.cameras.Camera3D;

       import org.papervision3d.objects.primitives.Sphere;

       import org.papervision3d.render.BasicRenderEngine;

       import org.papervision3d.scenes.Scene3D;

       import org.papervision3d.view.Viewport3D;

 

       public class BasicSample extends Sprite

       {

             private var _scene:Scene3D;

             private var _viewport:Viewport3D;

             private var _camera:Camera3D;

             private var _renderer:BasicRenderEngine;

             private var _sphere:Sphere;

            

             public function BasicSample()

             {

                    //Scene, Camera, Viewport 생성 => Object 삽입 => 랜더링 

                    _scene = new Scene3D();

                    _camera = new Camera3D();

                    _viewport = new Viewport3D();

                    _sphere = new Sphere();

                    _renderer = new BasicRenderEngine();

                   

                    this.addChild(_viewport);

                    _scene.addChild(_sphere);              

                    _renderer.renderScene(_scene,_camera,_viewport);

             }

            

       }

}



 

+ Recent posts