[Papervision3D] 2d coords of a 3d point

Andy Zupko azupko at zupko.info
Fri Aug 24 05:00:53 PDT 2007


Hey Mike - if you don't want to worry about using rendering, try this:

 

public function projectVertex(vertex:Vertex3D, camera:Camera3D):Number3D

{

                var vx:Number = vertex.x;

                var vy:Number = vertex.y;

                var vz:Number = vertex.z;

 

                var view:Matrix3D = camera.view;

 

                var sz:Number = vx * view.n31 + vy * view.n32 + vz *
view.n33 + view.n34;

 

                if (isNaN(sz))

                                return null;

 

                if (sz*2 <= -camera.focus)

                {

 

                                return null;

                }

 

 

                var persp:Number = camera.zoom / (1 + sz / camera.focus);

 

                var projected:Number3D = new Number3D();

                projected.z = sz;

                projected.x = (vx * view.n11 + vy * view.n12 + vz * view.n13
+ view.n14) * persp;

                projected.y = (vx * view.n21 + vy * view.n22 + vz * view.n23
+ view.n24) * persp;

 

                return projected;

}

 

It's a hack off away3d's vertex.project.  (I've been sorting through way to
much away3d lately).

 

*warning* - this has never been tested J - might help you get on your way
though.

 

From: papervision3d-bounces at osflash.org
[mailto:papervision3d-bounces at osflash.org] On Behalf Of Mike Mountain
Sent: Friday, August 24, 2007 7:14 AM
To: papervision3d at osflash.org
Subject: Re: [Papervision3D] 2d coords of a 3d point

 

Cool - how easy would it be to make this a method of Number3D - say
returnStageCoords(), returns Point?


M



On 8/24/07, Carlos Ulloa < carlos at carlosulloa.com
<mailto:carlos at carlosulloa.com> > wrote:

Create an empty DO3D, set its position in 3D and then check the 2D
coordinates after rendering. It used to be possible to project and object
without rendering, so maybe you can try that. 

C4RL05
// carlosulloa.com
// papervision3d.org



On 24/08/07, Mike Mountain < <mailto:mike.mountain at gmail.com>
mike.mountain at gmail.com> wrote:

Yeah, I want to convert an arbitrary (x,y,z) point in 3D space to a X,Y
point in the stages coord system - I thought as the 3D engine must be doing
this anyhow to update the display there should be an easy way of doing it? 

 

On 8/24/07, Nathaniel Warner < <mailto:warner.nathaniel at gmail.com>
warner.nathaniel at gmail.com> wrote:

To get the screen coordinates (2D) of a point on a plane I used:

plane.screen.x
plane.screen.y

Of course, this only works if you have a DisplayObject3D object to work
with.
Hope this helps.

On 8/23/07, John Grden < neoriley at gmail.com> wrote:
> hey Mike, check out the InteractiveDrawingTest - at the point where it
draws 
> on the texture - you can see how we get a point object back with the 2D 
> mouse coordinates:
>
> var point:Object = InteractiveUtils.getMapCoordAtPoint
> (e.face3d, e.sprite.mouseX, e.sprite.mouseY);
>
> You need to use an interactive material on your object, then you can use
the 
> InteractiveScene3DEvent properties face3d and sprite to pass the values to
> InteractiveUtils.getMapCoordAtPoint ()
>
> Let me know if that makes sense.
>
> OH and you have to turn
> InteractiveSceneManager.faceLevelMode = true
>
>
> On 8/23/07, Mike Mountain < mike.mountain at gmail.com
<mailto:mike.mountain at gmail.com> > wrote:
> >
> > I thought this would be easy - but digging through the docs I can't seem

> to find a simple way of translating a 3d point back to 2d screen
> coordinates. Am I missing something?
> >
> > Cheers
> >
> > Mike
> >
> > _______________________________________________ 
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> >
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
<http://osflash.org/mailman/listinfo/papervision3d_osflash.org> 
> >
> >
>
>
>
> --
> [  JPG  ]
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_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
<http://osflash.org/mailman/listinfo/papervision3d_osflash.org> 

 

 

_______________________________________________
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/20070824/e81f6b74/attachment-0001.html 


More information about the Papervision3D mailing list