2 PV3D的坐标

为了搞清PV3D的坐标系是左手系还是右手系,最简单的办法就是在场景中画出坐标轴来。

 

package

{

       import flash.display.Sprite;

       import flash.events.Event;

       import org.papervision3d.core.geom.Lines3D;

       import org.papervision3d.core.geom.renderables.Line3D;

       import org.papervision3d.core.geom.renderables.Vertex3D;

       import org.papervision3d.materials.special.LineMaterial;

       import org.papervision3d.view.BasicView;

      

       /**

        * ...

        * @author yl

        */

       publicclass Main extends BasicView

       {

              var lineX:Line3D;//定义一条直线

              var lineY:Line3D;

              var lineZ:Line3D;

              var lines3D:Lines3D;//Line3D必须放在Lines3D对象中,才能在场景中显示

             

              publicfunction Main():void

              {

                     if(stage) init();

                     elseaddEventListener(Event.ADDED_TO_STAGE, init);

              }

             

              privatefunction init(e:Event = null):void

              {

                     removeEventListener(Event.ADDED_TO_STAGE,init);

                     //entry point

                     var lineXMaterial:LineMaterial = new LineMaterial(0x0000FF);//蓝色材质

                     var lineYMaterial:LineMaterial = new LineMaterial(0x00FF00);//绿色材质

                     var lineZMaterial:LineMaterial = new LineMaterial(0xFF0000);//红色材质

                     //直线X开始、结束的端点坐标

                     var p1:Vertex3D = new Vertex3D(0, 0, 0);

                     var e1:Vertex3D = new Vertex3D(500, 0, 0);

                     //直线Y开始、结束的端点坐标

                     var p2:Vertex3D = new Vertex3D(0, 0, 0);

                     var e2:Vertex3D = new Vertex3D(0, 500, 0);

                     //直线Z开始、结束的端点坐标

                     var p3:Vertex3D = new Vertex3D(0, 0, 0);

                     var e3:Vertex3D = new Vertex3D(0, 0, 500);

                    

                     lines3D= new Lines3D();//创建Lines3D对象

                    

                     //创建直线X,直线大小为2

                     lineX= new Line3D(lines3D, lineXMaterial, 2, p1, e1);

                     lines3D.addLine(lineX);//将直线放入Lines3D对象

                     //创建直线Y

                     lineY= new Line3D(lines3D, lineYMaterial, 2, p2, e2);

                     lines3D.addLine(lineY);//将直线放入Lines3D对象

                     //创建直线Z

                     lineZ= new Line3D(lines3D, lineZMaterial, 2, p3, e3);

                     lines3D.addLine(lineZ);//将直线放入Lines3D对象

                    

                     scene.addChild(lines3D);//将Lines3D对象加入场景显示

                    

                     startRendering();//渲染场景

                    

                     addEventListener(Event.ENTER_FRAME,onEnterFrame);

              }

             

              privatefunction onEnterFrame(event:Event):void {

                     lines3D.rotationY++;

              }

       }

}

运行效果如下

2 PV3D的坐标_第1张图片

可以看到在PV3D中,原点在FP的正中央。默认的X正向指向屏幕右侧,Y正向指向屏幕上方,Z正向垂直屏幕向内,即PV3D采用的是左手坐标系。


你可能感兴趣的:(2 PV3D的坐标)