public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            if (_customImage == null)
            {
                return(null);
            }

            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            var positions = GetGridlineIntersectionPositionsOrthographicView();

            for (int i = positions.Count - 1; i >= 0; i--)
            {
                var position = positions[i];
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(position.x, position.y, position.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? _imageSize * Config.CurrentMapGraphics.MapViewScaleValue : _imageSize;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, position.x, position.y, position.z, index: i));
                }
            }
            return(null);
        }
Example #2
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            List <(float x, float y, float z)> data = GetData();

            for (int i = data.Count - 1; i >= 0; i--)
            {
                var dataPoint = data[i];
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(dataPoint.x, dataPoint.y, dataPoint.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? Size * Config.CurrentMapGraphics.MapViewScaleValue : Size;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, index: i));
                }
            }
            return(null);
        }
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            if (_customImage == null)
            {
                return(null);
            }

            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            (double x, double y, double z)   = PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
            (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView((float)x, (float)y, (float)z, UseRelativeCoordinates);
            double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
            double radius = Scales ? _iconSize * Config.CurrentMapGraphics.MapViewScaleValue : _iconSize;

            if (dist <= radius || forceCursorPosition)
            {
                return(new MapObjectHoverData(this, x, y, z));
            }
            return(null);
        }
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            var quadList = GetQuadList(null);

            for (int i = quadList.Count - 1; i >= 0; i--)
            {
                var quad           = quadList[i];
                var quadForControl = quad.ConvertAll(p => MapUtilities.ConvertCoordsForControlOrthographicView(p.x, p.y, p.z, UseRelativeCoordinates));
                if (MapUtilities.IsWithinShapeForControl(quadForControl, relPos.X, relPos.Y) || forceCursorPosition)
                {
                    double xMin = quad.Min(p => p.x);
                    double xMax = quad.Max(p => p.x);
                    double zMin = quad.Min(p => p.z);
                    double zMax = quad.Max(p => p.z);
                    string info = string.Format("{0}<x<{1} {2}<z<{3}", xMin, xMax, zMin, zMax);
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i, info: info));
                }
            }
            return(null);
        }
Example #5
0
        public override void DrawOn2DControlOrthographicView()
        {
            (double x, double y, double z, double angle) = GetPositionAngle().GetValues();
            (float xPosPixels, float yPosPixels)         = MapUtilities.ConvertCoordsForControlOrthographicView((float)x, (float)y, (float)z);
            float angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
            SizeF size         = MapUtilities.ScaleImageSizeForControl(Image.Size, Size);

            MapUtilities.DrawTexture(TextureId, new PointF(xPosPixels, yPosPixels), size, angleDegrees, Opacity);
        }
Example #6
0
        private List <(float centerX, float centerZ, float radius, Color color)> GetOrthographicDimensionsForControl()
        {
            return(Get3DDimensions().ConvertAll(dimension =>
            {
                if (!_useCrossSection)
                {
                    (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                        dimension.centerX, dimension.centerY, dimension.centerZ, UseRelativeCoordinates);
                    float radius = dimension.radius3D * Config.CurrentMapGraphics.MapViewScaleValue;
                    return (x, z, radius, dimension.color);
                }
                switch (Config.CurrentMapGraphics.MapViewYawValue)
                {
                case 0:
                case 32768:
                    {
                        float zDiff = Config.CurrentMapGraphics.MapViewCenterZValue - dimension.centerZ;
                        float xDistSquared = dimension.radius3D * dimension.radius3D - zDiff * zDiff;
                        float xDist = xDistSquared >= 0 ? (float)Math.Sqrt(xDistSquared) : 0;
                        float radius = xDist * Config.CurrentMapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ, UseRelativeCoordinates);
                        return (x, z, radius, dimension.color);
                    }

                case 16384:
                case 49152:
                    {
                        float xDiff = Config.CurrentMapGraphics.MapViewCenterXValue - dimension.centerX;
                        float zDistSquared = dimension.radius3D * dimension.radius3D - xDiff * xDiff;
                        float zDist = zDistSquared >= 0 ? (float)Math.Sqrt(zDistSquared) : 0;
                        float radius = zDist * Config.CurrentMapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ, UseRelativeCoordinates);
                        return (x, z, radius, dimension.color);
                    }

                default:
                    {
                        float aDiff = (float)MoreMath.GetPlaneDistanceToPoint(
                            Config.CurrentMapGraphics.MapViewCenterXValue, Config.CurrentMapGraphics.MapViewCenterYValue,
                            Config.CurrentMapGraphics.MapViewCenterZValue, Config.CurrentMapGraphics.MapViewYawValue, Config.CurrentMapGraphics.MapViewPitchValue,
                            dimension.centerX, dimension.centerY, dimension.centerZ);
                        float bDistSquared = dimension.radius3D * dimension.radius3D - aDiff * aDiff;
                        float bDist = bDistSquared >= 0 ? (float)Math.Sqrt(bDistSquared) : 0;
                        float radius = bDist * Config.CurrentMapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ, UseRelativeCoordinates);
                        return (x, z, radius, dimension.color);
                    }
                }
            }));
        }
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            (double x, double y, double z, double angle) = GetPositionAngle().GetValues();
            (float xPosPixels, float yPosPixels)         = MapUtilities.ConvertCoordsForControlOrthographicView((float)x, (float)y, (float)z, UseRelativeCoordinates);
            float  angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
            SizeF  size         = MapUtilities.ScaleImageSizeForControl(Image.Size, GetSize(), Scales);
            double opacity      = Opacity;

            if (this == hoverData?.MapObject)
            {
                opacity = MapUtilities.GetHoverOpacity();
            }
            MapUtilities.DrawTexture(TextureId, new PointF(xPosPixels, yPosPixels), size, angleDegrees, opacity);
        }
        public override void DrawOn2DControlOrthographicView()
        {
            List <(float x, float y, float z, float angle, int tex)> data = GetData();

            data.Reverse();
            foreach (var dataPoint in data)
            {
                (float x, float y, float z, float angle, int tex) = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z);
                float  angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
                SizeF  size         = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size);
                PointF point        = new PointF(positionOnControl.x, positionOnControl.z);
                MapUtilities.DrawTexture(tex, point, size, angleDegrees, Opacity);
            }
        }
Example #9
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <List <(float x, float y, float z, Color color, bool isHovered)> > quadList           = GetQuadList3D() ?? GetQuadList(hoverData);
            List <List <(float x, float z, Color color, bool isHovered)> >          quadListForControl =
                quadList.ConvertAll(quad => quad.ConvertAll(
                                        vertex =>
            {
                (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(vertex.x, vertex.y, vertex.z, UseRelativeCoordinates);
                return(x, z, vertex.color, vertex.isHovered);
            }));

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            // Draw quad
            GL.Begin(PrimitiveType.Quads);
            foreach (List <(float x, float z, Color color, bool isHovered)> quad in quadListForControl)
            {
                foreach ((float x, float z, Color color, bool isHovered) in quad)
                {
                    byte opacityByte = isHovered ? MapUtilities.GetHoverOpacityByte() : OpacityByte;
                    GL.Color4(color.R, color.G, color.B, opacityByte);
                    GL.Vertex2(x, z);
                }
            }
            GL.End();

            // Draw outline
            if (LineWidth != 0)
            {
                GL.Color4(LineColor.R, LineColor.G, LineColor.B, (byte)255);
                GL.LineWidth(LineWidth);
                foreach (List <(float x, float z, Color color, bool isHovered)> quad in quadListForControl)
                {
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z, Color color, bool isHovered) in quad)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            base.DrawOn2DControlOrthographicView(hoverData);

            if (_customImage != null)
            {
                (float x, float y, float z)      = ((float, float, float))PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                PointF point   = new PointF(controlX, controlZ);
                SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _iconSize, Scales);
                double opacity = Opacity;
                if (this == hoverData?.MapObject)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(_customImageTex.Value, point, size, 0, opacity);
            }
        }
Example #11
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <(float x, float y, float z, float angle, int tex)> data = GetData();

            for (int i = data.Count - 1; i >= 0; i--)
            {
                var dataPoint = data[i];
                (float x, float y, float z, float angle, int tex) = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                float  angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
                SizeF  size         = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size, Scales);
                PointF point        = new PointF(positionOnControl.x, positionOnControl.z);
                double opacity      = Opacity;
                if (this == hoverData?.MapObject && i == hoverData?.Index)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(tex, point, size, angleDegrees, opacity);
            }
        }
Example #12
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <(float x, float y, float z, float angle, bool rotates, Image image, int tex, uint objAddress)> data = GetData();

            data.Reverse();
            foreach (var dataPoint in data)
            {
                (float x, float y, float z, float angle, bool rotates, Image image, int tex, uint objAddress) = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                float  angleDegrees = (CustomRotates ?? rotates) ? MapUtilities.ConvertAngleForControl(angle) : 0;
                SizeF  size         = MapUtilities.ScaleImageSizeForControl(image.Size, Size, Scales);
                PointF point        = new PointF(positionOnControl.x, positionOnControl.z);
                double opacity      = Opacity;
                if (this == hoverData?.MapObject && dataPoint.objAddress == hoverData?.ObjAddress)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(tex, point, size, angleDegrees, opacity);
            }
        }
Example #13
0
        public override void DrawOn2DControlOrthographicView()
        {
            List <List <(float x, float y, float z)> > quadList           = GetQuadList();
            List <List <(float x, float z)> >          quadListForControl =
                quadList.ConvertAll(quad => quad.ConvertAll(
                                        vertex => MapUtilities.ConvertCoordsForControlOrthographicView(vertex.x, vertex.y, vertex.z)));

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            // Draw quad
            GL.Color4(Color.R, Color.G, Color.B, OpacityByte);
            GL.Begin(PrimitiveType.Quads);
            foreach (List <(float x, float z)> quad in quadListForControl)
            {
                foreach ((float x, float z) in quad)
                {
                    GL.Vertex2(x, z);
                }
            }
            GL.End();

            // Draw outline
            if (OutlineWidth != 0)
            {
                GL.Color4(OutlineColor.R, OutlineColor.G, OutlineColor.B, (byte)255);
                GL.LineWidth(OutlineWidth);
                foreach (List <(float x, float z)> quad in quadListForControl)
                {
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z) in quad)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
Example #14
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            base.DrawOn2DControlOrthographicView(hoverData);

            if (_customImage != null)
            {
                List <(float x, float y, float z)> positions = GetGridlineIntersectionPositionsOrthographicView();
                for (int i = 0; i < positions.Count; i++)
                {
                    (float x, float y, float z)      = positions[i];
                    (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                    SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _imageSize, Scales);
                    double opacity = Opacity;
                    if (this == hoverData?.MapObject && i == hoverData?.Index)
                    {
                        opacity = MapUtilities.GetHoverOpacity();
                    }
                    MapUtilities.DrawTexture(_customImageTex.Value, new PointF(controlX, controlZ), size, 0, opacity);
                }
            }
        }
Example #15
0
        public override void DrawOn2DControlOrthographicView(MapObjectHoverData hoverData)
        {
            List <(float x, float y, float z)> data = GetData();

            for (int i = 0; i < data.Count; i++)
            {
                var dataPoint = data[i];
                (float x, float y, float z)         = dataPoint;
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z, UseRelativeCoordinates);
                SizeF  size    = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size, Scales);
                PointF point   = new PointF(positionOnControl.x, positionOnControl.z);
                double opacity = Opacity;
                if (this == hoverData?.MapObject && i == hoverData?.Index)
                {
                    opacity = MapUtilities.GetHoverOpacity();
                }
                MapUtilities.DrawTexture(_customImageTex ?? _tex, point, size, 0, opacity);
            }

            if (LineWidth != 0)
            {
                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Color4(LineColor.R, LineColor.G, LineColor.B, OpacityByte);
                GL.LineWidth(LineWidth);
                GL.Begin(PrimitiveType.Lines);
                for (int i = 0; i < data.Count - 1; i++)
                {
                    (float x1, float y1, float z1)      = data[i];
                    (float x2, float y2, float z2)      = data[i + 1];
                    (float x, float z)vertex1ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x1, y1, z1, UseRelativeCoordinates);
                    (float x, float z)vertex2ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x2, y2, z2, UseRelativeCoordinates);
                    GL.Vertex2(vertex1ForControl.x, vertex1ForControl.z);
                    GL.Vertex2(vertex2ForControl.x, vertex2ForControl.z);
                }
                GL.End();
                GL.Color4(1, 1, 1, 1.0f);
            }
        }
Example #16
0
        public override void DrawOn2DControlOrthographicView()
        {
            List <(float x, float y, float z, float angle, int tex, bool show)> data = GetData();

            foreach (var dataPoint in data)
            {
                (float x, float y, float z, float angle, int tex, bool show) = dataPoint;
                if (!show)
                {
                    continue;
                }
                (float x, float z)positionOnControl = MapUtilities.ConvertCoordsForControlOrthographicView(x, y, z);
                float  angleDegrees = Rotates ? MapUtilities.ConvertAngleForControl(angle) : 0;
                SizeF  size         = MapUtilities.ScaleImageSizeForControl(Config.ObjectAssociations.BlueMarioMapImage.Size, Size);
                PointF point        = new PointF(positionOnControl.x, positionOnControl.z);
                MapUtilities.DrawTexture(tex, point, size, angleDegrees, Opacity);
            }

            if (OutlineWidth != 0)
            {
                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.Color4(OutlineColor.R, OutlineColor.G, OutlineColor.B, OpacityByte);
                GL.LineWidth(OutlineWidth);
                GL.Begin(PrimitiveType.Lines);
                for (int i = 0; i < data.Count - 1; i++)
                {
                    (float x1, float y1, float z1, float angle1, int tex1, bool show1) = data[i];
                    (float x2, float y2, float z2, float angle2, int tex2, bool show2) = data[i + 1];
                    (float x, float z)vertex1ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x1, y1, z1);
                    (float x, float z)vertex2ForControl = MapUtilities.ConvertCoordsForControlOrthographicView(x2, y2, z2);
                    GL.Vertex2(vertex1ForControl.x, vertex1ForControl.z);
                    GL.Vertex2(vertex2ForControl.x, vertex2ForControl.z);
                }
                GL.End();
                GL.Color4(1, 1, 1, 1.0f);
            }
        }
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            var quadList = GetQuadList(null);

            for (int i = quadList.Count - 1; i >= 0; i--)
            {
                var quad           = quadList[i];
                var quadForControl = quad.ConvertAll(p => MapUtilities.ConvertCoordsForControlOrthographicView(p.x, p.y, p.z, UseRelativeCoordinates));
                if (MapUtilities.IsWithinShapeForControl(quadForControl, relPos.X, relPos.Y) || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, 0, 0, 0, index: i));
                }
            }
            return(null);
        }
Example #18
0
        public override void DrawOn2DControlOrthographicView()
        {
            if (OutlineWidth == 0)
            {
                return;
            }

            List <(float x, float y, float z)> vertices            = GetVerticesOrthographicView();
            List <(float x, float z)>          veriticesForControl =
                vertices.ConvertAll(vertex => MapUtilities.ConvertCoordsForControlOrthographicView(vertex.x, vertex.y, vertex.z));

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Color4(OutlineColor.R, OutlineColor.G, OutlineColor.B, OpacityByte);
            GL.LineWidth(OutlineWidth);
            GL.Begin(PrimitiveType.Lines);
            foreach ((float x, float z) in veriticesForControl)
            {
                GL.Vertex2(x, z);
            }
            GL.End();
            GL.Color4(1, 1, 1, 1.0f);
        }
Example #19
0
        public override MapObjectHoverData GetHoverDataOrthographicView(bool isForObjectDrag, bool forceCursorPosition)
        {
            Point?relPosMaybe = MapObjectHoverData.GetPositionMaybe(isForObjectDrag, forceCursorPosition);

            if (!relPosMaybe.HasValue)
            {
                return(null);
            }
            Point relPos = relPosMaybe.Value;

            List <(float x, float y, float z, float angle, bool rotates, Image image, int tex, uint objAddress)> data = GetData();

            foreach (var dataPoint in data)
            {
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlOrthographicView(dataPoint.x, dataPoint.y, dataPoint.z, UseRelativeCoordinates);
                double dist   = MoreMath.GetDistanceBetween(controlX, controlZ, relPos.X, relPos.Y);
                double radius = Scales ? Size * Config.CurrentMapGraphics.MapViewScaleValue : Size;
                if (dist <= radius || forceCursorPosition)
                {
                    return(new MapObjectHoverData(this, dataPoint.x, dataPoint.y, dataPoint.z, objAddress: dataPoint.objAddress));
                }
            }
            return(null);
        }
Example #20
0
        public override void DrawOn2DControlOrthographicView()
        {
            List <(float centerX, float centerZ, float radius)> dimensionList = Get3DDimensions().ConvertAll(dimension =>
            {
                switch (Config.MapGraphics.MapViewYawValue)
                {
                case 0:
                case 32768:
                    {
                        float zDiff        = Config.MapGraphics.MapViewCenterZValue - dimension.centerZ;
                        float xDistSquared = dimension.radius3D * dimension.radius3D - zDiff * zDiff;
                        float xDist        = xDistSquared >= 0 ? (float)Math.Sqrt(xDistSquared) : 0;
                        float radius       = xDist * Config.MapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ);
                        return(x, z, radius);
                    }

                case 16384:
                case 49152:
                    {
                        float xDiff        = Config.MapGraphics.MapViewCenterXValue - dimension.centerX;
                        float zDistSquared = dimension.radius3D * dimension.radius3D - xDiff * xDiff;
                        float zDist        = zDistSquared >= 0 ? (float)Math.Sqrt(zDistSquared) : 0;
                        float radius       = zDist * Config.MapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ);
                        return(x, z, radius);
                    }

                default:
                    {
                        float aDiff = (float)MoreMath.GetPlaneDistanceToPoint(
                            Config.MapGraphics.MapViewCenterXValue, Config.MapGraphics.MapViewCenterYValue,
                            Config.MapGraphics.MapViewCenterZValue, Config.MapGraphics.MapViewYawValue, Config.MapGraphics.MapViewPitchValue,
                            dimension.centerX, dimension.centerY, dimension.centerZ);
                        float bDistSquared = dimension.radius3D * dimension.radius3D - aDiff * aDiff;
                        float bDist        = bDistSquared >= 0 ? (float)Math.Sqrt(bDistSquared) : 0;
                        float radius       = bDist * Config.MapGraphics.MapViewScaleValue;
                        (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(
                            dimension.centerX, dimension.centerY, dimension.centerZ);
                        return(x, z, radius);
                    }
                }
            });

            foreach ((float controlCenterX, float controlCenterZ, float controlRadius) in dimensionList)
            {
                List <(float pointX, float pointZ)> controlPoints = Enumerable.Range(0, SpecialConfig.MapCircleNumPoints2D).ToList()
                                                                    .ConvertAll(index => (index / (float)SpecialConfig.MapCircleNumPoints2D) * 65536)
                                                                    .ConvertAll(angle => ((float, float))MoreMath.AddVectorToPoint(controlRadius, angle, controlCenterX, controlCenterZ));

                GL.BindTexture(TextureTarget.Texture2D, -1);
                GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();

                // Draw circle
                GL.Color4(Color.R, Color.G, Color.B, OpacityByte);
                GL.Begin(PrimitiveType.TriangleFan);
                GL.Vertex2(controlCenterX, controlCenterZ);
                foreach ((float x, float z) in controlPoints)
                {
                    GL.Vertex2(x, z);
                }
                GL.Vertex2(controlPoints[0].pointX, controlPoints[0].pointZ);
                GL.End();

                // Draw outline
                if (OutlineWidth != 0)
                {
                    GL.Color4(OutlineColor.R, OutlineColor.G, OutlineColor.B, (byte)255);
                    GL.LineWidth(OutlineWidth);
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z) in controlPoints)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }
Example #21
0
        private List <List <(float x, float z, Color color)> > GetOrthographicDimensionsForControl()
        {
            List <List <(float x, float y, float z, Color color)> > vertexLists = Get3DDimensions().ConvertAll(dimension =>
            {
                if (_useCrossSection)
                {
                    double dist = MoreMath.GetDistanceBetween(
                        Config.CurrentMapGraphics.MapViewCenterXValue,
                        Config.CurrentMapGraphics.MapViewCenterZValue,
                        dimension.centerX,
                        dimension.centerZ);
                    double angle = MoreMath.AngleTo_AngleUnits(
                        Config.CurrentMapGraphics.MapViewCenterXValue,
                        Config.CurrentMapGraphics.MapViewCenterZValue,
                        dimension.centerX,
                        dimension.centerZ);
                    (double sidewaysDist, double forwardsDist) =
                        MoreMath.GetComponentsFromVectorRelatively(
                            dist, angle, Config.CurrentMapGraphics.MapViewYawValue);
                    if (forwardsDist > dimension.radius || forwardsDist < -1 * dimension.radius)
                    {
                        return(null);
                    }
                    (double pointX, double pointZ) = MoreMath.AddVectorToPoint(
                        -1 * forwardsDist,
                        Config.CurrentMapGraphics.MapViewYawValue,
                        dimension.centerX,
                        dimension.centerZ);
                    double legDist             = Math.Sqrt(dimension.radius * dimension.radius - forwardsDist * forwardsDist);
                    (float leftX, float leftZ) = ((float, float))MoreMath.AddVectorToPoint(
                        legDist, Config.CurrentMapGraphics.MapViewYawValue + 16384, pointX, pointZ);
                    (float rightX, float rightZ) = ((float, float))MoreMath.AddVectorToPoint(
                        legDist, Config.CurrentMapGraphics.MapViewYawValue - 16384, pointX, pointZ);
                    return(new List <(float x, float y, float z, Color color)>()
                    {
                        (leftX, dimension.minY, leftZ, dimension.color),
                        (rightX, dimension.minY, rightZ, dimension.color),
                        (rightX, dimension.maxY, rightZ, dimension.color),
                        (leftX, dimension.maxY, leftZ, dimension.color),
                    });
                }
                switch (Config.CurrentMapGraphics.MapViewYawValue)
                {
                case 0:
                case 32768:
                    return(new List <(float x, float y, float z, Color color)>()
                    {
                        (dimension.centerX - dimension.radius, dimension.minY, dimension.centerZ, dimension.color),
                        (dimension.centerX + dimension.radius, dimension.minY, dimension.centerZ, dimension.color),
                        (dimension.centerX + dimension.radius, dimension.maxY, dimension.centerZ, dimension.color),
                        (dimension.centerX - dimension.radius, dimension.maxY, dimension.centerZ, dimension.color),
                    });

                case 16384:
                case 49152:
                    return(new List <(float x, float y, float z, Color color)>()
                    {
                        (dimension.centerX, dimension.minY, dimension.centerZ - dimension.radius, dimension.color),
                        (dimension.centerX, dimension.minY, dimension.centerZ + dimension.radius, dimension.color),
                        (dimension.centerX, dimension.maxY, dimension.centerZ + dimension.radius, dimension.color),
                        (dimension.centerX, dimension.maxY, dimension.centerZ - dimension.radius, dimension.color),
                    });

                default:
                    double sideAngle = MoreMath.RotateAngleCW(Config.CurrentMapGraphics.MapViewYawValue, 16384);
                    (float sideDiffX, float sideDiffZ) = ((float, float))MoreMath.GetComponentsFromVector(dimension.radius, sideAngle);
                    return(new List <(float x, float y, float z, Color color)>()
                    {
                        (dimension.centerX - sideDiffX, dimension.minY, dimension.centerZ - sideDiffZ, dimension.color),
                        (dimension.centerX + sideDiffX, dimension.minY, dimension.centerZ + sideDiffZ, dimension.color),
                        (dimension.centerX + sideDiffX, dimension.maxY, dimension.centerZ + sideDiffZ, dimension.color),
                        (dimension.centerX - sideDiffX, dimension.maxY, dimension.centerZ - sideDiffZ, dimension.color),
                    });
                }
            }).FindAll(list => list != null);

            List <List <(float x, float z, Color color)> > vertexListsForControl =
                vertexLists.ConvertAll(vertexList => vertexList.ConvertAll(
                                           vertex =>
            {
                (float x, float z) = MapUtilities.ConvertCoordsForControlOrthographicView(vertex.x, vertex.y, vertex.z, UseRelativeCoordinates);
                return(x, z, vertex.color);
            }));

            return(vertexListsForControl);
        }
Example #22
0
        public override void DrawOn2DControlOrthographicView()
        {
            List <List <(float x, float y, float z)> > vertexLists = Get3DDimensions().ConvertAll(dimension =>
            {
                switch (Config.MapGraphics.MapViewYawValue)
                {
                case 0:
                case 32768:
                    return(new List <(float x, float y, float z)>()
                    {
                        (dimension.centerX - dimension.radius, dimension.minY, dimension.centerZ),
                        (dimension.centerX + dimension.radius, dimension.minY, dimension.centerZ),
                        (dimension.centerX + dimension.radius, dimension.maxY, dimension.centerZ),
                        (dimension.centerX - dimension.radius, dimension.maxY, dimension.centerZ),
                    });

                case 16384:
                case 49152:
                    return(new List <(float x, float y, float z)>()
                    {
                        (dimension.centerX, dimension.minY, dimension.centerZ - dimension.radius),
                        (dimension.centerX, dimension.minY, dimension.centerZ + dimension.radius),
                        (dimension.centerX, dimension.maxY, dimension.centerZ + dimension.radius),
                        (dimension.centerX, dimension.maxY, dimension.centerZ - dimension.radius),
                    });

                default:
                    double sideAngle = MoreMath.RotateAngleCW(Config.MapGraphics.MapViewYawValue, 16384);
                    (float sideDiffX, float sideDiffZ) = ((float, float))MoreMath.GetComponentsFromVector(dimension.radius, sideAngle);
                    return(new List <(float x, float y, float z)>()
                    {
                        (dimension.centerX - sideDiffX, dimension.minY, dimension.centerZ - sideDiffZ),
                        (dimension.centerX + sideDiffX, dimension.minY, dimension.centerZ + sideDiffZ),
                        (dimension.centerX + sideDiffX, dimension.maxY, dimension.centerZ + sideDiffZ),
                        (dimension.centerX - sideDiffX, dimension.maxY, dimension.centerZ - sideDiffZ),
                    });
                }
            });

            List <List <(float x, float z)> > vertexListsForControl =
                vertexLists.ConvertAll(vertexList => vertexList.ConvertAll(
                                           vertex => MapUtilities.ConvertCoordsForControlOrthographicView(vertex.x, vertex.y, vertex.z)));

            GL.BindTexture(TextureTarget.Texture2D, -1);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();

            // Draw triangle
            GL.Color4(Color.R, Color.G, Color.B, OpacityByte);
            foreach (List <(float x, float z)> vertexList in vertexListsForControl)
            {
                GL.Begin(PrimitiveType.Polygon);
                foreach ((float x, float z) in vertexList)
                {
                    GL.Vertex2(x, z);
                }
                GL.End();
            }

            // Draw outline
            if (OutlineWidth != 0)
            {
                GL.Color4(OutlineColor.R, OutlineColor.G, OutlineColor.B, (byte)255);
                GL.LineWidth(OutlineWidth);
                foreach (List <(float x, float z)> vertexList in vertexListsForControl)
                {
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z) in vertexList)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }
            }

            GL.Color4(1, 1, 1, 1.0f);
        }