Exemplo n.º 1
0
 void Draw_Rectangle(Person_Struct self, List <Person_Struct> Other_list)
 {
     //求距离
     try
     {
         var Rectangles = new List <(Rectangle, Color)>();
         foreach (var Other in Other_list)
         {
             var    VM = WorldToScreen(Other, Get_ViewMatrix(DllPtr + ViewMatrix_offset));
             double M  = Math.Sqrt(Math.Pow((double)(self.X - Other.X), 2) + Math.Pow((double)(self.Y - Other.Y), 2) + Math.Pow((double)(self.Z - Other.Z), 2)) / 30;
             int    H  = Convert.ToInt32(950 / M * 2);
             int    W  = Convert.ToInt32(400 / M * 2);
             if (Other.army == self.army)
             {
                 Rectangles.Add((new Rectangle((int)VM.X - W / 2, (int)VM.Y - H, W, H), Color.Coral));
             }
             else
             {
                 Rectangles.Add((new Rectangle((int)VM.X - W / 2, (int)VM.Y - H, W, H), Color.Red));
             }
         }
         Form1.bitmap_form.Drawing(Rectangles);
     }
     catch {
     }
 }
Exemplo n.º 2
0
        ViewScreen WorldToScreen(Person_Struct Ps, float[,] ViewMatrix)
        {
            var Sigma_Matrix = new float[4];

            for (int i = 0; i < Sigma_Matrix.Length; i++)
            {
                Sigma_Matrix[i] = ViewMatrix[i, 0] * Ps.X + ViewMatrix[i, 1] * Ps.Y + ViewMatrix[i, 2] * Ps.Z + ViewMatrix[i, 3];
            }
            if (Sigma_Matrix[3] < 0.01)
            {
                return(new ViewScreen()
                {
                    X = 0, Y = 0
                });
            }
            float      X        = Sigma_Matrix[0] / Sigma_Matrix[3];
            float      Y        = Sigma_Matrix[1] / Sigma_Matrix[3];
            float      Z        = Sigma_Matrix[2] / Sigma_Matrix[3];
            float      Window_H = 1080 / 2; //屏高
            float      Window_W = 1920 / 2; //屏框
            ViewScreen Rs;

            Rs.X = X * Window_W + Window_W + X;
            Rs.Y = -(Y * Window_H) + Window_H + Y;
            return(Rs);
        }