BasicView를 상속받아  처리하여 이전 기초예제 1과 비교해서 코드량이 획기적으로 줄어 든 것을 확인 할 수 있다.

BasicView는 기본적으로 처리해야 될 업무를 처리해 줘서 (Scene, Viewport, Camera, 랜더러 설정..) 우리는 그것에 필요한 최소 정보 입력을 통해 손쉽게 코드를 구성할 수 있다. 책에서는 이렇게 말했고... 역시 코드는 짧고 명확하며 알아보기 쉬우면 그것으로 된것이다, 물론 내부처리까지 다 알아서 좀더 퍼포먼스가 낳은것을 개발하는 것도 좋지만 짧은 개발시간에 비춰 본다면 우선적으로 전체를 보고 구상하는 것이 먼저라고 하는것이 좋을거 같다, 이후에 뭐 시간 남으면 좀더 안쪽으로 Detail하게 ...

아래 코드는 원형 구체를 X축 방향으로 돌리는 예제 입니다. 간결하면서도 확실하게 눈에 쏙 들어오는 코드 ^_^



//Main.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application

       creationComplete="init()"

       frameRate="40"

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

       <mx:Script>

             <![CDATA[

                    import sample.BasicViewExample;

                    import mx.core.UIComponent;

                   

                    private function init():void{

                           var bs:BasicViewExample = new BasicViewExample();

                          

                           var ui:UIComponent = new UIComponent();

                           ui.addChild(bs);

                          

                           this.addChild(ui);

                    }

                   

             ]]>

       </mx:Script>

</mx:Application>


//BasicViewExample.as

package sample

{

       import flash.events.Event;

       import org.papervision3d.objects.primitives.Sphere;

       import org.papervision3d.view.BasicView;

 

       public class BasicViewExample extends BasicView

       {

             private var _sphere:Sphere;

            

             public function BasicViewExample()

             {

                    _sphere = new Sphere();

                    scene.addChild(_sphere);

                   

                    startRendering();               

             }

            

             override protected function onRenderTick(event:Event=null):void{

                   

                    _sphere.localRotationX += 1;

                   

                    super.onRenderTick();

             }

            

       }

}


'기타 > Old' 카테고리의 다른 글

[ PV3D ] 3-2 Primitives - Plane  (0) 2009.10.10
[ PV3D ] 3-1 Primitives 기본모델?  (0) 2009.10.10
[ PV3D ] 2-2 기초 예제 1  (0) 2009.10.08
[ PV3D ] 2-1 PV3D기본 SCENE, CAMERA, VIEWPORT ...  (0) 2009.10.08
[ PV3D ] 1-1 환경설정  (0) 2009.10.08

+ Recent posts