예제 #1
0
        private void UpdateInternals()
        {
            // FIXME: the half map scale is a value used throughout the implementation to rule the camera elevation
            // and the size/scale of the tiles, it depends on fixed tile size and resolution (here 256 and 72) so I am not
            // sure it would work for a tile layer with different values...
            // maybe there is a way to take the values out of the calculations and reintroduce them on Layer level...
            // FIXME: the 'division by 20000' helps the values to be kept in range for the Unity3D engine, not sure
            // this is the right approach either, feels kinda voodooish...

            halfMapScale        = GeoHelpers.OsmZoomLevelToMapScale(currentZoom, /*(float)centerWGS84[1]*/ 0.0f, tileResolution, 72) / scaleDivider;
            roundedHalfMapScale = GeoHelpers.OsmZoomLevelToMapScale(roundedZoom, (float)/*(float)centerWGS84[1]*/ 0.0f, tileResolution, 72) / scaleDivider;

            metersPerPixel        = GeoHelpers.MetersPerPixel(0.0f, (float)currentZoom);
            roundedMetersPerPixel = GeoHelpers.MetersPerPixel(0.0f, (float)roundedZoom);

            // FIXME: another voodoish value to help converting meters (EPSG 900913) to Unity3D world coordinates
            scaleMultiplier        = halfMapScale / (metersPerPixel * tileResolution);
            roundedScaleMultiplier = roundedHalfMapScale / (roundedMetersPerPixel * tileResolution);
        }
예제 #2
0
파일: Map.cs 프로젝트: cajuuh/denguewars
        // <summary>
        // Zooms the map.
        // </summary>
        public void Zoom(float zoomSpeed)
        {
            // apply the zoom
            CurrentZoom += 4.0f * zoomSpeed * Time.deltaTime;

            // move the camera
            // FIXME: the camera jumps on the first zoom when tilted, 'cause cam altitude and zoom value are unsynced by the rotation
            Transform cameraTransform = currentCamera.transform;
            float     y = GeoHelpers.OsmZoomLevelToMapScale(currentZoom, 0.0f, tileResolution, 72) / scaleDivider * screenScale;
            float     t = y / cameraTransform.forward.y;

            cameraTransform.position = new Vector3(
                t * cameraTransform.forward.x,
                y,
                t * cameraTransform.forward.z);

            // set the update flag to tell the behaviour the user is manipulating the map
            hasMoved = true;
            IsDirty  = true;
        }