Hi all,
Just discovered Away3D after having used Papervision for a while.
I have a charting app which overlays columns of data onto a flash google map (this is within a Flex app) using papervision, and I’m trying to convert it to Away3D but am having real trouble with the transformation matrices to get the google camera to line up with the Away3D camera.
It’s really close but is spinning out in odd ways when you move the camera in certain ways.
Has anyone had any luck?
Very quick paste here of code from the camera before I go home…
override public function get viewMatrix():Matrix3D{
invViewMatrix.rawData = sceneTransform.rawData;
invViewMatrix.prepend(_flipY);
_viewMatrix.rawData = invViewMatrix.rawData;
_viewMatrix.invert();
var g:TransformationGeometry = map3D.camera.getTransformationGeometry();
//Note to self, everything but the zoom is static, so make them
//be set once and then apply the zoom in matrix.
var xBit:Number = zoom *(2 * g.focalLength / g.viewportSize.x);
var yBit:Number = zoom *(2 * g.focalLength / g.viewportSize.y);
var zBit:Number = zoom*(-zf / (zn - zf));
var b:Number = zn * zf / (zn - zf);
// zn -> 0
// zf -> 1
invViewMatrix.rawData = sceneTransform.rawData;
//invViewMatrix.prepend(_flipY);
//Scaling: x:0.7267441860465116 y:1.2254901960784315 z:1.0000000100000002
/* SCALING in X, Y and Z
X, 0, 0, 0,
0, Y, 0, 0,
0, 0, Z, b,
0, 0, 1, 0
*/
trace('Scaling: x:'+xBit+' y:'+yBit+' z:'+zBit+' b:'+b+' zoom:'+zoom);
googleMatrix = new Matrix3D(Vector.<Number>([
xBit, 0, 0, 0,
0, yBit, 0, 0,
0, 0, zBit, 0,
0, 0, 1, 0
]));
// googleMatrix.prepend(_flipY);
_viewMatrix.append(googleMatrix);
return _viewMatrix;
}