Carlos, to go from 2D to 3D I have been using Fabrice's Drag3D in a routine
like this:


*public* *function* mouseTo3D(screenX:Number, screenY:Number, screenZ:Number
= 0):Vector3D

{

*var* n3D:Vector3D = *new* Vector3D;

*// var persp:Number = view.camera.zoom / view.camera.focus;
*

*// Use Fabrice's Drag3D class...
*

*var* d3D:Drag3D = *new* Drag3D( view );

*var* plane:String = gridStyle.toLowerCase();

plane = (plane == *"yz"*) ? *"zy"* : plane;

d3D.plane = plane;

n3D = N2V(d3D.getIntersect( screenX, screenY ));

*// 8? WTF?
*

*if* (view.camera.lens *is* OrthogonalLens) {

n3D.x /= 8;

n3D.y /= 8;

n3D.z /= 8;

}

*return* n3D;

}

Ignore the occassional dark mutterings in that code.

For 3D to 2D, I use the camera's screen method something like this:


sv = view.camera.screen( *this*, *this*.mesh.vertices[i] );

Pass it in a vertex or other point, get back a ScreenVertex.



Cheers,

BW

On Fri, Apr 8, 2011 at 10:38 AM, carlos.lunetta <carlos.lune...@gmail.com>wrote:

> Hello all
>
> I've read a couple of opinions regarding the conversion of a 2D
> coordinate to 3D space, but not sure the best way to proceed. Some
> people talk about deperspective, but it's not present on 3.6 anymore.
>
> I have the screenX and screenY coordinates, and the desired Z depth -
> looking for the projected x and y. What would be the best way to go?
>
> thanks a lot!

Reply via email to