Results 1 to 7 of 7

Thread: World to screen с++

  1. #1
    Join Date
    Apr 2013
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default World to screen с++

    Can you lay out the example source code "World is Screen" on any game? or where it is possible to learn (except googl)?

  2. #2
    Join Date
    Jun 2009
    Location
    https://www.downloadedskills.com/
    Age
    29
    Posts
    421
    Thanks
    65
    Thanked 686 Times in 216 Posts

    Default

    Quote Originally Posted by VDV View Post
    Can you lay out the example source code "World is Screen" on any game? or where it is possible to learn(except googl)?
    The answer is mathematics

  3. #3
    Join Date
    Apr 2013
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by PocketMonster View Post
    The answer is mathematics
    bool WorldToScreen(Vector3D World, float *ScreenX, float *ScreenY)
    {
    //Get the enemy position
    Vector3D Position = VectorSubtract(World, RefDef->Origin);
    Vector3D Transform;

    //Get the Dot Products from the View Angles of the player
    Transform.x = DotProduct(Position, RefDef->viewAxis[1]);
    Transform.y = DotProduct(Position, RefDef->viewAxis[2]);
    Transform.z = DotProduct(Position, RefDef->viewAxis[0]);

    //Make sure the enemy is in front of the player. If not, return.
    if (Transform.z < 0.1f)
    return false;

    //Calculate the center of the screen
    Vector2D Center = Vector2D((float)RefDef->Width * 0.5f, (float)RefDef->Height * 0.5f);

    //Calculates the screen coordinates
    *ScreenX = Center.x * (1 - (Transform.x / RefDef->fov.x / Transform.z));
    *ScreenY = Center.y * (1 - (Transform.y / RefDef->fov.y / Transform.z));

    return true;


    it is one of the sources




    RefDef - whatever address you have that stores your origin, view angles and view axis - how to do this ????
    Vector 3d - not understand it, hike x, y, z enemy - x, y, z my
    VectorSubtract - do not understand the difference between a campaign 2x vectors: the enemy of my
    DotProduct - x * y * z or something like that, too, it is not clear
    viewAxis - view along the axis - how to properly calculate not understand, can anyone help
    Vector2D - I do not know how to calculate


    That count if you do not know what it looks like?

  4. #4
    Join Date
    Apr 2011
    Posts
    25
    Thanks
    0
    Thanked 27 Times in 15 Posts

    Default

    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.

  5. The Following User Says Thank You to mOwl For This Useful Post:

    wessie (13th July 2013)

  6. #5
    Join Date
    Apr 2013
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mOwl View Post
    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.
    So the easiest way to tell. But to explain .....

  7. #6
    Join Date
    Jan 2010
    Location
    America
    Posts
    244
    Thanks
    510
    Thanked 172 Times in 120 Posts

    Default

    bool; getC0de -- 2dto3d));
    if
    2d=true;
    return;
    false;
    [SIGPIC][/SIGPIC]

  8. #7
    Join Date
    Jun 2009
    Location
    https://www.downloadedskills.com/
    Age
    29
    Posts
    421
    Thanks
    65
    Thanked 686 Times in 216 Posts

    Default

    Quote Originally Posted by VDV View Post
    So the easiest way to tell. But to explain .....
    I think mOwl pointed you into the right direction

    Quote Originally Posted by mOwl View Post
    I wish you the best of luck to project 3d coordinates in a 2d screen space without even knowing what vectors are, or what vector operations are.
    Logical conclusion, look it up and study it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •