Ejemplo n.º 1
0
    private void DrawPath(ArrayList Path, Color color, float Alpha)
    {
        GL.PushMatrix();

        GL.LoadOrtho();

        mat.SetPass(0);

        GL.Begin(GL.LINES);

        GL.Color(new Color(color.r, color.g, color.b, Alpha));

        for (int i = 0; i < Path.Count - 1; i++)
        {
            FlightInfo = (FlightPointInfo)Path[i];

            GL.Vertex3(FlightInfo.Position.x, FlightInfo.Position.z, 0);

            FlightInfo = (FlightPointInfo)Path[i + 1];

            GL.Vertex3(FlightInfo.Position.x, FlightInfo.Position.z, 0);
        }

        GL.End();

        GL.PopMatrix();
    }
Ejemplo n.º 2
0
    private void DrawIndicator(ArrayList PathInfo, Color color)
    {
        int             PointIndex;
        float           PosX, PosY;
        float           PosX1, PosY1;
        float           PosX2, PosY2;
        float           PosX3, PosY3;
        float           PosX4, PosY4;
        float           Angle;
        FlightPointInfo FlightInfo;
        FlightPointInfo FlightInfo1;

        Angle = 0.0f;

        PosX1 = 0;
        PosY1 = 0;

        PointIndex = (int)Mathf.Lerp(0, PathInfo.Count - 1, FlightStep);

        if (PointIndex < PathInfo.Count - 1)
        {
            FlightInfo  = (FlightPointInfo)PathInfo[PointIndex];
            FlightInfo1 = (FlightPointInfo)PathInfo[PointIndex + 1];

            PosX = FlightInfo.Position.x;
            PosY = FlightInfo.Position.z;

            PosX1 = FlightInfo1.Position.x;
            PosY1 = FlightInfo1.Position.z;

            Angle = Mathf.Atan2(FlightInfo1.Position.z - FlightInfo.Position.z, FlightInfo1.Position.x - FlightInfo.Position.x);

            PosX2 = Mathf.Cos(Angle + Mathf.Deg2Rad * 90.0f) * ControlPointWidth;
            PosY2 = Mathf.Sin(Angle + Mathf.Deg2Rad * 90.0f) * ControlPointWidth;

            PosX3 = Mathf.Cos(Angle + Mathf.Deg2Rad * -90.0f) * ControlPointWidth;
            PosY3 = Mathf.Sin(Angle + Mathf.Deg2Rad * -90.0f) * ControlPointWidth;

            PosX4 = Mathf.Cos(Angle) * ControlPointWidth * 2.0f;
            PosY4 = Mathf.Sin(Angle) * ControlPointWidth * 2.0f;

            GL.PushMatrix();

            GL.LoadOrtho();

            mat.SetPass(0);

            GL.Begin(GL.QUADS);

            GL.Color(Color.white);

            GL.Vertex3(PosX + PosX2, PosY + PosY2, 0);
            GL.Vertex3(PosX + PosX4, PosY + PosY4, 0);

            GL.Vertex3(PosX + PosX3, PosY + PosY3, 0);
            GL.Vertex3(PosX + PosX4, PosY + PosY4, 0);

            GL.Vertex3(PosX + PosX2, PosY + PosY2, 0);
            GL.Vertex3(PosX + PosX3, PosY + PosY3, 0);

            GL.End();

            // Draw Triangle Line

            GL.Begin(GL.LINES);

            GL.Color(color);

            GL.Vertex3(PosX + PosX2, PosY + PosY2, 0);
            GL.Vertex3(PosX + PosX4, PosY + PosY4, 0);

            GL.Vertex3(PosX + PosX3, PosY + PosY3, 0);
            GL.Vertex3(PosX + PosX4, PosY + PosY4, 0);

            GL.Vertex3(PosX + PosX2, PosY + PosY2, 0);
            GL.Vertex3(PosX + PosX3, PosY + PosY3, 0);

            GL.End();

            GL.PopMatrix();
        }
    }