[Papervision3D] camera.orbit() camera.rotationY and displayList

John Brookes jbpv3d at googlemail.com
Fri Sep 26 15:39:54 PDT 2008


Trying to work out why certain things are happening.

I take it scene.displayList() doesn't show any particular order.
Is there a way to get displayList in its Zsorted index or display order?


Why does camera.rotaionY not equal camera.orbit();
Camera.rotationY seems to go 0->90->0

Example here www.shrewballooba.co.uk/pv/example03.html

// Uses Latest AS3 branch (todays)
// * NOTE the order of the colours should spell PARTS or STRAP just made it
easier ;)
package
{
    import flash.events.*;
    import flash.text.*;

    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.view.BasicView;
    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.*;
    import org.papervision3d.view.layer.ViewportLayer;
    import org.papervision3d.view.layer.util.ViewportLayerSortMode;

    /**
     * ...
     * @author DefaultUser (JB shrewballooba.co.uk)
     */
    public class example03 extends BasicView
    {
        private var PlumPlane:Plane
        private var lastMouseX:int;
        private var lastMouseY:int;
        private var doMove:Boolean = false;
        private var dspLstdbg:TextField  = new TextField();
        private var camRotdbg:TextField  = new TextField();
        private var orbitdbg:TextField  = new TextField();

        public function example03():void
        {
            super(400, 300, true, true, "TARGET");
            stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            setScene();
            //singleRender();
            startRendering();
        }

        private function setScene():void
        {
            camera.z = -1500;

            camRotdbg.y = 20;
            camRotdbg.height = 20;
            camRotdbg.width = 250;
            camRotdbg.background = true;
            camRotdbg.backgroundColor;
            addChild(camRotdbg)

            orbitdbg.y = 50;
            orbitdbg.height = 20;
            orbitdbg.width = 250;
            orbitdbg.background = true;
            orbitdbg.backgroundColor;
            addChild(orbitdbg);

            dspLstdbg.y = 80;
            dspLstdbg.height = 100;
            dspLstdbg.width = 260;
            dspLstdbg.background = true;
            dspLstdbg.backgroundColor;
            addChild(dspLstdbg);

            var Plum:uint = 0x880080;
            var Aquamarine:uint = 0x77ffd4;
            var Red:uint = 0xFF0000;
            var Tan:uint = 0xD2B48C;
            var Silver:uint = 0xC0C0C0;

            //Plum Plane
            var PlumPlaneMat:ColorMaterial = new ColorMaterial(Plum);
            PlumPlaneMat.doubleSided = true;
            PlumPlane = new Plane(PlumPlaneMat);
            PlumPlane.name = "PlumPlane";
            PlumPlane.useOwnContainer = true;
            scene.addChild(PlumPlane);

            //Aquamarine Plane
            var AquamarinePlaneMat:ColorMaterial = new
ColorMaterial(Aquamarine);
            var AquamarinePlane:Plane = new Plane(AquamarinePlaneMat);
            AquamarinePlaneMat.doubleSided = true;
            AquamarinePlane.name = "AquamarinePlane";
            AquamarinePlane.useOwnContainer = true;
            AquamarinePlane.x = -75;
            AquamarinePlane.y = 75;
            AquamarinePlane.z = -50;
            scene.addChild(AquamarinePlane);

            //Red Plane
            var RedPlaneMat:ColorMaterial = new ColorMaterial(Red);
            RedPlaneMat.doubleSided = true;
            var RedPlane:Plane = new Plane(RedPlaneMat);
            RedPlane.name = "RedPlane";
            RedPlane.useOwnContainer = true;
            RedPlane.x = -150;
            RedPlane.y = 150;
            RedPlane.z = -100;
            scene.addChild(RedPlane);

            //Tan Plane
            var TanPlaneMat:ColorMaterial = new ColorMaterial(Tan);
            TanPlaneMat.doubleSided = true;
            var TanPlane:Plane = new Plane(TanPlaneMat);
            TanPlane.name = "TanPlane";
            TanPlane.useOwnContainer = true;
            TanPlane.x = -225;
            TanPlane.y = 225;
            TanPlane.z = -150;
            scene.addChild(TanPlane);

            //Silver Plane
            var SilverPlaneMat:ColorMaterial = new ColorMaterial(Silver);
            SilverPlaneMat.doubleSided = true;
            var SilverPlane:Plane = new Plane(SilverPlaneMat);
            SilverPlane.name = "SilverPlane";
            SilverPlane.useOwnContainer = true;
            SilverPlane.x = -300;
            SilverPlane.y = 300;
            SilverPlane.z = -200;
            scene.addChild(SilverPlane);

            /* IGNORE
            var parentLayer:ViewportLayer = new ViewportLayer(viewport,
null);
            viewport.containerSprite.addLayer(parentLayer);
            parentLayer.sortMode = ViewportLayerSortMode.Z_SORT;

            parentLayer.getChildLayer(PlumPlane, true).layerIndex = 1;
            parentLayer.getChildLayer(AquamarinePlane, true).layerIndex = 2;
            parentLayer.getChildLayer(RedPlane, true).layerIndex = 3;
            parentLayer.getChildLayer(TanPlane, true).layerIndex = 4;
            parentLayer.getChildLayer(SilverPlane, true).layerIndex = 5;
            */

            trace( scene.childrenList() );
        }

        private function onMouseDown(event:MouseEvent):void {
            doMove = true;
            lastMouseX = event.stageX - (stage.width/2);
            lastMouseY = event.stageY - (stage.height/2) ;
            startRendering();
        }

        private function onMouseUp(event:MouseEvent):void
        {
            doMove = false;
            stopRendering();
            dspLstdbg.text = "scene.childrenList() \n" +scene.childrenList()
;
        }

        override protected function onRenderTick(event:Event = null):void
        {
            if (doMove)
            {
                camera.orbit(  -90 , (360 / stage.width) * ( lastMouseX -
(mouseX - (stage.width/2)) ) + 90, true, PlumPlane );
                camRotdbg.text = "camera.rotationY = " + camera.rotationY;
                orbitdbg.text = "camera.orbit( -90, " + (360 / stage.width)
* ( lastMouseX - (mouseX - (stage.width/2)) ) + 90 + ", true, PlumPlane);" ;
            }
            super.onRenderTick(event);
        }
    }

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20080926/ccbaf01a/attachment-0001.html 


More information about the Papervision3D mailing list