Example #1
0
        public WindowHook(IntPtr externalWindowHwnd, Overlay windowForm)
        {
            this.externalWindowHwnd = externalWindowHwnd;

            this.windowForm = windowForm;

            chivato = new Thread(
                () =>
            {
                while (windowForm.working)
                {
                    RECTANGULO rectangulo = new RECTANGULO();
                    GetWindowRect(externalWindowHwnd, out rectangulo);
                    windowForm.resizeForm(rectangulo);
                    Thread.Sleep(250);
                }
            });

            chivato.SetApartmentState(ApartmentState.MTA);
            chivato.IsBackground   = true;
            chivato.CurrentCulture = System.Globalization.CultureInfo.CurrentCulture;
            chivato.Priority       = ThreadPriority.Highest;
            chivato.Name           = "WindowHookWorkerThread";

            chivato.Start();
            //chivato.Join();
        }
Example #2
0
        public void drawPlayer(Graphics g, Entity localPlayer, Entity player, RECTANGULO windowRect)
        {
            /*Translate by - camerapos*/
            var camerapos = new Vector3DU(localPlayer.Data.baseEntity.pos.x, localPlayer.Data.baseEntity.pos.y, -localPlayer.Data.baseEntity.pos.z);
            var point     = new Vector3DU(player.Data.baseEntity.pos.x, player.Data.baseEntity.pos.y, -player.Data.baseEntity.pos.z);

            point = camerapos - point;

            Vector3DU camRotation = localPlayer.Data.baseEntity.rot;

            /*Construct rotation matrix
             * Rotations would be negative here to account for opposite direction of     rotations in Unity's left-handed coordinate system,
             * but since we're making them negative already this cancels out*/
            //Console.WriteLine(camRotation);
            float P = (float)Math.PI / 180;

            float cosX = (float)Math.Cos(camRotation.x * P); //Hay que convertir grados a radianes
            float cosY = (float)Math.Cos(camRotation.y * P);
            float cosZ = (float)Math.Cos(camRotation.z * P);
            float sinX = (float)Math.Sin(camRotation.x * P);
            float sinY = (float)Math.Sin(camRotation.y * P);
            float sinZ = (float)Math.Sin(camRotation.z * P);

            float[,] matrix = new float[3, 3];
            matrix[0, 0]    = cosZ * cosY - sinZ * sinX * sinY;
            matrix[0, 1]    = -cosX * sinZ;
            matrix[0, 2]    = cosZ * sinY + cosY * sinZ * sinX;
            matrix[1, 0]    = cosY * sinZ + cosZ * sinX * sinY;
            matrix[1, 1]    = cosZ * cosX;
            matrix[1, 2]    = sinZ * sinY - cosZ * cosY * sinX;
            matrix[2, 0]    = -cosX * sinY;
            matrix[2, 1]    = sinX;
            matrix[2, 2]    = cosX * cosY;

            /*Apply rotation matrix to target point*/
            Vector3DU rotatedPoint;

            rotatedPoint.x = matrix[0, 0] * point.x + matrix[0, 1] * point.y + matrix[0, 2] * point.z;
            rotatedPoint.y = matrix[1, 0] * point.x + matrix[1, 1] * point.y + matrix[1, 2] * point.z;
            rotatedPoint.z = matrix[2, 0] * point.x + matrix[2, 1] * point.y + matrix[2, 2] * point.z;

            Vector3DU resultPoint = new Vector3DU(rotatedPoint.x, rotatedPoint.y, -rotatedPoint.z);

            if (resultPoint.z > 0)
            {
                float      focalLength = 540f / (float)Math.Tan(85f * P / 2f);
                float      screenX     = focalLength * resultPoint.x / resultPoint.z + windowRect.Width / 2;
                float      screenY     = focalLength * resultPoint.y / resultPoint.z + windowRect.Height / 2;
                RECTANGULO rect        = new RECTANGULO(screenX, screenY, screenX + 10, screenY + 10);
                Pen        lapiz       = new Pen(Color.Red);
                g.DrawRectangle(lapiz, rect);
                //device.DrawEllipse(new Ellipse(new RawVector2(screenX, screenY), 6, 6), greenBrush);
            }
        }
Example #3
0
 public void resizeForm(RECTANGULO rectangulo)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new resizeFormCallback(resizeForm), rectangulo);
     }
     else
     {
         //this.Size = rectangulo.Size;
         this.Size = new Size(SystemInfo.getSystemInfo(SystemInfo.SystemMetric.SM_CXFULLSCREEN), SystemInfo.getSystemInfo(SystemInfo.SystemMetric.SM_CYFULLSCREEN));
         //Setting Window position;
         this.Top  = (int)rectangulo.Top;
         this.Left = (int)rectangulo.Left;
     }
 }
Example #4
0
        public void drawCrosshair(Graphics g, Color color, RECTANGULO targetRect, int longitudRecta = 5, bool ignoreOffset = false)
        {
            Pen lapiz = new Pen(color);

            lapiz.Width = 1;
            //linea horizontal
            Vector2DX offsetCentro = ignoreOffset ? new Vector2DX() : new Vector2DX(manejador.getXCrosshairOffsetValue(), manejador.getYCrosshairOffsetValue());
            Vector2DX centro       = targetRect.CenterAbsolute - offsetCentro;
            POINT     middleMinorH = centro - Vector2DX.UnitX * longitudRecta;
            POINT     middleMayorH = centro + Vector2DX.UnitX * longitudRecta;

            g.DrawLine(lapiz, middleMinorH, middleMayorH);
            //linea vertical
            POINT middleMinorV = centro - Vector2DX.UnitY * longitudRecta;
            POINT middleMayorV = centro + Vector2DX.UnitY * longitudRecta;

            g.DrawLine(lapiz, middleMinorV, middleMayorV);
        }
Example #5
0
        public void drawRadar(Graphics g, Color color, POINT init, Entity localPlayer, out RECTANGULO radarRect)  //, List<Entity> players)
        {
            radarRect = new RECTANGULO(
                Convert.ToInt32(init.X),
                Convert.ToInt32(init.Y),
                Convert.ToInt32(init.X + (RADAR_RADIUS * 2 - 1)),
                Convert.ToInt32(init.Y + (RADAR_RADIUS * 2 - 1))
                );
            //DrawingUtils.AddorUpdateRect(clase, rect);
            //if (filled) //FIXME Se rellena con el color de fondo del form
            {
                SolidBrush pincel = new SolidBrush(color);
                g.FillEllipse(pincel, radarRect);
            }
            Pen lapiz = new Pen(color);

            lapiz.Width = 2;
            lapiz.Color = Color.FromArgb(255, color.R, color.G, color.B);
            g.DrawEllipse(lapiz, radarRect);

            drawCrosshair(g, Color.FromArgb(128, Color.Red), radarRect, RADAR_RADIUS, true); //Para comprobar si el calculo del centro esta Ok
        }
Example #6
0
 static extern bool GetWindowRect(IntPtr hwnd, out RECTANGULO lpRect);
Example #7
0
 public bool Equals(RECTANGULO r)
 {
     return(r.Left == Left && r.Top == Top && r.Right == Right && r.Bottom == Bottom);
 }