[Papervision3D] Get 2D real screen coordinates of 3D object

7/5/2008 wow.party at gmail.com
Mon May 5 00:29:24 PDT 2008


Hey Ryan,

I'm using breakpoints and can't see the "vertex2DInstance" property, but
there is a ""vertex3DInstance" which is not so helpful...

did you use "GreatWhite" ?

On Mon, May 5, 2008 at 9:34 AM, Ryan Sabir <ryan at newgency.com> wrote:

>  I did this by referring to:
>
> myObject.geometry.vertices[n].vertex2DInstance.x
>  myObject.geometry.vertices[n].vertex2DInstance.y
>
> Where n is a number based of the number of segments in your object. My
> example was a Plane with 2x2 segments, so there were 9 items in the vertices
> array. The x and y of items 0 and 8 gave me the top left and bottom right of
> my plane.
>
> Not sure if this is the best / correct way to do this, but it worked for
> me.
>
> Hope this helps!
>
>
>  ------------------------------
> *From:* papervision3d-bounces at osflash.org [mailto:
> papervision3d-bounces at osflash.org] *On Behalf Of *7/5/2008
> *Sent:* Monday, 5 May 2008 4:14 PM
> *To:* info at jeffwinder.nl; papervision3d at osflash.org
>
> *Subject:* Re: [Papervision3D] Get 2D real screen coordinates of 3D object
>
> Hi Jeff,
>
> Thanks for the response, and yes, this is kind of a deadline :-)
>
> Well, i tried the screen parameter and got '0' for screen.x and screen.y ,
> do you know why?
>
> i added a simple source code that shows what i mean:
>
>
> --------------------------------------------------------------------------------------------
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute" creationComplete="init()" viewSourceURL="
> http://www.liorbruder.com/paperTest/paperTest.html">
>     <mx:Script>
>         <![CDATA[
>             import caurina.transitions.Tweener;
>             import org.papervision3d.objects.primitives.Plane;
>             import org.papervision3d.materials.ColorMaterial;
>             import org.papervision3d.render.BasicRenderEngine;
>             import org.papervision3d.cameras.FrustumCamera3D;
>             import org.papervision3d.scenes.Scene3D;
>             import org.papervision3d.view.Viewport3D;
>
>              private var viewport:Viewport3D;
>             private var scene:Scene3D;
>             private var camera:FrustumCamera3D;
>             private var renderer:BasicRenderEngine;
>
>             private var testPlane:Plane;
>
>             private function init():void  {
>                 initPapervision();
>                 initObjects();
>                 initListeners();
>
>                 // Start the movement
>                 Tweener.addTween([testPlane], {x:300, time:10});
>             }
>
>             private function initPapervision():void {
>                 viewport  = new Viewport3D(m_PlaceUI.width,
> m_PlaceUI.height, false, true, true, false);
>                 m_PlaceUI.addChild(viewport);
>
>                 viewport.visible = true;
>
>                 scene = new Scene3D();
>                 camera = new FrustumCamera3D(viewport, 20);
>                 camera.far = 5000;
>                 camera.z = -1500;
>
>                renderer = new BasicRenderEngine();
>             }
>
>             private function initObjects():void
>             {
>                 var testPlaneMaterial:ColorMaterial = new ColorMaterial();
>                 testPlane = new Plane(testPlaneMaterial, 100, 100, 1, 1);
>                 testPlane.x = -200;
>
>                 scene.addChild(testPlane);
>             }
>
>             private function initListeners():void
>             {
>                 addEventListener(Event.ENTER_FRAME, onEnterFrame);
>             }
>
>             private function onEnterFrame(e:Event):void
>             {
>                   renderer.renderScene(scene, camera, viewport);
>
>                   m_3DObjectX.text = testPlane.x.toString();
>                   m_3DObjectY.text = testPlane.y.toString();
>                   m_3DObjectZ.text = testPlane.z.toString();
>
>                   m_2DRealX.text = testPlane.screen.x.toString();
>                   m_2DRealY.text = testPlane.screen.y.toString();
>             }
>         ]]>
>     </mx:Script>
>
>     <mx:UIComponent id="m_PlaceUI" width="1000" height="700"/>
>     <mx:Panel x="10" y="10" width="250" height="200" layout="absolute"
> title="Positions:">
>         <mx:Label x="10" y="10" text="3D Object X:"/>
>         <mx:Label x="93" y="10" text="0" id="m_3DObjectX"/>
>         <mx:Label x="10" y="27" text="3D Object Y:"/>
>         <mx:Label x="93" y="27" text="0" id="m_3DObjectY"/>
>         <mx:Label x="10" y="45" text="3D Object Z:"/>
>         <mx:Label x="93" y="45" text="0" id="m_3DObjectZ"/>
>         <mx:Label x="10" y="82" text="2D Real X Cord:"/>
>         <mx:Label x="105.5" y="82" text="0" id="m_2DRealX"/>
>         <mx:Label x="10" y="97" text="2D Real Y Cord:"/>
>         <mx:Label x="105.5" y="97" text="0" id="m_2DRealY"/>
>     </mx:Panel>
>
> </mx:Application>
>
>
> --------------------------------------------------------------------------------------------
>
> On Sun, May 4, 2008 at 5:37 PM, Jeff Winder <winderjeff at hotmail.com>
> wrote:
>
> > 7/5/2008? is that your deadline :-)?
> >
> > *screen*<http://www.flashbookmarks.com/PV3D-Effects-DOC/org/papervision3d/objects/DisplayObject3D.html#screen>:
> > *Number3D*<http://www.flashbookmarks.com/PV3D-Effects-DOC/org/papervision3d/core/math/Number3D.html>
> > [read-only] The coordinate of the object on screen.
> >
> > Isn't that what you mean?
> >
> > Jeff.
> > seedylifestyle.blogspot.com/
> >
> >
> >
> >  ------------------------------
> > Date: Sun, 4 May 2008 17:28:26 +0300
> > From: wow.party at gmail.com
> > To: papervision3d at osflash.org
> > Subject: Re: [Papervision3D] Get 2D real screen coordinates of 3D object
> >
> >
> >
> > Sorry, your right, im using GreatWhite.
> >
> > On Sun, May 4, 2008 at 5:06 PM, Tom Richardson <kwarismian at gmail.com>
> > wrote:
> >
> > Are you using GreatWhite or the Effects branch?
> >
> >   On Sun, May 4, 2008 at 6:34 AM, 7/5/2008 <wow.party at gmail.com> wrote:
> >
> >   Hi All,
> >
> > I was looking for a solution in this form but could not find an answer
> > to my problem.
> >
> > The question is very simple: i have a 3d object (base on
> > DisplayObject3D) and i need the real screen location to display additional
> > information out of papervision
> >
> > very important thing is that i'm using *Frustum camera*!
> >
> >
> > Thanks in advance, waiting for your answers
> > :-)
> > Lior
> >
> >
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> >
> >
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> >
> >
> > ------------------------------
> > Plan je evenement, nodig mensen uit en deel je foto's met Windows Live
> > Events <http://events.live.com>
> >
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> >
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20080505/c8ac8f1a/attachment.html 


More information about the Papervision3D mailing list