Beispiel #1
0
        private float DistAA3(float[] img, int w, int c, int xc, int yc, int xi, int yi)
        {
            int   closest = c - xc - yc * w;     // Index to the edge pixel pointed to from c
            float a       = img[closest];        // Grayscale value at the edge pixel
            var   gx      = _gradients[closest]; // gradient component at the edge pixel

            a = MathUtils.Clamp(a, 0.0f, 1.0f);  // Clip grayscale values outside the range [0,1]
            if (a == 0.0f)
            {
                return(1000000.0f); // Not an object pixel, return "very far" ("don't know yet")
            }
            var   dx = new SharpDX.Vector2(xi, yi);
            float di = dx.Length(); // Length of integer vector, like a traditional EDT
            float df;

            if (di == 0.0f)
            {
                // Use local gradient only at edges
                // Estimate based on local gradient only
                df = EdgeDf(gx, a);
            }
            else
            {
                // Estimate gradient based on direction to edge (accurate for large di)
                df = EdgeDf(dx, a);
            }

            return(di + df); // Same metric as edtaa2, except at edges (where di=0)
        }
Beispiel #2
0
 private void DrawEntity(WindowRenderTarget device, ProtoBuf.Entity localPlay, ProtoBuf.Entity entity, SharpDX.Vector2 screenMid, SharpDX.Color color)
 {
     if (entity != null)
     {
         SharpDX.Vector2 pointToRotate = SharpDX.Vector2.op_UnaryPlus(new SharpDX.Vector2(entity.baseEntity.pos.x, entity.baseEntity.pos.z));
         pointToRotate.X = localPlay.baseEntity.pos.x - entity.baseEntity.pos.x;
         pointToRotate.Y = localPlay.baseEntity.pos.z - entity.baseEntity.pos.z;
         if (pointToRotate.Length() <= 149f)
         {
             if (pointToRotate.Length() > 150f)
             {
                 pointToRotate.Normalize();
                 pointToRotate = (SharpDX.Vector2)(pointToRotate * 150f);
             }
             pointToRotate += screenMid;
             pointToRotate  = RotatePoint(pointToRotate, screenMid, localPlayer.baseEntity.rot.y);
             this.FillEllipse(device, new SharpDX.Color(0xff, 0xff, 0xff, color.A), pointToRotate.X + 1.5f, pointToRotate.Y + 1.5f, 6f, 6f, true);
             this.FillEllipse(device, color, pointToRotate.X + 1f, pointToRotate.Y + 1f, 4f, 4f, true);
         }
     }
 }
Beispiel #3
0
 private void DrawPlayer(WindowRenderTarget device, ProtoBuf.Entity currentPlayer, ProtoBuf.Entity player, SharpDX.Vector2 screenMid, SharpDX.Color color)
 {
     if ((player != null) && (player.basePlayer.name != currentPlayer.basePlayer.name))
     {
         SharpDX.Vector2 pointToRotate = SharpDX.Vector2.op_UnaryPlus(new SharpDX.Vector2(player.baseEntity.pos.x, player.baseEntity.pos.z));
         pointToRotate.X = currentPlayer.baseEntity.pos.x - player.baseEntity.pos.x;
         pointToRotate.Y = currentPlayer.baseEntity.pos.z - player.baseEntity.pos.z;
         if (pointToRotate.Length() <= 400f)
         {
             if (pointToRotate.Length() > 150f)
             {
                 pointToRotate.Normalize();
                 pointToRotate = (SharpDX.Vector2)(pointToRotate * 150f);
             }
             pointToRotate += screenMid;
             pointToRotate  = RotatePoint(pointToRotate, screenMid, currentPlayer.baseEntity.rot.y);
             if (Radar.Default.drawPlayerNames)
             {
                 this.DrawText(((int)pointToRotate.X) - player.basePlayer.name.Length, ((int)pointToRotate.Y) + 5, player.basePlayer.name, SharpDX.Color.White, true, this.radarSmall);
             }
             this.FillEllipse(device, color, pointToRotate.X + 2f, pointToRotate.Y + 2f, 8f, 8f, true);
         }
     }
 }