private void InitGraph()
        {
            // Set horizontal and vertical clip factor to different values.
            ViewportRestrictionCallback enlargeCallback = (proposedBound) =>
            {
                if (proposedBound.IsEmpty)
                {
                    return(proposedBound);
                }
                return(CoordinateUtilities.RectZoom(proposedBound, proposedBound.GetCenter(), 1, 1.05));
            };

            BpsChart.ViewportClipToBoundsEnlargeFactor = 1;
            PpsChart.ViewportClipToBoundsEnlargeFactor = 1;
            BpsChart.Viewport.FitToViewRestrictions
            .Add(new InjectionDelegateRestriction(BpsChart.Viewport, enlargeCallback));
            PpsChart.Viewport.FitToViewRestrictions
            .Add(new InjectionDelegateRestriction(PpsChart.Viewport, enlargeCallback));

            // Disable zoom and pan
            BpsChart.Children.Remove(BpsChart.MouseNavigation);
            BpsChart.Children.Remove(BpsChart.KeyboardNavigation);
            BpsChart.Children.Remove(BpsChart.HorizontalAxisNavigation);
            BpsChart.Children.Remove(BpsChart.VerticalAxisNavigation);
            BpsChart.DefaultContextMenu.RemoveFromPlotter();

            PpsChart.Children.Remove(PpsChart.MouseNavigation);
            PpsChart.Children.Remove(PpsChart.KeyboardNavigation);
            PpsChart.Children.Remove(PpsChart.HorizontalAxisNavigation);
            PpsChart.Children.Remove(PpsChart.VerticalAxisNavigation);
            PpsChart.DefaultContextMenu.RemoveFromPlotter();

            ResetLineChart(BpsChart);
            ResetLineChart(PpsChart);
        }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        // get reference to player Instance for transformations
        rigi = GetComponent <Rigidbody>();

        // Initialize with Startpoint
        coordUtil = new CoordinateUtilities(tmplat, tmplon, 0.00);

        // Testing if it works
        double[] enu2 = coordUtil.geo_to_enu(tmplat, tmplon, 0.00);
        Debug.Log("ENU: X: " + enu2[0] + ", Y: " + enu2[1]);

        // Call for Location Permission
        if (!Permission.HasUserAuthorizedPermission("android.permission.ACCESS_FINE_LOCATION"))
        {
            Permission.RequestUserPermission("android.permission.ACCESS_FINE_LOCATION");
            Permission.RequestUserPermission("android.permission.ACCESS_COARSE_LOCATION");
            Permission.RequestUserPermission("android.permission.TYPE_ORIENTATION");
        }

        // initialize lerping
        lastTime = Time.time;
        int   index   = 0;
        float strecke = 0;
    }
Exemple #3
0
 //  Wrapper for both geo2ecef And ecef2enu
 //  Input Arguments: current poSintion latitude, current poSintion longitude, current poSintion altitude
 public double[] geo_to_enu(double lat, double lon, double alt)
 {
     double[] ecef = CoordinateUtilities.geo_to_ecef(lat, lon, alt);
     double[] enu  = this.ecef_to_enu(ecef[0], ecef[1], ecef[2], this.centerLat, this.centerLon, centerAlt);
     // Log.i("ENU in geo2enu func","X = " + enu[0] + ", Y = " + enu[1] + ", Z = " + enu[2]);
     return(enu);
 }
Exemple #4
0
    // Start is called before the first frame update
    void Start()
    {
        double lat = 49;
        double lon = 11;
        double alt = 0;

        CoordinateUtilities kompass_test = new CoordinateUtilities(lat, lon, alt);

        double[] enu = kompass_test.geo_to_enu(lat, lon, alt);
        print("enu = " + enu[0] + "," + enu[1]);
    }
Exemple #5
0
        private void MouseWheelZoom(Point mousePos, double wheelRotationDelta)
        {
            Point zoomTo = mousePos.ScreenToViewport(Viewport.Transform);

            double zoomSpeed = Math.Abs(wheelRotationDelta / Mouse.MouseWheelDeltaForOneLine);

            zoomSpeed *= wheelZoomSpeed;
            if (wheelRotationDelta < 0)
            {
                zoomSpeed = 1 / zoomSpeed;
            }
            //Viewport.Visible = Viewport.Visible.Zoom(zoomTo, zoomSpeed);
            Viewport.Visible = CoordinateUtilities.RectZoomX(Viewport.Visible, zoomTo, zoomSpeed);
        }
Exemple #6
0
        public void GetChunkCoordinatesContainingPoint_Test4()
        {
            int3 worldPosition = new int3(5, 3, 16);
            int  chunkSize     = 16;

            IEnumerable <int3> coordinates = CoordinateUtilities.GetChunkCoordinatesContainingPoint(worldPosition, chunkSize);

            IEnumerable <int3> expectedCoordinates = new List <int3>
            {
                new int3(0, 0, 1),
                new int3(0, 0, 0),
            };

            Assert.That(coordinates, Is.EquivalentTo(expectedCoordinates));
        }
Exemple #7
0
        /// <summary>
        /// Set's the data value of the voxel data point at <paramref name="dataWorldPosition"/> to <paramref name="dataValue"/>
        /// </summary>
        /// <param name="dataWorldPosition">The world position of the data point</param>
        /// <param name="dataValue">The new data value of the data point</param>
        public void SetData(int3 dataWorldPosition, T dataValue)
        {
            int3[] affectedChunkCoordinates = CoordinateUtilities.GetChunkCoordinatesContainingPoint(dataWorldPosition, VoxelWorld.WorldSettings.ChunkSize);

            for (int i = 0; i < affectedChunkCoordinates.Length; i++)
            {
                int3 chunkCoordinate = affectedChunkCoordinates[i];
                if (TryGetDataChunk(chunkCoordinate, out VoxelDataVolume <T> chunkData))
                {
                    int3 localPos = (dataWorldPosition - chunkCoordinate * VoxelWorld.WorldSettings.ChunkSize).Mod(VoxelWorld.WorldSettings.ChunkSize + 1);

                    chunkData.SetVoxelData(dataValue, localPos);

                    if (VoxelWorld.ChunkStore.TryGetDataChunk(chunkCoordinate, out ChunkProperties chunkProperties))
                    {
                        chunkProperties.HasChanges = true;
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Generates terrain around <paramref name="coordinate"/> with a radius of <see cref="renderDistance"/>
        /// </summary>
        /// <param name="coordinate">The coordinate to generate the terrain around</param>
        private void GenerateTerrainAroundCoordinate(int3 coordinate)
        {
            // Start generating voxel data for chunks with radius 'renderDistance + loadingBufferSize'
            int3[] preloadCoordinates = CoordinateUtilities.GetPreloadCoordinates(coordinate, renderDistance, loadingBufferSize);
            for (int i = 0; i < preloadCoordinates.Length; i++)
            {
                int3 loadingCoordinate = preloadCoordinates[i];
                voxelWorld.VoxelDataStore.GenerateDataForChunk(loadingCoordinate);
            }

            // Generate chunks with radius 'renderDistance'
            int3[] chunkGenerationCoordinates = CoordinateUtilities.GetChunkGenerationCoordinates(coordinate, renderDistance);
            for (int i = 0; i < chunkGenerationCoordinates.Length; i++)
            {
                int3 generationCoordinate = chunkGenerationCoordinates[i];
                voxelWorld.VoxelColorStore.GenerateDataForChunk(generationCoordinate);
                chunkProvider.EnsureChunkExistsAtCoordinate(generationCoordinate);
            }

            _lastGenerationCoordinate = coordinate;
        }
Exemple #9
0
        public override void Render(DrawingContext dc, Point screenPoint)
        {
            FormattedText textToDraw = new FormattedText(Text, Thread.CurrentThread.CurrentCulture,
                                                         FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);

            double width  = textToDraw.Width;
            double height = textToDraw.Height;

            const double verticalShift = -20;             // px

            Rect bounds = RectExtensions.FromCenterSize(new Point(screenPoint.X, screenPoint.Y + verticalShift - height / 2),
                                                        new Size(width, height));

            Point loc = bounds.Location;

            bounds = CoordinateUtilities.RectZoom(bounds, 1.05, 1.15);

            dc.DrawLine(new Pen(Brushes.Black, 1), Point.Add(screenPoint, new Vector(0, verticalShift)), screenPoint);
            dc.DrawRectangle(Brushes.White, new Pen(Brushes.Black, 1), bounds);
            dc.DrawText(textToDraw, loc);
        }
Exemple #10
0
        private void Update()
        {
            int3 newPlayerCoordinate = GetPlayerCoordinate();

            if (!newPlayerCoordinate.Equals(_lastGenerationCoordinate))
            {
                MoveVoxelData(_lastGenerationCoordinate, newPlayerCoordinate);

                var newlyFreedCoordinates = voxelWorld.ChunkStore.GetChunkCoordinatesOutsideOfRange(newPlayerCoordinate, renderDistance);

                int3 renderSize = new int3(renderDistance * 2 + 1);

                int3      oldPos    = _lastGenerationCoordinate - new int3(renderDistance);
                BoundsInt oldCoords = new BoundsInt(oldPos.ToVectorInt(), renderSize.ToVectorInt());

                int3      newPos    = newPlayerCoordinate - new int3(renderDistance);
                BoundsInt newCoords = new BoundsInt(newPos.ToVectorInt(), renderSize.ToVectorInt());

                int3[] coordinatesThatNeedChunks = CoordinateUtilities.GetCoordinatesThatNeedChunks(oldCoords, newCoords);

                int i = 0;
                foreach (int3 source in newlyFreedCoordinates)
                {
                    int3 target = coordinatesThatNeedChunks[i];

                    // Move chunk gameobjects
                    voxelWorld.ChunkStore.MoveChunk(source, target);

                    // Move colors and generate new
                    voxelWorld.VoxelColorStore.MoveChunk(source, target);

                    chunkProvider.AddChunkToGenerationQueue(target);

                    i++;
                }

                _lastGenerationCoordinate = newPlayerCoordinate;
            }
        }
Exemple #11
0
        /// <summary>
        /// Moves all of the voxel data that existed when the player was at the coordinate <paramref name="playerFromCoordinate"/> to the coordinates that don't yet have data but should have when the player is at coordinate <paramref name="playerToCoordinate"/>
        /// </summary>
        /// <param name="playerFromCoordinate">The old coordinate of the player</param>
        /// <param name="playerToCoordinate">The new coordinate of the player</param>
        private void MoveVoxelData(int3 playerFromCoordinate, int3 playerToCoordinate)
        {
            int  range      = renderDistance + loadingBufferSize;
            int3 renderSize = new int3(range * 2 + 1);

            int3      oldPos    = playerFromCoordinate - new int3(range);
            BoundsInt oldCoords = new BoundsInt(oldPos.ToVectorInt(), renderSize.ToVectorInt());

            int3      newPos    = playerToCoordinate - new int3(range);
            BoundsInt newCoords = new BoundsInt(newPos.ToVectorInt(), renderSize.ToVectorInt());

            int3[] coordinatesThatNeedData = CoordinateUtilities.GetCoordinatesThatNeedChunks(oldCoords, newCoords);

            var newlyFreedCoordinates = voxelWorld.VoxelDataStore.GetChunkCoordinatesOutsideOfRange(playerToCoordinate, range);

            int i = 0;

            foreach (int3 freeCoordinate in newlyFreedCoordinates)
            {
                var targetCoordinate = coordinatesThatNeedData[i];
                voxelWorld.VoxelDataStore.MoveChunk(freeCoordinate, targetCoordinate);
                i++;
            }
        }