# AIR and Flash Player Incubator (READ-ONLY)

Currently Being Moderated

## Away3D Broomstick - local to global coords?

### May 9, 2011 8:36 PM

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?

Replies
• Currently Being Moderated
Jun 14, 2011 9:02 AM   in reply to jblatta

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

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers
• 10,000+ points
• 1,001-10,000 points
• 501-1,000 points
• 5-500 points