1 Reply Latest reply: Jun 14, 2011 9:02 AM by Zebulon2011 RSS

    Away3D Broomstick - local to global coords?

    jblatta

      I am having a heck of a time getting the the vector3D of the 3D object translated back to normal stage x,y. Any ideas? Code Samples?

        • 1. Re: Away3D Broomstick - local to global coords?
          Zebulon2011 Community Member

          Hi,

           

          Here's a code sample to acheived these transformations ( on a mesh ).

          Maybe not the most efficient way, open to any comments in order to improve.

           

          /***************************************************************************************** **********/

          var projected_vert:Vector.<Number> = new Vector.<Number>;

          var projected_uv:Vector.<Number> = new Vector.<Number>;

           

          var camT:Matrix3D = _view3D.camera.viewProjection.clone();

          var planT:Matrix3D = mymesh.sceneTransform.clone();

          camT.prepend(planT);

           

           

          Utils3D.projectVectors( camT, vdata.vertexData, projected_vert, projected_uv );

           

          var vertsize:int = projected_vert.length;

          var correctWidth:int = _stage.stageWidth / 2;

          var correctHeight:int = _stage.stageHeight / 2;

           

           

          for (var i:int = 0; i < vertsize; i+=2 ) {

               projected_vert[i] = ( projected_vert[i] * correctWidth ) + correctWidth;

               projected_vert[i+1]  = ( projected_vert[i+1] * -correctHeight ) + correctHeight;

          }

          /***************************************************************************************** **********/

           

          projected_vert[i] -> x

          projected_vert[i+1] -> y

           

          Regards,

           

          Jeff