public static double GetSignedAngleBetweenTwoVectors(Vector2 Source, Vector2 Dest, Vector2 DestsRight)
        {
            // We make sure all of our vectors are unit length
            Source.Normalize();
            Dest.Normalize();
            DestsRight.Normalize();

            //float forwardDot = Vector3.Dot(Source, Dest);
            //float rightDot = Vector3.Dot(Source, DestsRight);

            float forwardDot = Dot(Source.X, Source.Y, Dest.X, Dest.Y);
            float rightDot   = Dot(Source.X, Source.Y, DestsRight.X, DestsRight.Y);

            // Make sure we stay in range no matter what, so Acos doesn't fail later
            forwardDot = Clamp(forwardDot, -1.0f, 1.0f);

            double angleBetween = Math.Acos((float)forwardDot);

            if (rightDot < 0.0f)
            {
                angleBetween *= -1.0f;
            }

            return(angleBetween);
        }
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);
         }
     }
 }