World to Screen menu

Shout-Out

User Tag List

Results 1 to 10 of 10
  1. #1
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    World to Screen

    Hi there, I have been having issues in calculating world to screen, below is the sample code I have come up with so far,
    Please can someone point me in the right direction because I can't find where my calculations are going wrong.

    Update: I would like to do this Passively (no memory writing at all)

    Code:
    Vector2 xy = WorldSpaceToScreenSpace(new Vector3 { X = wow.LocalPlayer.PlayerX, Y = wow.LocalPlayer.PlayerY, Z = wow.LocalPlayer.PlayerZ });
    log.LogActivity("Result (x, y) = " + xy.X + ", " + xy.Y);
    Code:
    Vector2 WorldSpaceToScreenSpace(Vector3 worldSpacePos)
    {
        Vector3 viewProjMatrix = new Vector3
        {
            X = wow.CameraMatrixX,
            Y = wow.CameraMatrixY,
            Z = wow.CameraMatrixZ
        };
    
        Vector4 clipSpacePos = Vector4.Transform(new Vector4(worldSpacePos, 1f), viewProjMatrix, log);
        Vector2 screenSpacePos;
        screenSpacePos.X = (clipSpacePos.X / clipSpacePos.W) * 0.5f + 0.5f;
        screenSpacePos.Y = 1.0f - ((clipSpacePos.Y / clipSpacePos.W) * 0.5f + 0.5f);
        screenSpacePos.X *= 1920;
        screenSpacePos.Y *= 1080;
        return screenSpacePos;
    }
    Code:
    private struct Vector2
    {
        public float X;
        public float Y;
    }
    
    private struct Vector3
    {
        public float X;
        public float Y;
        public float Z;
    }
    
    private class Vector4
    {
        public float W;
        public float X;
        public float Y;
        public float Z;
    
        public Vector4()
        {
        }
    
        public Vector4(Vector3 worldSpacePosition, float w)
        {
            X = worldSpacePosition.X;
            Y = worldSpacePosition.Y;
            Z = worldSpacePosition.Z;
            W = w;
        }
    
        public static Vector4 Transform(Vector4 worldSpace, Vector3 viewProjMatrix, Logging log)
        {
            // http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/#The_Model__View_and_Projection_matrices
    
            float[][] ws = new float[4][];
            ws[0] = new float[4];
            ws[1] = new float[4];
            ws[2] = new float[4];
            ws[3] = new float[4];
            ws[0][0] = 1f; ws[0][1] = 0f; ws[0][2] = 0f; ws[0][3] = worldSpace.X;
            ws[1][0] = 0f; ws[1][1] = 1f; ws[1][2] = 0f; ws[1][3] = worldSpace.Y;
            ws[2][0] = 0f; ws[2][1] = 0f; ws[2][2] = 1f; ws[2][3] = worldSpace.Z;
            ws[3][0] = 0f; ws[3][1] = 0f; ws[3][2] = 0f; ws[3][3] = 1f;
    
            log.LogActivityNoTime(string.Format("World Space Matrix\r\n" +
                                            "{0}\t{1}\t{2}\t{3}\r\n" +
                                            "{4}\t{5}\t{6}\t{7}\r\n" +
                                            "{8}\t{9}\t{10}\t{11}\r\n" + 
                                            "{12}\t{13}\t{14}\t{15}\r\n", 
                                            ws[0][0], ws[0][1], ws[0][2], ws[0][3],
                                            ws[1][0], ws[1][1], ws[1][2], ws[1][3],
                                            ws[2][0], ws[2][1], ws[2][2], ws[2][3],
                                            ws[3][0], ws[3][1], ws[3][2], ws[3][3]));
    
            float[][] vp = new float[4][];
            vp[0] = new float[1];
            vp[1] = new float[1];
            vp[2] = new float[1];
            vp[3] = new float[1];
            vp[0][0] = viewProjMatrix.X;
            vp[1][0] = viewProjMatrix.Y;
            vp[2][0] = viewProjMatrix.Z;
            vp[3][0] = 1f;
    
            log.LogActivityNoTime(string.Format("View Proj Matrix\r\n" +
                                            "{0}\r\n" +
                                            "{1}\r\n" +
                                            "{2}\r\n" +
                                            "{3}", vp[0][0], vp[1][0], vp[2][0], vp[3][0]));
    
            float[][] res = new float[4][];
            res[0] = new float[1];
            res[1] = new float[1];
            res[2] = new float[1];
            res[3] = new float[1];
    
            res[0][0] = (ws[0][0] * vp[0][0]) + (ws[0][1] * vp[1][0]) + (ws[0][2] * vp[2][0]) + (ws[0][3] * vp[3][0]);
            res[1][0] = (ws[1][0] * vp[0][0]) + (ws[1][1] * vp[1][0]) + (ws[1][2] * vp[2][0]) + (ws[1][3] * vp[3][0]);
            res[2][0] = (ws[2][0] * vp[0][0]) + (ws[2][1] * vp[1][0]) + (ws[2][2] * vp[2][0]) + (ws[2][3] * vp[3][0]);
            res[3][0] = (ws[3][0] * vp[0][0]) + (ws[3][1] * vp[1][0]) + (ws[3][2] * vp[2][0]) + (ws[3][3] * vp[3][0]);
    
            return new Vector4
            {
                X = res[0][0],
                Y = res[1][0],
                Z = res[2][0],
                W = res[3][0]
            };
        }            
    }
    Sample Result / Output below, showing incorrect X,Y co-ords.



    I think the issue is with my assumption that viewProjMatrix = the camera matrix position, because I should also be taking the camera position and field of view into account, but no idea how to do this.
    I think it should be viewProjMatrix = some calculation on (camera position) and (matrix position) and (field of view)
    Attached Thumbnails Attached Thumbnails World to Screen-bdhdz9n-png  
    Last edited by WiNiFiX; 09-23-2015 at 02:33 PM.

    World to Screen
  2. #2
    lolp1's Avatar Site Donator CoreCoins Purchaser
    Reputation
    190
    Join Date
    Feb 2013
    Posts
    210
    Thanks G/R
    43/77
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    https://github.com/BigMo/ExternalUti...p/MathUtils.cs should give you an idea of how translating 3d world vectors to screen coordinates work.

  3. #3
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by lolp1 View Post
    https://github.com/BigMo/ExternalUti...p/MathUtils.cs should give you an idea of how translating 3d world vectors to screen coordinates work.
    Thanks for this, just 1 question you call the function below with "viewMatrix", which I populate from the below code, which yields a 3x3 matrix, however the method appears to want a 4x4 matrix?

    public static Vector2 WorldToScreen(this Matrix viewMatrix, Vector2 screenSize, Vector3 point3D)

    Code:
    public Matrix CameraMatrix
    {
        get
        {
            Matrix m = new Matrix(3, 3);
    
            byte []b = Memory.Read<byte>(CameraOffset + Offsets_x86.Camera.CameraMatrix, 36);
            m.Read(b);
    
            return m;
        }
    }
    Code:
    // Offsets
    public struct Camera
    {
        public static IntPtr CameraStruct = new IntPtr(0xEAF1F0);   // Version 6.2.2.20490
        public static int CameraOffset = 0x7610;                    // Version 6.2.2.20490
        public static int CameraOrigin = 0x08;                      // Version 6.2.2.20490
        public static int CameraMatrix = 0x14;                      // Version 6.2.2.20490
        public static int CameraFov = 0x38;                         // Version 6.2.2.20490
    }
    
    public IntPtr CameraStruct
    {
        get
        {
            return Memory.Read<IntPtr>(Offsets_x86.Camera.CameraStruct, true);
        }
    }
    
    public IntPtr CameraOffset
    {
        get
        {
            return Memory.Read<IntPtr>(CameraStruct + Offsets_x86.Camera.CameraOffset);
        }
    }
    Below is the matrix showing correctly, however I noticed that all values except the one in red changes (when I move the camera), is that normal?

    Last edited by WiNiFiX; 09-22-2015 at 02:30 PM.

  4. #4
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Good guy Blizzard already has a function for this, so if you're internal maybe this will help:

    Code:
            /// <summary>
            /// Gets a two-dimensional position in screen space, for a three-dimensional position in world space.
            /// </summary>
            /// <param name="position">A three-dimensional position in world space.</param>
            /// <param name="result">The resulting two-dimensional position in screen space.</param>
            /// <returns>true if the position in world space is a valid position in screen space, otherwise false.</returns>
            public static bool GetScreenPosition(Vector3 position, out Vector2 result) {
                var output = Vector3.Zero;
                var onScreen = CGWorldFrame__GetScreenCoordinates(CurrentWorldFrame, ref position, ref output, IntPtr.Zero, IntPtr.Zero);
                
                Rectangle clientRect;
                WinAPI.GetClientRect(Window.Handle, out clientRect);
    
                var x = 0.0f;
                var y = 0.0f;
                var height = clientRect.Bottom - clientRect.Top;
                var width = clientRect.Right - clientRect.Left;
    
                DDCToNDC(output.X, output.Y, ref x, ref y);
                x = clientRect.Left + (x * width);
                y = height - clientRect.Top + (y * height); // Resulting Y is inverse of what we would expect.
    
                result = new Vector2(x, y);
                return onScreen;
            }
    Resulting coordinates are relative to the client screen space rather than full screen space, ie.


    Offsets (6.2.2.20490):

    Code:
    00405C9A CGWorldFrame__GetScreenCoordinates
    00013953 DDCToNDC

  5. Thanks reliasn, Razzue (2 members gave Thanks to Jadd for this useful post)
  6. #5
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Jadd,

    Good to know, however I am keeping this bot passive (no memory writing), so I don't think I can call this function without writing?
    I am also doing this for educational purposes in 3D / 2D programming so prefer to find a working solution.

    I have read the forums and googled like crazy but cant seem to find working solutions.

    @Anyone who has done this (passively), I would love it if you could shed some light.
    Pictures paint a 1000 words so those are good to.

    I have looked @Master674's post on this page (World To Screen transformation)
    however am unsure how to get some of the values he mentions such as "Up", Near clip and Far clip values.
    Then he mentions "Then calculate the current transformation matrix with Identity (World) * View * Projection.", however it is not clear what matrix's he posted makes up each of those 3.

  7. #6
    lolp1's Avatar Site Donator CoreCoins Purchaser
    Reputation
    190
    Join Date
    Feb 2013
    Posts
    210
    Thanks G/R
    43/77
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Jadd View Post
    Good guy Blizzard already has a function for this, so if you're internal maybe this will help:
    ...
    Neat. Reminds me of my path of exile world to screen.

    Code:
    public unsafe Vector2 WorldToScreen(Vector3 vec3)
    		{
    			float x, y;
    			var address = Ptr + 0xBC;
    			fixed (byte* numRef = MemoryCore.ReadBytes(Memory.SafeHandle, address, 0x40))
    			{
    				var matrix = *(Matrix*) numRef;
    				var cord = *(Vector4*) &vec3;
    				cord.W = 1;
    				cord = Vector4.Transform(cord, matrix);
    				cord = Vector4.Divide(cord, cord.W);
    				x = ((cord.X + 1.0f)*0.5f)*Width;
    				y = ((1.0f - cord.Y)*0.5f)*Height;
    			}
    			var resultCord = new Vector2(x, y); // 
    			return resultCord;
    		}
    Anyways on topic, I'm bad at geometry and math really so sorry I am not of much help my friend, I too had issues figuring it out on the first game I started learning to code on a few months ago. I've not tried it in Wow but the concept should still apply.

    Read the matrix like so: (using the matrix & vector classes here https://github.com/BigMo/ExternalUti...rp/MathObjects ).
    Code:
       private const int SIZE_FLOAT = sizeof(float);
            /// <summary>
            /// Reads a matrix from memory
            /// </summary>
            /// <param name="address">The address of the matrix in memory</param>
            /// <param name="rows">The number of rows of this matrix</param>
            /// <param name="columns">The number of columns of this matrix</param>
            /// <returns>The matrix read from memory</returns>
            public Matrix ReadMatrix(IntPtr address, int rows, int columns)
            {
                Matrix matrix = new Matrix(rows, columns);
                byte[] data;
                // How ever you want to read below is fine of course.
                Read(address, out data, SIZE_FLOAT * rows * columns);
                matrix.Read(data);
                return matrix;
            }
    Then, use this: https://github.com/BigMo/ExternalUti...p/MathUtils.cs

    Keep in mind:
    Matrix = The already fully read and ready camera matrix.
    screenSize = The.. yeah. Just a vector2 of the screen.
    point3D = This is the actual 3d space you are wanting to convert to client screen cords to.

    So CameraMatrixBytesRead, Vector2(x,y) size of screen, new Vector3(x,y,z) with the x-y-z representing the 3d point you are wanting to get client cords from.

    As far as I know, this method should work really in any game provided you have the camera matrix/3d point/screen size data.

    Code:
          
    
            /// <summary>
            /// Translates a 3d-coordinate to a screen-coodinate
            /// </summary>
            /// <param name="viewMatrix">The viewmatrix used to perform translation</param>
            /// <param name="screenSize">The size of the screen which is translated to</param>
            /// <param name="point3D">3d-coordinate of the point to translate</param>
            /// <returns>Translated screen-coodinate</returns>
            public static Vector2 WorldToScreen(this Matrix viewMatrix, Vector2 screenSize, Vector3 point3D)
            {
                Vector2 returnVector = Vector2.Zero;
                float w = viewMatrix[3, 0] * point3D.X + viewMatrix[3, 1] * point3D.Y + viewMatrix[3, 2] * point3D.Z + viewMatrix[3, 3];
                if (w >= 0.01f)
                {
                    float inverseX = 1f / w;
                    returnVector.X =
                        (screenSize.X / 2f) +
                        (0.5f * (
                        (viewMatrix[0, 0] * point3D.X + viewMatrix[0, 1] * point3D.Y + viewMatrix[0, 2] * point3D.Z + viewMatrix[0, 3])
                        * inverseX)
                        * screenSize.X + 0.5f);
                    returnVector.Y =
                        (screenSize.Y / 2f) -
                        (0.5f * (
                        (viewMatrix[1, 0] * point3D.X + viewMatrix[1, 1] * point3D.Y + viewMatrix[1, 2] * point3D.Z + viewMatrix[1, 3])
                        * inverseX)
                        * screenSize.Y + 0.5f);
                }
                return returnVector;
            }

  8. #7
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @lolp1 - Thanks, but this was linked in this thread earlier (details and my questions in the 2nd post on this page) - I get a 3x3 matrix, the function wants a 4x4 matrix, how do i get that 4x4 matrix?

    Currently I am working on trying to understand what KcDan did in his post (3D WoW Radar for 6.03.19116 32bit)as it appears (from what I have gone through so far) that he doesn't use any memory writing to find his 2d world coordinate in his function, hopefully his method will work.

  9. #8
    lolp1's Avatar Site Donator CoreCoins Purchaser
    Reputation
    190
    Join Date
    Feb 2013
    Posts
    210
    Thanks G/R
    43/77
    Trade Feedback
    3 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by WiNiFiX View Post
    @lolp1 - Thanks, but this was linked in this thread earlier (details and my questions in the 2nd post on this page) - I get a 3x3 matrix, the function wants a 4x4 matrix, how do i get that 4x4 matrix?

    Currently I am working on trying to understand what KcDan did in his post as it appears (from what I have gone through so far) that he doesn't use any memory writing to find his 2d world coordinate in his function, hopefully his method will work.
    What are you working to understand in it, exactly? It's hard to help with really general statements. There is post and examples here that are just shy of physically typing out compile-ready/working code here. You should focus more on understanding how world to screen works and less so on an immediate working result, if you're actually interested in this stuff. I know I do the same thing and it's practically always bad to do.

    There is no need to write memory - you simply need to read the data, and perform the math on it. You need a view matrix, a screen size, and the 3D point desired to translate and that is it. By the way, I am not intending to be rude and openly admit I am as new as anyone else. However, I will leave you with some basic math that helped me just recently, considering I fail at even basic geometry
    .
    [Tutorial] How to implement a simple radar

  10. #9
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    EDIT
    : I have managed to find the scale (another way) but will test later today and provide feedback and the method assuming it works, but I am still curios why the SendDlgItemMessage function below always returns 0.




    My method of understanding has always come from coding, I find a working method, then understand it.
    I understand graphically what needs to be done, (Drawn up a picture) but my maths is rusty on 3d, last time I wrote a Raytracer for Graphics was in my Honors year in 2005, that's why I am seeking advice and guidance.
    Regarding writing to memory, I was referring to Jadd's post, which would require writing to memory.

    So far I have managed to convert most of KcDan's radar to c#, however some things are not 100% clear to me still.
    Hopefully someone can shed some light on the c# equivalent to

    Code:
    #define IDC_XSCALE  4003
    #define IDC_YSCALE  4004
    ...
    int screenXScale=SendDlgItemMessage(gradarDC.hWnd,IDC_XSCALE,TBM_GETPOS,0,0);
    int screenYScale=SendDlgItemMessage(gradarDC.hWnd,IDC_YSCALE,TBM_GETPOS,0,0);
    I attempted what I thought it was below (but it always returns 0)
    Code:
    private IntPtr hWnd = FindWindow(null, "World of Warcraft");
    
    [DllImport("user32.dll")]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
    [DllImport("user32.dll")]
    static extern IntPtr SendDlgItemMessage(IntPtr hDlg, int nIDDlgItem, uint Msg, UIntPtr wParam, IntPtr lParam);
    
    public enum DeviceCap : int
    {
        SCALINGFACTORX = 4003,
        SCALINGFACTORY = 4004            
    }
    
    int screenXScale
    {
        get
        {
            uint TBM_GETPOS = 0x0400;
            return (int)SendDlgItemMessage(hWnd, (int)DeviceCap.SCALINGFACTORX, TBM_GETPOS, new UIntPtr(0), new IntPtr(0));
        }
    }
    Other than that I also have a question regarding the below function (converted from KcDan's c++ function
    He appears to consider the first 3 values of the camera matrix as angles, and ignores the remaining 6 values, are they not needed?

    Code:
    [StructLayout(LayoutKind.Sequential, Size = 24, CharSet = CharSet.Ansi)]
    public struct WoWCamera
    {
        public float z;
        public float x;
        public float y;
        public float zAngle;
        public float xAngle;
        public float yAngle;
    }
    
    public WoWCamera cam
    {
        get
        {
            return Memory.Read<WoWCamera>(CameraOffset + Offsets_x86.Camera.CameraOrigin);
        }
    }
    Code:
    public V2 d3ScreenXY(double x, double y, double z)
    {
        double _d3Cam2CtrX = cam.xAngle;
        double _d3Cam2CtrY = cam.yAngle;
        double _d3Cam2CtrZ = cam.zAngle;
        double _d3CtrX = cam.x + cam.xAngle;
        double _d3CtrY = cam.y + cam.yAngle;
        double _d3CtrZ = cam.z + cam.zAngle;
    
        double Cam2NodeX = (x - cam.x);
        double Cam2NodeY = (y - cam.y);
        double Cam2NodeZ = (z - cam.z);
        double _d3numerator = _d3Cam2CtrX * _d3Cam2CtrX + _d3Cam2CtrY * _d3Cam2CtrY + _d3Cam2CtrZ * _d3Cam2CtrZ;
        double denominator = (Cam2NodeX * _d3Cam2CtrX) + (Cam2NodeY * _d3Cam2CtrY) + (Cam2NodeZ * _d3Cam2CtrZ);
        double t = (_d3numerator / denominator);
        double ipX = cam.x + Cam2NodeX * t;
        double ipY = cam.y + Cam2NodeY * t;
        double ipZ = cam.z + Cam2NodeZ * t;
        double Ctr2ipX = (ipX - _d3CtrX);
        double Ctr2ipY = (ipY - _d3CtrY);
        double Ctr2ipZ = (ipZ - _d3CtrZ);
    
        double _d3LenCam2Ctr = Math.Sqrt(_d3Cam2CtrX * _d3Cam2CtrX + _d3Cam2CtrY * _d3Cam2CtrY + _d3Cam2CtrZ * _d3Cam2CtrZ);
    
        double _d3virtualXi = -1 * (_d3Cam2CtrZ);
        double _d3virtualXk = _d3Cam2CtrX;
        double _d3virtualYi = -1 * (_d3virtualXk * _d3Cam2CtrY);
        double _d3virtualYj = (_d3virtualXk * _d3Cam2CtrX) - (_d3virtualXi * _d3Cam2CtrZ);
        double _d3virtualYk = (_d3virtualXi * _d3Cam2CtrY);
    
        double _d3LenVirtualX = Math.Sqrt(_d3virtualXi * _d3virtualXi + _d3virtualXk * _d3virtualXk);
        _d3virtualXi = _d3virtualXi / _d3LenVirtualX;
        _d3virtualXi = _d3virtualXi / _d3LenCam2Ctr;
        _d3virtualXk = _d3virtualXk / _d3LenVirtualX;
        _d3virtualXk = _d3virtualXk / _d3LenCam2Ctr;
    
        double _d3LenVirtualY = Math.Sqrt(_d3virtualYi * _d3virtualYi + _d3virtualYj * _d3virtualYj + _d3virtualYk * _d3virtualYk);
        _d3virtualYi = _d3virtualYi / _d3LenVirtualY;
        _d3virtualYi = _d3virtualYi / _d3LenCam2Ctr;
        _d3virtualYj = _d3virtualYj / _d3LenVirtualY;
        _d3virtualYj = _d3virtualYj / _d3LenCam2Ctr;
        _d3virtualYk = _d3virtualYk / _d3LenVirtualY;
        _d3virtualYk = _d3virtualYk / _d3LenCam2Ctr;
    
        double PX = (Ctr2ipX * _d3virtualXi) + (Ctr2ipZ * _d3Cam2CtrX);
        double PY = (Ctr2ipX * _d3virtualYi) + (Ctr2ipY * _d3virtualYj) + (Ctr2ipZ * _d3virtualYk);
    
        double d3ScreenXCenter = 1920 / 2;
        double d3ScreenYCenter = 1080 / 2;
        V2 p = new V2();
        p.X = d3ScreenXCenter + (screenXScale * PX);
        p.Y = d3ScreenYCenter - (screenYScale * PY);
        return p;
    }
    Last edited by WiNiFiX; 09-25-2015 at 01:40 AM.

  11. #10
    WiNiFiX's Avatar Banned
    Reputation
    242
    Join Date
    Jun 2008
    Posts
    447
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As promised, below is the final code that works for World2Screen (Credits to Lazybot)
    Full source: here

    Code:
    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;
    }

  12. Thanks provirus (1 members gave Thanks to WiNiFiX for this useful post)

Similar Threads

  1. World to screen
    By uncledolan in forum WoW Memory Editing
    Replies: 7
    Last Post: 12-03-2016, 08:34 AM
  2. World To Screen transformation
    By newbiehacker in forum WoW Memory Editing
    Replies: 2
    Last Post: 01-19-2013, 04:01 PM
  3. direct3d for world to screen
    By mnbvc in forum WoW Memory Editing
    Replies: 11
    Last Post: 12-29-2011, 01:54 AM
  4. world to screen
    By mnbvc in forum WoW Memory Editing
    Replies: 16
    Last Post: 01-29-2010, 08:08 AM
  5. [Version Independent] World to Screen
    By ramey in forum WoW Memory Editing
    Replies: 1
    Last Post: 09-13-2009, 04:17 PM
All times are GMT -5. The time now is 10:53 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search