Any success with scene overlay on google flash map?

Software: Away3D 3.x

spoco2, Newbie
Posted: 25 August 2011 07:00 AM   Total Posts: 4

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 *(g.focalLength g.viewportSize.x);
   var 
yBit:Number zoom *(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
000
    
0yBit00
    
00zBit0
    
0010
   ]
));
  
// googleMatrix.prepend(_flipY);
   
_viewMatrix.append(googleMatrix);
   
   
   
   return 
_viewMatrix;
  
   

spoco2, Newbie
Posted: 26 August 2011 12:03 AM   Total Posts: 4   [ # 1 ]

Hmmm, (to answer my own post),

I’m starting to think it may be more to do with the syncing of the camera positions between the Google Map camera and the Away3D one.

I have a sync function (this is all based on a papervision example from the google flash demos: Demo ) which is called whenever the map is moved:

public function sync():void
  {   
   
var g:TransformationGeometry map3D.camera.getTransformationGeometry();
   
g.cameraPosition.x;
   
g.cameraPosition.y;
   
g.cameraPosition.z;  
   
   
   var 
p:Point map3D.fromLatLngToPoint(map3D.getCenter(), 0);
   
t.p.x;
   
t.p.y;
   
t.0;
   
this.zoom map3D.camera.zoom;
   var 
upAxis:Vector3D = new Vector3D(-g.cameraYAxis.x, -g.cameraYAxis.y, -g.cameraYAxis.z);
   
lookAt(tupAxis);   
   
update();
  

And fiddling around with the upAxis is starting to make more difference I think.

Still playing though, not there yet. It’s a powerful thing to be able to do though, dropping 3D objects onto lat/lng points and have them ‘stuck’ to the map.

 

 

   

spoco2, Newbie
Posted: 26 August 2011 04:57 AM   Total Posts: 4   [ # 2 ]

Adding in a couple of images here… one of it almost lining up my chart columns correctly on the map, and one where it’s just nowhere near. This is the same code, just rotating the camera differently.

(The postcode polygons are laid on as actual google polygons as I already have the code to do that from another application that does them using the google API with no 3D overlays)

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X