Camera rotationY to 2d rotation

Software: Away3D 4.x

mario, Newbie
Posted: 22 November 2013 09:12 PM   Total Posts: 7

Hello,

I want to make a 2d rotation of arrow based on camera.rotationY.
I have tried to use Math.atan2 and get camera.x & camera.y coordinates but it wasn’t right. Than I used camera.project/view.project but still it wasn’t perfect - probably I made wrong calculations. Than I found out that camera.rotationY gives me value I need however the value is between -90 and 90 degrees. Arrow rotate correctly to -90 degrees and than bounce back. I struggling to do the full 360 rotation. Could anyone help me with that issue, please?

   

mario, Newbie
Posted: 23 November 2013 04:09 PM   Total Posts: 7   [ # 1 ]

Ok I have found something like Vector3DUtils.getAngle(). It gives me value between -180 to 180 so the 2d arrow rotates half a circle and than the movement is reversing.
I really need help with that, guys.

   

mario, Newbie
Posted: 24 November 2013 06:14 PM   Total Posts: 7   [ # 2 ]

After 3 days of scratching my head how to solve that problem I finally did it. That Vector3DUtils class is really useful. If any one need to show where the 3d camera looks on 2d sprite something like radar effect the code below shows you how to do that:

var Vector3D Vector3DUtils.rotatePoint(camera.position, new Vector3D(0,0,zoom));

var 
dx Number v.x
var 
dy Number v.z;
var 
rad Number Math.atan2(dydx);
arrow.rotation rad 180 /Math.PI 90
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X