3 Replies Latest reply on Jun 1, 2009 11:41 AM by the.fontvir.us

    How to let a Panel created in 3D show up?

    ningyuanma

      I have created a panel in 3D space, however, when I test run it, nothing shows up and no compile errors comes up.

      So I am quite confused why I can't see my panel on the scene...

      The following is how I did it. Could someone please point out where I did wrong or missed anythig out?

      Many thanks in advance!

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:xx="com.fontvirus.*" creationComplete="init()">

       

      <mx:Script>
          <![CDATA[
              import org.papervision3d.view.BasicView;
              import org.papervision3d.objects.primitives.Plane;
              import org.papervision3d.materials.ColorMaterial;
              import com.fontvirus.CanvasView3D;
             
              private var redMaterial:ColorMaterial = new ColorMaterial(0xff00ff);
              private var plane:Plane;
              private var view:BasicView;
             
              private function init():void{
                  view = canvasView.view;
                  redMaterial.doubleSided = true;
                  plane = new Plane(redMaterial, 50, 50, 3, 3);
                  view.scene.addChild(plane);
              }
          ]]>
      </mx:Script>

       


      <xx:CanvasView3D id="canvasView" autoScaleMode="true" interactivity="false" autoClipMode="true" autoCullMode="true"/>
      </mx:WindowedApplication>

        • 1. Re: How to let a Panel created in 3D show up?
          Barna Biro Level 3

          Hello,

           

          I'm not a PaperVision3D expert but one thing that I see missing from your code is the actual Panel. I see that you are creating a plane and a view but can't see the panel you are talking about. Could you enlighten me ( or is the CanvasView3D a custom panel component ) ?

           

          Best regards,

          Barna Biro

          • 2. Re: How to let a Panel created in 3D show up?
            ningyuanma Level 1

            Sorry, that's my mistake, I meant to say plane instead of panel.

            So how could I see the plane I created?

            • 3. Re: How to let a Panel created in 3D show up?
              the.fontvir.us

              hey,

              its cool to see people using my code.

               

              your so0o0o0o0o0o0o close!

               

              here's an updated version of your code that will work:

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:xx="com.fontvirus.*" creationComplete="init()">

               

              <mx:Script>
                  <![CDATA[
                      import org.papervision3d.objects.primitives.*;
                      import org.papervision3d.materials.*;
                      import com.fontvirus.*;
                     
                      private var redMaterial:ColorMaterial;
                      private var plane:Plane;
                      private var view:BasicView;
                     
                      private function init():void{

                          redMaterial = new ColorMaterial(0xff00ff);

                          redMaterial.doubleSided = true;


                          plane = new Plane(redMaterial, 50, 50, 3, 3);
                          canvasView.view.scene.addChild(plane);

               

                          addEventListener(Event.ENTER_FRAME, loop3D);
                      }

                      private function loop3D(e:Event):void {

                          plane.rotationX++;

                          plane.rotationZ++;

               

                          canvasView.view.singleRender();

                      }
                  ]]>
              </mx:Script>
              <xx:CanvasView3D id="canvasView" autoScaleMode="true" interactivity="false" autoClipMode="true" autoCullMode="true"/>
              </mx:WindowedApplication>

               

              the problem w/ your code is you need to render the scene!

              nothing will display unless you tell papervision3D it needs to

              render the 3D scene.

               

              in this example, i added an eventlistener on the enterframe event.

              every time that event fires (every frame) it will rotate the plane on

              its X and Z axis, and render the scene. notice im calling "singleRender()"

              on the loop function. it's also possible to call "startRendering()" in

              the init function, and make the loop unnecessary.

               

              lots more info on my blog

              http://the.fontvir.us/b10g/

               

              and tons of PV3D help at the forums

              http://forum.papervision3d.org/

               

              hope that helps!