Esempio n. 1
0
            internal static Point WorldToScreen(float x, float y, float z, bool realPos)
            {

                var Result = new Point
                {
                    X = 0,
                    Y = 0
                };

                Vector pseudoVec = new Vector(x, y, z);

                Vector Pos = new Vector(X, Y, Z);

                Vector diff = pseudoVec - Pos;

                Vector view = diff * Matrix.Inverse();
                Vector cam = new Vector(-view.Y, -view.Z, view.X);

                Single WowWidth = Convert.ToSingle((uint)InterfaceHelper.WindowWidth);
                Single WowHeight = Convert.ToSingle((uint)InterfaceHelper.WindowHeight);

                Single fHorizontalAdjust = ((WowWidth / WowHeight >= 1.6f) ? 55.0f : 44.0f);

                Single fScreenX = WowWidth / 2.0f;
                Single fScreenY = WowHeight / 2.0f;

                Rect rect = new Rect();
                GetClientRect(Memory.WindowHandle, ref rect);

                float modifier = 1.0f;
                float modifier2 = 1.08f;
                if (1.0 * rect.right / rect.bottom > 1.5)
                {
                    modifier *= 1.15f;
                    modifier2 = 1.0f;
                }

                Single fTmpX = fScreenX / (Single)Math.Tan((((WowWidth / WowHeight) * fHorizontalAdjust) * modifier2 * modifier / 2.0f) * Deg2Rad);
                Single fTmpY = fScreenY / (Single)Math.Tan((((WowWidth / WowHeight) * 35) / 2.0f) * Deg2Rad);

                Result.X = (int)(fScreenX + cam.X * fTmpX / cam.Z);
                Result.Y = (int)(fScreenY + cam.Y * fTmpY / cam.Z);

                if (Result.X < 0 || Result.Y < 0)
                {
                    Result.X = 0;
                    Result.Y = 0;
                }
                else
                {
                    if (realPos)
                    {

                        Point p = new Point();
                        Frame.ScreenToClient(Memory.WindowHandle, ref p);
                        Result.X += Math.Abs(p.X);
                        Result.Y += Math.Abs(p.Y);

                    }
                    Result.Y -= 20;
                }
                return Result;
            }
Esempio n. 2
0
 public static Vector operator -(Vector v1, Vector v2)
 {
     var v3 = new Vector((v1._x - v2._x), (v1._y - v2._y), (v1._z - v2._z));
     return v3;
 }
Esempio n. 3
0
 public static Vector operator +(Vector v1, Vector v2)
 {
     var v3 = new Vector((v1._x + v2._x), (v1._y + v2._y), (v1._z + v2._z));
     return v3;
 }
Esempio n. 4
0
 public void SetVec(Vector v)
 {
     _x = v._x;
     _y = v._y;
     _z = v._z;
 }
Esempio n. 5
0
 public Vector(Vector v)
 {
     _x = v._x;
     _y = v._y;
     _z = v._z;
 }
Esempio n. 6
0
 public static Vector operator *(Vector v, Matrix m)
 {
     var res = new Vector(m._x1 * v.X + m._y1 * v.Y + m._z1 * v.Z,
                             m._x2 * v.X + m._y2 * v.Y + m._z2 * v.Z,
                             m._x3 * v.X + m._y3 * v.Y + m._z3 * v.Z);
     return res;
 }