Hello,

I am trying to figure out how to get a correspondant 3D coordinate at an
specific Z axis depth from a 2D Stage coordinate.
For example, to constrain the position of some 3D objects inside the Stage

I had tried using the strategy described in this post:
http://groups.google.com/group/away3d-dev/browse_thread/thread/5882ff4e35412217?pli=1

The result is really close, but no precise.

Here is the piece of code I am using to make those calculation.


            view.x = 0;
            view.y = stage.stageHeight/2;


            var rayLeft:Number3D = view.camera.unproject(-view.x, -view.y);
            var rayRight:Number3D = view.camera.unproject(stage.stageWidth ,
-view.y);
            var cameraPosition:Number3D = new
Number3D(view.camera.x,view.camera.y, view.camera.z);
            rayLeft.add(rayLeft, cameraPosition);
            rayRight.add(rayRight, cameraPosition);
            var p:Plane3D = new Plane3D();
            p.fromNormalAndPoint(new Number3D(0, 0, 1),new Number3D(0, 0,
0));
            var intersectLeft:Number3D =
p.getIntersectionLineNumbers(cameraPosition,rayLeft);
            var intersectRight:Number3D =
p.getIntersectionLineNumbers(cameraPosition,rayRight);

            limitLeft = intersectLeft.x;
            limitRight = intersectRight.x ;
            trace(stage.stageWidth);
            trace(rayRight);
            trace(intersectRight);
            trace("Left :" + limitLeft);
            trace("Right :" + limitRight);


Any clue ?

Thanks in advance

-- 
Luciano Santana
www.lucianosantana.net

Reply via email to