Example #1
0
        public static Point2D GetHeightMapXYForPos(Vector3 worldPos, out Point2D tileCoord, out Point2D chunkCoord)
        {
            float tileFraction1 = PositionUtil.GetTileFraction(worldPos.X);
            float tileFraction2 = PositionUtil.GetTileFraction(worldPos.Y);
            int   tileX         = (int)tileFraction1;
            int   tileY         = (int)tileFraction2;

            PositionUtil.VerifyTileCoords(tileX, tileY);
            tileCoord = new Point2D()
            {
                X = tileX, Y = tileY
            };
            float chunkFraction1 = PositionUtil.GetChunkFraction(tileFraction1);
            float chunkFraction2 = PositionUtil.GetChunkFraction(tileFraction2);
            int   chunkX         = (int)chunkFraction1;
            int   chunkY         = (int)chunkFraction2;

            PositionUtil.VerifyPoint2D(worldPos, tileX, tileY, chunkX, chunkY);
            chunkCoord = new Point2D()
            {
                X = chunkX, Y = chunkY
            };
            int heightMapFraction1 = (int)PositionUtil.GetHeightMapFraction(chunkFraction1);
            int heightMapFraction2 = (int)PositionUtil.GetHeightMapFraction(chunkFraction2);

            return(new Point2D()
            {
                X = heightMapFraction1,
                Y = heightMapFraction2
            });
        }
Example #2
0
        public static void GetChunkXYForPos(Vector3 worldPos, out int chunkX, out int chunkY)
        {
            float tileFraction1 = PositionUtil.GetTileFraction(worldPos.X);
            float tileFraction2 = PositionUtil.GetTileFraction(worldPos.Y);

            chunkX = (int)PositionUtil.GetChunkFraction(tileFraction1);
            chunkY = (int)PositionUtil.GetChunkFraction(tileFraction2);
        }
Example #3
0
        public static HeightMapFraction GetHeightMapFraction(Vector3 worldPos, out Point2D tileCoord,
                                                             out Point2D chunkCoord, out Point2D unitCoord)
        {
            float tileFraction1 = PositionUtil.GetTileFraction(worldPos.X);
            float tileFraction2 = PositionUtil.GetTileFraction(worldPos.Y);
            int   tileX         = (int)tileFraction1;
            int   tileY         = (int)tileFraction2;

            PositionUtil.VerifyTileCoords(tileX, tileY);
            tileCoord = new Point2D()
            {
                X = tileX, Y = tileY
            };
            float chunkFraction1 = PositionUtil.GetChunkFraction(tileFraction1);
            float chunkFraction2 = PositionUtil.GetChunkFraction(tileFraction2);
            int   chunkX         = (int)chunkFraction1;
            int   chunkY         = (int)chunkFraction2;

            PositionUtil.VerifyPoint2D(worldPos, tileX, tileY, chunkX, chunkY);
            chunkCoord = new Point2D()
            {
                X = chunkX, Y = chunkY
            };
            float heightMapFraction1 = PositionUtil.GetHeightMapFraction(chunkFraction1);
            float heightMapFraction2 = PositionUtil.GetHeightMapFraction(chunkFraction2);
            int   heightMapX         = (int)heightMapFraction1;
            int   heightMapY         = (int)heightMapFraction2;

            PositionUtil.VerifyHeightMapCoord(worldPos, tileX, tileY, chunkX, chunkY, heightMapX, heightMapY);
            unitCoord = new Point2D()
            {
                X = heightMapX,
                Y = heightMapY
            };
            return(new HeightMapFraction()
            {
                FractionX = heightMapFraction1 - (float)heightMapX,
                FractionY = heightMapFraction2 - (float)heightMapY
            });
        }
Example #4
0
        public static Point2D GetXYForPos(Vector3 worldPos, out Point2D tileCoord)
        {
            float tileFraction1 = PositionUtil.GetTileFraction(worldPos.X);
            float tileFraction2 = PositionUtil.GetTileFraction(worldPos.Y);
            int   tileX         = (int)tileFraction1;
            int   tileY         = (int)tileFraction2;

            PositionUtil.VerifyTileCoords(tileX, tileY);
            tileCoord = new Point2D()
            {
                X = tileX, Y = tileY
            };
            int chunkFraction1 = (int)PositionUtil.GetChunkFraction(tileFraction1);
            int chunkFraction2 = (int)PositionUtil.GetChunkFraction(tileFraction2);

            PositionUtil.VerifyPoint2D(worldPos, (int)tileFraction1, (int)tileFraction2, chunkFraction1,
                                       chunkFraction2);
            return(new Point2D()
            {
                X = chunkFraction1,
                Y = chunkFraction2
            });
        }