Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public override void DrawOn2DControlTopDownView()
        {
            List <(PointF loc, SizeF size)> dimensions = GetDimensions();
            float angle = InternalRotates ? MapUtilities.ConvertAngleForControl(0) : 0;

            foreach ((PointF loc, SizeF size) in dimensions)
            {
                MapUtilities.DrawTexture(TextureId, loc, size, angle, Opacity);
            }
        }
Ejemplo n.º 3
0
        public override void DrawOn2DControlOrthographicView()
        {
            List <(PointF loc, SizeF size)> dimensions = GetDimensions();

            if (InternalRotates)
            {
                return;
            }
            foreach ((PointF loc, SizeF size) in dimensions)
            {
                MapUtilities.DrawTexture(TextureId, loc, size, 0, Opacity);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            base.DrawOn2DControlTopDownView(hoverData);

            if (_customImage != null)
            {
                (float x, float y, float z)      = ((float, float, float))PositionAngle.GetMidPoint(_posAngle1, _posAngle2);
                (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlTopDownView(x, 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);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
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);
            }
        }
Ejemplo n.º 12
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            float marioHeight = Config.Stream.GetFloat(MarioConfig.StructAddress + MarioConfig.YOffset);
            float?height      = _relativeHeight.HasValue ? marioHeight - _relativeHeight.Value : _absoluteHeight;

            List <TriangleMapData> wallDataList = GetFilteredTriangles()
                                                  .ConvertAll(tri => MapUtilities.Get2DWallDataFromTri(tri, height))
                                                  .FindAll(wallDataNullable => wallDataNullable != null);

            foreach (TriangleMapData wallData in wallDataList)
            {
                float angle          = (float)MoreMath.AngleTo_Radians(wallData.X1, wallData.Z1, wallData.X2, wallData.Z2);
                float projectionDist = Size / (float)Math.Abs(wallData.Tri.XProjection ? Math.Cos(angle) : Math.Sin(angle));
                List <List <(float x, float z)> > quads = new List <List <(float x, float z)> >();
                void addQuad(float xAdd, float zAdd)
                {
                    quads.Add(new List <(float x, float z)>()
                    {
                        (wallData.X1, wallData.Z1),
                        (wallData.X1 + xAdd, wallData.Z1 + zAdd),
                        (wallData.X2 + xAdd, wallData.Z2 + zAdd),
                        (wallData.X2, wallData.Z2),
                    });
                };
                if (wallData.Tri.XProjection)
                {
                    addQuad(projectionDist, 0);
                    addQuad(-1 * projectionDist, 0);
                }
                else
                {
                    addQuad(0, projectionDist);
                    addQuad(0, -1 * projectionDist);
                }

                List <List <(float x, float z)> > quadsForControl =
                    quads.ConvertAll(quad => quad.ConvertAll(
                                         vertex => MapUtilities.ConvertCoordsForControlTopDownView(vertex.x, vertex.z, UseRelativeCoordinates)));

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

                // Draw quad
                byte opacityByte = OpacityByte;
                if (this == hoverData?.MapObject && hoverData?.Tri == wallData.Tri && !hoverData.Index.HasValue)
                {
                    opacityByte = MapUtilities.GetHoverOpacityByte();
                }
                GL.Color4(Color.R, Color.G, Color.B, opacityByte);
                GL.Begin(PrimitiveType.Quads);
                foreach (List <(float x, float z)> quad in quadsForControl)
                {
                    foreach ((float x, float z) in quad)
                    {
                        GL.Vertex2(x, z);
                    }
                }
                GL.End();

                if (_showArrows)
                {
                    double totalDistance = MoreMath.GetDistanceBetween(
                        wallData.X1, wallData.Z1, wallData.X2, wallData.Z2);
                    List <double> markDistances = new List <double>();
                    if (totalDistance < 100)
                    {
                        markDistances.Add(totalDistance / 2);
                    }
                    else
                    {
                        int    cardinalAngle        = wallData.Tri.XProjection ? 16384 : 0;
                        double angleDiffCoefficient = 1 / Math.Abs(Math.Cos(MoreMath.AngleUnitsToRadians(wallData.Tri.GetPushAngle() - cardinalAngle)));
                        double firstDistance        = 25 * angleDiffCoefficient;
                        double lastDistance         = totalDistance - 25 * angleDiffCoefficient;
                        double distanceDiff         = lastDistance - firstDistance;
                        int    numMarks             = (int)Math.Truncate(distanceDiff / 50 + 0.25) + 1;
                        int    numBetweens          = numMarks - 1;
                        double betweenDistance      = distanceDiff / numBetweens;
                        for (int i = 0; i < numMarks; i++)
                        {
                            markDistances.Add(firstDistance + i * betweenDistance);
                        }
                    }

                    List <(float x, float z)> markPoints = new List <(float x, float z)>();
                    foreach (double dist in markDistances)
                    {
                        double portion = dist / totalDistance;
                        (double x, double z)pointOnMidpoint =
                            (wallData.X1 + portion * (wallData.X2 - wallData.X1), wallData.Z1 + portion * (wallData.Z2 - wallData.Z1));
                        (double x, double z)pointOnSide1 = wallData.Tri.XProjection ?
                                                           (pointOnMidpoint.x - projectionDist / 2, pointOnMidpoint.z) :
                                                           (pointOnMidpoint.x, pointOnMidpoint.z - projectionDist / 2);
                        (double x, double z)pointOnSide2 = wallData.Tri.XProjection ?
                                                           (pointOnMidpoint.x + projectionDist / 2, pointOnMidpoint.z) :
                                                           (pointOnMidpoint.x, pointOnMidpoint.z + projectionDist / 2);
                        markPoints.Add(((float x, float z))pointOnSide1);
                        markPoints.Add(((float x, float z))pointOnSide2);
                    }

                    markPoints = markPoints.FindAll(p => MapUtilities.IsInVisibleSpace(p.x, p.z, 200));

                    double pushAngle      = wallData.Tri.GetPushAngle();
                    double angleUp        = pushAngle;
                    double angleDown      = pushAngle + 32768;
                    double angleLeft      = pushAngle + 16384;
                    double angleRight     = pushAngle - 16384;
                    double angleUpLeft    = pushAngle + 8192;
                    double angleUpRight   = pushAngle - 8192;
                    double angleDownLeft  = pushAngle + 24576;
                    double angleDownRight = pushAngle - 24576;

                    double arrowBaseLength = 0.4 * Math.Min(Size, 50);
                    double arrowSideLength = 0.2 * Math.Min(Size, 50);

                    List <List <(float x, float z)> > arrowPoints = markPoints.ConvertAll(midPoint =>
                    {
                        (float x, float z)frontPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleUp, midPoint.x, midPoint.z);
                        (float x, float z)leftOuterPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2 + arrowSideLength, angleLeft, midPoint.x, midPoint.z);
                        (float x, float z)leftInnerPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2, angleLeft, midPoint.x, midPoint.z);
                        (float x, float z)rightOuterPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2 + arrowSideLength, angleRight, midPoint.x, midPoint.z);
                        (float x, float z)rightInnerPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength / 2, angleRight, midPoint.x, midPoint.z);
                        (float x, float z)backLeftPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleDown, leftInnerPoint.x, leftInnerPoint.z);
                        (float x, float z)backRightPoint = ((float, float))MoreMath.AddVectorToPoint(
                            arrowBaseLength, angleDown, rightInnerPoint.x, rightInnerPoint.z);

                        return(new List <(float x, float z)>()
                        {
                            frontPoint,
                            leftOuterPoint,
                            leftInnerPoint,
                            backLeftPoint,
                            backRightPoint,
                            rightInnerPoint,
                            rightOuterPoint,
                        });
                    });

                    List <List <(float x, float z)> > arrowsForControl =
                        arrowPoints.ConvertAll(arrow => arrow.ConvertAll(
                                                   vertex => MapUtilities.ConvertCoordsForControlTopDownView(vertex.x, vertex.z, UseRelativeCoordinates)));

                    // Draw arrow
                    Color arrowColor = Color.Darken(0.5);
                    GL.Color4(arrowColor.R, arrowColor.G, arrowColor.B, opacityByte);
                    foreach (List <(float x, float z)> arrow in arrowsForControl)
                    {
                        GL.Begin(PrimitiveType.Polygon);
                        foreach ((float x, float z) in arrow)
                        {
                            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)> quad in quadsForControl)
                    {
                        GL.Begin(PrimitiveType.LineLoop);
                        foreach ((float x, float z) in quad)
                        {
                            GL.Vertex2(x, z);
                        }
                        GL.End();
                    }
                }

                if (_customImage != null)
                {
                    for (int i = 0; i < quadsForControl.Count; i++)
                    {
                        var quad = quadsForControl[i];
                        for (int j = 0; j < quad.Count; j++)
                        {
                            var    vertex  = quad[j];
                            PointF point   = new PointF(vertex.x, vertex.z);
                            SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _iconSize, Scales);
                            double opacity = 1;
                            if (this == hoverData?.MapObject && hoverData?.Tri == wallData.Tri && i == hoverData?.Index && j == hoverData?.Index2)
                            {
                                opacity = MapUtilities.GetHoverOpacity();
                            }
                            MapUtilities.DrawTexture(_customImageTex.Value, point, size, 0, opacity);
                        }
                    }
                }

                GL.Color4(1, 1, 1, 1.0f);
            }
        }
Ejemplo n.º 13
0
        public override void DrawOn2DControlTopDownView(MapObjectHoverData hoverData)
        {
            List <(float centerX, float centerY, float centerZ, float radius, Color color)> dimensionList = Get2DDimensions();

            for (int i = 0; i < dimensionList.Count; i++)
            {
                (float centerX, float centerY, float centerZ, float radius, Color color) = dimensionList[i];
                (float controlCenterX, float controlCenterZ) = MapUtilities.ConvertCoordsForControlTopDownView(centerX, centerZ, UseRelativeCoordinates);
                float controlRadius = radius * Config.CurrentMapGraphics.MapViewScaleValue;
                List <(float pointX, float pointZ)> controlPoints = Enumerable.Range(0, MapConfig.MapCircleNumPoints2D).ToList()
                                                                    .ConvertAll(index => (index / (float)MapConfig.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
                byte opacityByte = OpacityByte;
                if (this == hoverData?.MapObject && i == hoverData?.Index && hoverData.Index2 == null)
                {
                    opacityByte = MapUtilities.GetHoverOpacityByte();
                }
                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 (LineWidth != 0)
                {
                    GL.Color4(LineColor.R, LineColor.G, LineColor.B, (byte)255);
                    GL.LineWidth(LineWidth);
                    GL.Begin(PrimitiveType.LineLoop);
                    foreach ((float x, float z) in controlPoints)
                    {
                        GL.Vertex2(x, z);
                    }
                    GL.End();
                }

                if (_customImage != null)
                {
                    List <(float x, float z)> positions = MapUtilities.GetFloatPositions(10_000);
                    for (int j = 0; j < positions.Count; j++)
                    {
                        (float x, float z) = positions[j];
                        float dist = (float)MoreMath.GetDistanceBetween(centerX, centerZ, x, z);
                        if (dist >= radius)
                        {
                            continue;
                        }
                        (float controlX, float controlZ) = MapUtilities.ConvertCoordsForControlTopDownView(x, z, UseRelativeCoordinates);
                        SizeF  size    = MapUtilities.ScaleImageSizeForControl(_customImage.Size, _imageSize, Scales);
                        double opacity = 1;
                        if (this == hoverData?.MapObject && i == hoverData?.Index && j == hoverData?.Index2)
                        {
                            opacity = MapUtilities.GetHoverOpacity();
                        }
                        MapUtilities.DrawTexture(_customImageTex.Value, new PointF(controlX, controlZ), size, 0, opacity);
                    }
                }
            }

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