CGWorldFrame::GetScreenCoordinates menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    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)

    CGWorldFrame::GetScreenCoordinates

    bool __thiscall CGWorldFrame::GetScreenCoordinates(C3Vector const&, C3Vector*, CGWorldFrame::SCREEN_RESULT *, bool *)
    0x004C97A0 (Rebased)

    Has anyone worked with this function before? I'm trying to use it in place of a big WorldToScreen function. When I try to use it, I get strange numbers in the out vector, normally -2 to +2 for X and Y, and around 10 to 40 for Z. The return bool value is whether the position is in the screen. It's always correct.

    I've tried looking into exactly what the function does after it gets the coordinates but can't find the exact math/functions I need to use. I could use a hand here

    Thanks in advance.

    CGWorldFrame::GetScreenCoordinates
  2. #2
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't know if it gets you any further... but the SCREEN_RESULT has flag 8 set when the x coordinate is in the viewport and flag 4 set when y is in the viewport. Flags 1 and 2 are always set, if the vector passes the near plane clip. If so, the out bool is set to false, meaning basically clippedAway. The return value of the function returns true if the flags are (or would be) set to 15.

    You can get the projection matrix from [worlframe + 668] currently. The NDC viewport (4 floats) is at 648, another viewport-ish values are used from 104 before exit.

    They project like this: Get the vector relative to camera or eye position (prob eye). Get the transformed vector (with added w coordinate ofc) by multiplying with the matrix. If the result's z is lower than nearclip, discard. Then normalize the vector by its w component.
    My computer graphics math isn't that fresh, but you should check here if you have your result.

    Else go further and do some strange stuff: add 1 to both x and y and divide by 2 (like (x+1)/2), multiply with the NDC viewport width/height (for x/y) and perform the NDCToDDC conversion (normalized device coordinates to whatever-blizz-means-by-the-first-D device coordinates), which currently only multiplies x by 0.8 and y by 0.6.
    Regarding the last quarter of the function I can't say anything with certainty... here comes the second DDC viewport I mentioned into play.

    Also, I found the function at 004E0360 in the database from 15595

    Edit: I actually worked with an old mac build too and failed at spotting the right offset in the current version, so the matrix should be at [worldframe + 664].
    Last edited by Bananenbrot; 06-03-2012 at 03:06 PM.

  3. #3
    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)
    Yeah I am actually using that offset as well. I accidentally wrote the one from the 15508 debug build. Thanks for the info, I'll let you know how I go.

All times are GMT -5. The time now is 10:42 AM. 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